root/trunk/libffado/src/dice/dice_eap.cpp

Revision 2057, 58.6 kB (checked in by adi, 11 years ago)

DICE-EAP: Get Capture/Playback names when EAP router is present.

When a router is available, Capture/Playback, i.e. inputs/outputs for
jack, are related to the corresponding entries in the router table.
When no router is available (no initialized router or no initialized
EAP) Capture/Playback are receivers/transmitters respectively.

Patch by Philippe Carriere

Line 
1 /*
2  * Copyright (C) 2005-2009 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #include "dice_avdevice.h"
25
26 #include "dice_eap.h"
27 #include "dice_defines.h"
28
29 #include "libutil/SystemTimeSource.h"
30 #include "libutil/ByteSwap.h"
31
32 #include <cstdio>
33
34 namespace Dice {
35
36 // ----------- helper functions -------------
37
38 #if 0
39 static const char *
40 srcBlockToString(const char id)
41 {
42     switch(id) {
43         case eRS_AES:   return "AES ";
44         case eRS_ADAT:  return "ADAT";
45         case eRS_Mixer: return "MXR ";
46         case eRS_InS0:  return "INS0";
47         case eRS_InS1:  return "INS1";
48         case eRS_ARM:   return "ARM ";
49         case eRS_ARX0:  return "AVS0";
50         case eRS_ARX1:  return "AVS1";
51         case eRS_Muted: return "MUTE";
52         default :       return "RSVD";
53     }
54 }
55
56 static  const char *
57 dstBlockToString(const char id)
58 {
59     switch(id) {
60         case eRD_AES:    return "AES ";
61         case eRD_ADAT:   return "ADAT";
62         case eRD_Mixer0: return "MXR0";
63         case eRD_Mixer1: return "MXR1";
64         case eRD_InS0:   return "INS0";
65         case eRD_InS1:   return "INS1";
66         case eRD_ARM:    return "ARM ";
67         case eRD_ATX0:   return "AVS0";
68         case eRD_ATX1:   return "AVS1";
69         case eRD_Muted:  return "MUTE";
70         default : return "RSVD";
71     }
72 }
73 #endif
74
75 IMPL_DEBUG_MODULE( EAP, EAP, DEBUG_LEVEL_NORMAL );
76
77 EAP::EAP(Device &d)
78 : Control::Container(&d, "EAP")
79 , m_device(d)
80 , m_mixer( NULL )
81 , m_router( NULL )
82 , m_current_cfg_routing_low ( RouterConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_LOW_ROUTER ) )
83 , m_current_cfg_routing_mid ( RouterConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_MID_ROUTER ) )
84 , m_current_cfg_routing_high( RouterConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_HIGH_ROUTER) )
85 , m_current_cfg_stream_low  ( StreamConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_LOW_STREAM ) )
86 , m_current_cfg_stream_mid  ( StreamConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_MID_STREAM ) )
87 , m_current_cfg_stream_high ( StreamConfig(*this, eRT_CurrentCfg, DICE_EAP_CURRCFG_HIGH_STREAM) )
88 {
89 }
90
91 EAP::~EAP()
92 {
93     // remove all control elements registered to this device (w/o free)
94     clearElements(false);
95
96     // delete the helper classes
97     if(m_mixer) delete m_mixer;
98     if(m_router) delete m_router;
99 }
100
101 // offsets and sizes are returned in quadlets, but we use byte values, hence the *= 4
102 #define DICE_EAP_READREG_AND_CHECK(base, addr, var) { \
103     if(!readReg(base, addr, &var)) { \
104         debugError("Could not initialize " #var "\n"); \
105         return false; \
106     } \
107     var *= 4; \
108 }
109
110 bool
111 EAP::init() {
112     if(!supportsEAP(m_device)) {
113         debugWarning("no EAP mixer (device does not support EAP)\n");
114         return false;
115     }
116
117     // offsets and sizes are returned in quadlets, but we use byte values
118     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CAPABILITY_SPACE_OFF, m_capability_offset);
119     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CAPABILITY_SPACE_SZ, m_capability_size);
120     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CMD_SPACE_OFF, m_cmd_offset);
121     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CMD_SPACE_SZ, m_cmd_size);
122     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_MIXER_SPACE_OFF, m_mixer_offset);
123     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_MIXER_SPACE_SZ, m_mixer_size);
124     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_PEAK_SPACE_OFF, m_peak_offset);
125     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_PEAK_SPACE_SZ, m_peak_size);
126     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_NEW_ROUTING_SPACE_OFF, m_new_routing_offset);
127     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_NEW_ROUTING_SPACE_SZ, m_new_routing_size);
128     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_NEW_STREAM_CFG_SPACE_OFF, m_new_stream_cfg_offset);
129     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_NEW_STREAM_CFG_SPACE_SZ, m_new_stream_cfg_size);
130     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CURR_CFG_SPACE_OFF, m_curr_cfg_offset);
131     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_CURR_CFG_SPACE_SZ, m_curr_cfg_size);
132     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_STAND_ALONE_CFG_SPACE_OFF, m_standalone_offset);
133     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_STAND_ALONE_CFG_SPACE_SZ, m_standalone_size);
134     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_APP_SPACE_OFF, m_app_offset);
135     DICE_EAP_READREG_AND_CHECK(eRT_Base, DICE_EAP_APP_SPACE_SZ, m_app_size);
136
137     // initialize the capability info
138     quadlet_t tmp;
139     if(!readReg(eRT_Capability, DICE_EAP_CAPABILITY_ROUTER, &tmp)) {
140         debugError("Could not read router capabilities\n");
141         return false;
142     }
143     m_router_exposed = (tmp >> DICE_EAP_CAP_ROUTER_EXPOSED) & 0x01;
144     m_router_readonly = (tmp >> DICE_EAP_CAP_ROUTER_READONLY) & 0x01;
145     m_router_flashstored = (tmp >> DICE_EAP_CAP_ROUTER_FLASHSTORED) & 0x01;
146     m_router_nb_entries = (tmp >> DICE_EAP_CAP_ROUTER_MAXROUTES) & 0xFFFF;
147
148     if(!readReg(eRT_Capability, DICE_EAP_CAPABILITY_MIXER, &tmp)) {
149         debugError("Could not read mixer capabilities\n");
150         return false;
151     }
152     m_mixer_exposed = (tmp >> DICE_EAP_CAP_MIXER_EXPOSED) & 0x01;
153     m_mixer_readonly = (tmp >> DICE_EAP_CAP_MIXER_READONLY) & 0x01;
154     m_mixer_flashstored = (tmp >> DICE_EAP_CAP_MIXER_FLASHSTORED) & 0x01;
155     m_mixer_tx_id = (tmp >> DICE_EAP_CAP_MIXER_IN_DEV) & 0x000F;
156     m_mixer_rx_id = (tmp >> DICE_EAP_CAP_MIXER_OUT_DEV) & 0x000F;
157     m_mixer_nb_tx = (tmp >> DICE_EAP_CAP_MIXER_INPUTS) & 0x00FF;
158     m_mixer_nb_rx = (tmp >> DICE_EAP_CAP_MIXER_OUTPUTS) & 0x00FF;
159
160     if(!readReg(eRT_Capability, DICE_EAP_CAPABILITY_GENERAL, &tmp)) {
161         debugError("Could not read general capabilities\n");
162         return false;
163     }
164     m_general_support_dynstream = (tmp >> DICE_EAP_CAP_GENERAL_STRM_CFG_EN) & 0x01;
165     m_general_support_flash = (tmp >> DICE_EAP_CAP_GENERAL_FLASH_EN) & 0x01;
166     m_general_peak_enabled = (tmp >> DICE_EAP_CAP_GENERAL_PEAK_EN) & 0x01;
167     m_general_max_tx = (tmp >> DICE_EAP_CAP_GENERAL_MAX_TX_STREAM) & 0x0F;
168     m_general_max_rx = (tmp >> DICE_EAP_CAP_GENERAL_MAX_RX_STREAM) & 0x0F;
169     m_general_stream_cfg_stored = (tmp >> DICE_EAP_CAP_GENERAL_STRM_CFG_FLS) & 0x01;
170     m_general_chip = (tmp >> DICE_EAP_CAP_GENERAL_CHIP) & 0xFFFF;
171
172     // update our view on the current configuration
173     if(!updateConfigurationCache()) {
174         debugError("Could not initialize configuration cache\n");
175         return false;
176     }
177
178     // initialize the helper classes
179     if (m_mixer_exposed) {
180         // initialize the mixer
181         m_mixer = new EAP::Mixer(*this);
182         if(m_mixer == NULL) {
183             debugError("Could not allocate memory for mixer\n");
184             return false;
185         }
186         if(!m_mixer->init()) {
187             debugError("Could not initialize mixer\n");
188             delete m_mixer;
189             m_mixer = NULL;
190             return false;
191         }
192         // add the mixer to the EAP control container
193         if(!addElement(m_mixer)) {
194             debugWarning("Failed to add mixer to control tree\n");
195         }
196        
197         // initialize the peak meter
198         m_router = new EAP::Router(*this);
199         if(m_router == NULL) {
200             debugError("Could not allocate memory for router\n");
201             return false;
202         }
203         m_router->update();
204
205         // add the router to the EAP control container
206         if(!addElement(m_router)) {
207             debugWarning("Failed to add router to control tree\n");
208         }
209     }
210
211     return true;
212 }
213
214
215 void
216 EAP::update()
217 {
218     // update EAP from the last init
219     //   update router sources and destinations
220     if (m_router) {
221         m_router->update();
222     }
223 }
224
225 void
226 EAP::setupSources() {
227     // define router sources (possibly depending on the samplerate)
228     switch(m_device.getCurrentConfig()) {
229         case Device::eDC_Low: setupSources_low(); return;
230         case Device::eDC_Mid: setupSources_mid(); return;
231         case Device::eDC_High: setupSources_high(); return;
232         default:
233             debugError("Unsupported configuration mode\n");
234             return;
235     }
236 }
237
238 void
239 EAP::setupSources_low() {
240     // add the routing sources for a DICE chip
241     switch(m_general_chip) {
242         case DICE_EAP_CAP_GENERAL_CHIP_DICEII:
243             // router/EAP currently not supported
244             break;
245         case DICE_EAP_CAP_GENERAL_CHIP_DICEJR:
246             // second audio port (unique to the junior)
247             addSource("InS1", 0, 8, eRS_InS1);
248         case DICE_EAP_CAP_GENERAL_CHIP_DICEMINI:
249             /// these are common to the mini and junior
250             // the AES receiver
251             addSource("AES", 0, 8, eRS_AES);
252             // the ADAT receiver
253             addSource("ADAT", 0, 8, eRS_ADAT);
254             // the Mixer outputs
255             addSource("MixerOut", 0, 16, eRS_Mixer);
256             // the first audio port
257             addSource("InS0", 0, 8, eRS_InS0);
258             // the ARM audio port
259             addSource("ARM", 0, 8, eRS_ARM);
260             // the 1394 stream receivers
261             addSource("1394_0", 0, 16, eRS_ARX0);
262             addSource("1394_1", 0, 16, eRS_ARX1);
263             // mute
264             addSource("Mute", 0, 1, eRS_Muted);
265             break;
266         default:
267             // this is an unsupported chip
268             break;
269     }
270 }
271
272 void
273 EAP::setupSources_mid() {
274     setupSources_low();
275 }
276
277 void
278 EAP::setupSources_high() {
279     setupSources_low();
280 }
281
282 void
283 EAP::setupDestinations() {
284     switch(m_device.getCurrentConfig()) {
285         case Device::eDC_Low: setupDestinations_low(); return;
286         case Device::eDC_Mid: setupDestinations_mid(); return;
287         case Device::eDC_High: setupDestinations_high(); return;
288         default:
289             debugError("Unsupported configuration mode\n");
290             return;
291     }
292 }
293
294 void
295 EAP::setupDestinations_low() {
296     // add the routing destinations for a DICE chip
297     switch(m_general_chip) {
298         case DICE_EAP_CAP_GENERAL_CHIP_DICEII:
299             // router/EAP currently not supported
300             break;
301         case DICE_EAP_CAP_GENERAL_CHIP_DICEJR:
302             // second audio port (unique to the junior)
303             addDestination("InS1", 0, 8, eRD_InS1);
304         case DICE_EAP_CAP_GENERAL_CHIP_DICEMINI:
305             /// these are common to the mini and junior
306             // the AES receiver
307             addDestination("AES", 0, 8, eRD_AES);
308             // the ADAT receiver
309             addDestination("ADAT", 0, 8, eRD_ADAT);
310             // the Mixer outputs
311             addDestination("MixerIn", 0, 16, eRD_Mixer0);
312             addDestination("MixerIn", 0, 2, eRD_Mixer1, 16);
313             // the first audio port
314             addDestination("InS0", 0, 8, eRD_InS0);
315             // the ARM audio port
316             addDestination("ARM", 0, 8, eRD_ARM);
317             // the 1394 stream receivers
318             addDestination("1394_0", 0, 16, eRD_ATX0);
319             addDestination("1394_1", 0, 16, eRD_ATX1);
320             // mute
321             addDestination("Mute", 0, 1, eRD_Muted);
322             break;
323         default:
324             // this is an unsupported chip
325             break;
326     }
327 }
328 void
329 EAP::setupDestinations_mid() {
330     setupDestinations_low();
331 }
332 void
333 EAP::setupDestinations_high() {
334     setupDestinations_low();
335 }
336
337 void
338 EAP::addSource(const std::string name, unsigned int base, unsigned int count,
339                enum eRouteSource srcid, unsigned int offset)
340 {
341     m_router->addSource(name, srcid, base, count, offset);
342 }
343 void
344 EAP::addDestination(const std::string name, unsigned int base, unsigned int count,
345                     enum eRouteDestination destid, unsigned int offset)
346 {
347     m_router->addDestination(name, destid, base, count, offset);
348 }
349
350 bool
351 EAP::updateConfigurationCache()
352 {
353     if(!m_current_cfg_routing_low.read()) {
354         debugError("Could not initialize current routing configuration (low rates)\n");
355         return false;
356     }
357     if(!m_current_cfg_routing_mid.read()) {
358         debugError("Could not initialize current routing configuration (mid rates)\n");
359         return false;
360     }
361     if(!m_current_cfg_routing_high.read()) {
362         debugError("Could not initialize current routing configuration (high rates)\n");
363         return false;
364     }
365     if(!m_current_cfg_stream_low.read()) {
366         debugError("Could not initialize current stream configuration (low rates)\n");
367         return false;
368     }
369     if(!m_current_cfg_stream_mid.read()) {
370         debugError("Could not initialize current stream configuration (mid rates)\n");
371         return false;
372     }
373     if(!m_current_cfg_stream_high.read()) {
374         debugError("Could not initialize current stream configuration (high rates)\n");
375         return false;
376     }
377     if(m_mixer) m_mixer->updateNameCache();
378     return true;
379 }
380
381 // Get capture and playback names
382 //   If the device has a router, capture and playback are destinations and sources, respectively,
383 //     as defined above
384 //   If no router is found, transmitters and receivers names are returned
385
386 stringlist
387 EAP::getCptrNameString(unsigned int i) {
388     std::vector<unsigned int> destid;
389     unsigned int destid_0;
390     stringlist cptr_names;
391     std::string dest_name, src_name;
392    
393     if (m_router) {
394         switch (i) {
395           case 0: destid_0 = (eRD_ATX0<<4); break;
396           case 1: destid_0 = (eRD_ATX1<<4); break;
397           // Only 2 transmitter possible (?)
398           default: return cptr_names;
399         }
400         // At most 16 destinations per eRD
401         for (int j=0; j<16; j++) {
402           destid.push_back(destid_0+j);
403         }
404         for (unsigned it=0; it<destid.size(); it++) {
405           // If destination identifier is not part of the router, destination name will be empty
406           dest_name = m_router->getDestinationName(destid.at(it));
407           if (dest_name.size() > 0) {
408             // get a source possibly routed to the destination (only one source per destination)
409             src_name = m_router->getSourceForDestination(dest_name);
410             if (src_name.size() > 0) {
411               dest_name.append(" ("); dest_name.append(src_name); dest_name.append(")");
412             }
413             cptr_names.push_back(dest_name);
414           }
415         }
416
417     } else {
418         StreamConfig *scfg = getActiveStreamConfig();
419         if(scfg) {
420           cptr_names = scfg->getTxNamesString(i);
421         }
422     }
423     return cptr_names;
424 }
425
426 stringlist
427 EAP::getPbckNameString(unsigned int i) {
428     std::vector<unsigned int> srcid;
429     unsigned int srcid_0;
430     stringlist pbck_names, dest_names;
431     std::string src_name;
432    
433     if (m_router) {
434         switch (i) {
435            case 0: srcid_0 = (eRS_ARX0<<4); break;
436            case 1: srcid_0 = (eRS_ARX1<<4); break;
437             // Only 2 receiver possible (?)
438           default: return pbck_names;
439         }
440         // At most 16 destinations per eRD
441         for (int j=0; j<16; j++) {
442           srcid.push_back(srcid_0+j);
443         }
444         for (unsigned it=0; it<srcid.size(); it++) {
445           // If source identifier is not part of the router, source name will be empty
446           src_name = m_router->getSourceName(srcid.at(it));
447           if (src_name.size() > 0) {
448             // Search for destinations routed to this source
449             //   Multiple destinations for a single source are possible
450             dest_names = m_router->getDestinationsForSource(src_name);
451             if (dest_names.size() > 0) {
452               src_name.append(" (");
453               stringlist::iterator it_d = dest_names.begin();
454               stringlist::iterator it_d_end_m1 = dest_names.end(); --it_d_end_m1;
455               while (it_d != it_d_end_m1) {
456                 src_name.append((*it_d).c_str()); src_name.append("; ");
457                 it_d++;
458               }
459               src_name.append((*it_d).c_str()); src_name.append(")");
460             }
461             pbck_names.push_back(src_name);
462           }
463         }
464     } else {
465         StreamConfig *scfg = getActiveStreamConfig();
466         if(scfg) {
467           pbck_names = scfg->getRxNamesString(i);
468         }
469     }
470     return pbck_names;
471 }
472
473 /**
474  * Returns the router configuration for the current rate mode
475  */
476 EAP::RouterConfig *
477 EAP::getActiveRouterConfig()
478 {
479     switch(m_device.getCurrentConfig()) {
480         case Device::eDC_Low: return &m_current_cfg_routing_low;
481         case Device::eDC_Mid: return &m_current_cfg_routing_mid;
482         case Device::eDC_High: return &m_current_cfg_routing_high;
483         default:
484             debugError("Unsupported configuration mode\n");
485             return NULL;
486     }
487 }
488
489 /**
490  * Returns the stream configuration for the current rate mode
491  */
492 EAP::StreamConfig *
493 EAP::getActiveStreamConfig()
494 {
495     switch(m_device.getCurrentConfig()) {
496         case Device::eDC_Low: return &m_current_cfg_stream_low;
497         case Device::eDC_Mid: return &m_current_cfg_stream_mid;
498         case Device::eDC_High: return &m_current_cfg_stream_high;
499         default:
500             debugError("Unsupported configuration mode\n");
501             return NULL;
502     }
503 }
504
505 /**
506  * Uploads a new router configuration to the device
507  * @param  rcfg The new RouterConfig
508  * @param low store as config for the low rates
509  * @param mid store as config for the mid rates
510  * @param high store as config for the high rates
511  * @return true if successful, false otherwise
512  */
513 bool
514 EAP::updateRouterConfig(RouterConfig& rcfg, bool low, bool mid, bool high) {
515     // write the router config to the appropriate memory space on the device
516     if(!rcfg.write(eRT_NewRouting, 0)) {
517         debugError("Could not write new router configuration\n");
518         return false;
519     }
520     // perform the store operation
521     if(!loadRouterConfig(low, mid, high)) {
522         debugError("Could not activate new router configuration\n");
523         updateConfigurationCache(); // for consistency
524         return false;
525     }
526     return updateConfigurationCache();
527 }
528
529 /**
530  * Uploads a new router configuration to replace the configuration
531  * for the current rate.
532  * @param  rcfg The new RouterConfig
533  * @return true if successful, false otherwise
534  */
535 bool
536 EAP::updateCurrentRouterConfig(RouterConfig& rcfg) {
537     switch(m_device.getCurrentConfig()) {
538         case Device::eDC_Low: return updateRouterConfig(rcfg, true, false, false);
539         case Device::eDC_Mid: return updateRouterConfig(rcfg, false, true, false);
540         case Device::eDC_High: return updateRouterConfig(rcfg, false, false, true);
541         default:
542             debugError("Unsupported configuration mode\n");
543             return false;
544     }
545 }
546
547 /**
548  * Uploads a new stream configuration to the device
549  * @param scfg The new StreamConfig
550  * @param low store as config for the low rates
551  * @param mid store as config for the mid rates
552  * @param high store as config for the high rates
553  * @return true if successful, false otherwise
554  */
555 bool
556 EAP::updateStreamConfig(StreamConfig& scfg, bool low, bool mid, bool high) {
557     // write the stream config to the appropriate memory space on the device
558     if(!scfg.write(eRT_NewStreamCfg, 0)) {
559         debugError("Could not write new stream configuration\n");
560         return false;
561     }
562     // perform the store operation
563     if(!loadStreamConfig(low, mid, high)) {
564         debugError("Could not activate new stream configuration\n");
565         updateConfigurationCache(); // for consistency
566         return false;
567     }
568     return updateConfigurationCache();
569 }
570
571 /**
572  * Uploads a new router and stream configuration to the device
573  * @param  rcfg The new RouterConfig
574  * @param  scfg The new StreamConfig
575  * @param low store as config for the low rates
576  * @param mid store as config for the mid rates
577  * @param high store as config for the high rates
578  * @return true if successful, false otherwise
579  */
580 bool
581 EAP::updateStreamConfig(RouterConfig& rcfg, StreamConfig& scfg, bool low, bool mid, bool high) {
582     // write the router config to the appropriate memory space on the device
583     if(!rcfg.write(eRT_NewRouting, 0)) {
584         debugError("Could not write new router configuration\n");
585         return false;
586     }
587     // write the stream config to the appropriate memory space on the device
588     if(!scfg.write(eRT_NewStreamCfg, 0)) {
589         debugError("Could not write new stream configuration\n");
590         return false;
591     }
592     // perform the store operation
593     if(!loadRouterAndStreamConfig(low, mid, high)) {
594         debugError("Could not activate new router/stream configuration\n");
595         updateConfigurationCache(); // for consistency
596         return false;
597     }
598     return updateConfigurationCache();
599 }
600
601
602 bool
603 EAP::loadFlashConfig() {
604     bool retval = true;
605     debugWarning("Untested code\n");
606     fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_FLASH_CFG;
607     cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE;
608     if(!commandHelper(cmd)) {
609         debugWarning("Command failed\n");
610         retval = false;
611     }
612     retval &= updateConfigurationCache();
613     return retval;
614 }
615
616 bool
617 EAP::storeFlashConfig() {
618     //debugWarning("Untested code\n") // Works. -Arnold;
619     fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_ST_FLASH_CFG;
620     cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE;
621     return commandHelper(cmd);
622 }
623
624 // helpers
625 void
626 EAP::show()
627 {
628     printMessage("== DICE EAP ==\n");
629     printMessage("Parameter Space info:\n");
630     printMessage(" Capability        : offset=%04X size=%06d\n", m_capability_offset, m_capability_size);
631     printMessage(" Command           : offset=%04X size=%06d\n", m_cmd_offset, m_cmd_size);
632     printMessage(" Mixer             : offset=%04X size=%06d\n", m_mixer_offset, m_mixer_size);
633     printMessage(" Peak              : offset=%04X size=%06d\n", m_peak_offset, m_peak_size);
634     printMessage(" New Routing Cfg   : offset=%04X size=%06d\n", m_new_routing_offset, m_new_routing_size);
635     printMessage(" New Stream Cfg    : offset=%04X size=%06d\n", m_new_stream_cfg_offset, m_new_stream_cfg_size);
636     printMessage(" Current Cfg       : offset=%04X size=%06d\n", m_curr_cfg_offset, m_curr_cfg_size);
637     printMessage(" Standalone Cfg    : offset=%04X size=%06d\n", m_standalone_offset, m_standalone_size);
638     printMessage(" Application Space : offset=%04X size=%06d\n", m_app_offset, m_app_size);
639
640     printMessage("Capabilities:\n");
641     printMessage(" Router: %sexposed, %swritable, %sstored, %d routes\n",
642                                      (m_router_exposed?"":"not "),
643                                      (m_router_readonly?"not ":""),
644                                      (m_router_flashstored?"":"not "),
645                                      m_router_nb_entries);
646     printMessage(" Mixer : %sexposed, %swritable, %sstored\n",
647                                      (m_mixer_exposed?"":"not "),
648                                      (m_mixer_readonly?"not ":""),
649                                      (m_mixer_flashstored?"":"not "));
650     printMessage("         tx id: (%d==eRD_Mixer0) ? %s, rx id: (%d==eRS_Mixer) ? %s\n",
651                                      m_mixer_tx_id, (m_mixer_tx_id == eRD_Mixer0)?"true":"false",
652                                      m_mixer_rx_id, (m_mixer_rx_id == eRS_Mixer) ?"true":"false");
653     printMessage("         nb tx channels: %d, nb rx channels: %d\n", m_mixer_nb_tx, m_mixer_nb_rx);
654     printMessage(" General: dynamic stream config %ssupported\n",
655                                      (m_general_support_dynstream?"":"not "));
656     printMessage("          flash load and store %ssupported\n",
657                                      (m_general_support_flash?"":"not "));
658     printMessage("          peak metering %s\n",
659                                      (m_general_peak_enabled?"enabled":"disabled"));
660     printMessage("          stream config %sstored\n",
661                                      (m_general_stream_cfg_stored?"":"not "));
662     printMessage("          max TX streams: %d, max RX streams: %d\n",
663                                      m_general_max_tx, m_general_max_rx);
664
665     if(m_general_chip == DICE_EAP_CAP_GENERAL_CHIP_DICEII) {
666         printMessage("          Chip: DICE-II\n");
667     } else if(m_general_chip == DICE_EAP_CAP_GENERAL_CHIP_DICEMINI) {
668         printMessage("          Chip: DICE Mini (TCD2210)\n");
669     } else if(m_general_chip == DICE_EAP_CAP_GENERAL_CHIP_DICEJR) {
670         printMessage("          Chip: DICE Junior (TCD2220)\n");
671     }
672
673     printMessage("--- Mixer configuration ---\n");
674     if(m_mixer) {
675         m_mixer->show();
676     }
677     printMessage("--- Router/Peak space ---\n");
678     if(m_router) {
679         m_router->show();
680     }
681
682     printMessage("--- Active Router ---\n");
683     RouterConfig *rcfg = getActiveRouterConfig();
684     if(rcfg) {
685         rcfg->show();
686     }
687     printMessage("--- Active Stream ---\n");
688     StreamConfig *scfg = getActiveStreamConfig();
689     if(scfg) {
690         scfg->show();
691     }
692
693 // fixme
694 //     size_t len = 0x1000;
695 //     quadlet_t tmp[len];
696 //     if(!readRegBlock( eRT_CurrentCfg, DICE_EAP_CURRCFG_LOW_STREAM, tmp, len*4) ) {
697 //         debugError("Failed to read block\n");
698 //     } else {
699 //         hexDumpQuadlets(tmp, len);
700 //     }
701
702 }
703 void
704 EAP::showApplication()
705 {
706     printMessage("--- Application space ---\n");
707     fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(128, sizeof(fb_quadlet_t));
708     unsigned int appsize = m_app_size; /// m_app_size is rather big. Start with the first four block of 128 quadlets...
709     unsigned int offset = 0;
710     while ( appsize > 0 ) {
711         if ( ! readRegBlock( eRT_Application, offset, tmp, ((appsize<128)?appsize:128)*sizeof(fb_quadlet_t) ) )
712             appsize = 0;
713         else {
714             hexDumpQuadlets(tmp, 128);
715             offset += 128*sizeof(fb_quadlet_t);
716             appsize -= 128*sizeof(fb_quadlet_t);
717         }
718     }
719 }
720
721 // EAP load/store operations
722
723 enum EAP::eWaitReturn
724 EAP::operationBusy() {
725     fb_quadlet_t tmp;
726     if(!readReg(eRT_Command, DICE_EAP_COMMAND_OPCODE, &tmp)) {
727         debugError("Could not read opcode register\n");
728         return eWR_Error;
729     }
730     if( (tmp & DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE) == DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE) {
731         return eWR_Busy;
732     } else {
733         return eWR_Done;
734     }
735 }
736
737 enum EAP::eWaitReturn
738 EAP::waitForOperationEnd(int max_wait_time_ms) {
739     int max_waits = max_wait_time_ms;
740
741     while(max_waits--) {
742         enum eWaitReturn retval = operationBusy();
743         switch(retval) {
744             case eWR_Busy:
745                 break; // not done yet, keep waiting
746             case eWR_Done:
747                 return eWR_Done;
748             case eWR_Error:
749             case eWR_Timeout:
750                 debugError("Error while waiting for operation to end. (%d)\n", retval);
751         }
752         Util::SystemTimeSource::SleepUsecRelative(1000);
753     }
754     return eWR_Timeout;
755 }
756
757 bool
758 EAP::commandHelper(fb_quadlet_t cmd) {
759     // check whether another command is still running
760     if(operationBusy() == eWR_Busy) {
761         debugError("Other operation in progress\n");
762         return false;
763     }
764
765     // execute the command
766     if(!writeReg(eRT_Command, DICE_EAP_COMMAND_OPCODE, cmd)) {
767         debugError("Could not write opcode register\n");
768         return false;
769     }
770
771     // wait for the operation to end
772     enum eWaitReturn retval = waitForOperationEnd();
773     switch(retval) {
774         case eWR_Done:
775             break; // do nothing
776         case eWR_Timeout:
777             debugWarning("Time-out while waiting for operation to end. (%d)\n", retval);
778             return false;
779         case eWR_Error:
780         case eWR_Busy: // can't be returned
781             debugError("Error while waiting for operation to end. (%d)\n", retval);
782             return false;
783     }
784
785     // check the return value
786     if(!readReg(eRT_Command, DICE_EAP_COMMAND_RETVAL, &cmd)) {
787         debugError("Could not read return value register\n");
788         return false;
789     }
790     if(cmd != 0) {
791         debugWarning("Command failed\n");
792         return false;
793     } else {
794         debugOutput(DEBUG_LEVEL_VERBOSE, "Command successful\n");
795         return true;
796     }
797 }
798
799 bool
800 EAP::loadRouterConfig(bool low, bool mid, bool high) {
801     fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_ROUTER;
802     if(low) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_LOW;
803     if(mid) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_MID;
804     if(high) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_HIGH;
805     cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE;
806     return commandHelper(cmd);
807 }
808
809 bool
810 EAP::loadStreamConfig(bool low, bool mid, bool high) {
811     debugWarning("Untested code\n");
812     fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_STRM_CFG;
813     if(low) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_LOW;
814     if(mid) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_MID;
815     if(high) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_HIGH;
816     cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE;
817     return commandHelper(cmd);
818 }
819
820 bool
821 EAP::loadRouterAndStreamConfig(bool low, bool mid, bool high) {
822     debugWarning("Untested code\n");
823     fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_RTR_STRM_CFG;
824     if(low) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_LOW;
825     if(mid) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_MID;
826     if(high) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_HIGH;
827     cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_EXECUTE;
828     return commandHelper(cmd);
829 }
830
831 /*
832   I/O operations
833   */
834 bool
835 EAP::readReg(enum eRegBase base, unsigned offset, fb_quadlet_t *result) {
836     fb_nodeaddr_t addr = offsetGen(base, offset, 4);
837     return m_device.readReg(addr, result);
838 }
839
840 bool
841 EAP::writeReg(enum eRegBase base, unsigned offset, fb_quadlet_t data) {
842     fb_nodeaddr_t addr = offsetGen(base, offset, 4);
843     return m_device.writeReg(addr, data);
844 }
845
846 bool
847 EAP::readRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) {
848     fb_nodeaddr_t addr = offsetGen(base, offset, length);
849     return m_device.readRegBlock(addr, data, length);
850 }
851
852 bool
853 EAP::writeRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) {
854     fb_nodeaddr_t addr = offsetGen(base, offset, length);
855     return m_device.writeRegBlock(addr, data, length);
856 }
857
858 fb_nodeaddr_t
859 EAP::offsetGen(enum eRegBase base, unsigned offset, size_t length) {
860     fb_nodeaddr_t addr;
861     fb_nodeaddr_t maxlen;
862     switch(base) {
863         case eRT_Base:
864             addr = 0;
865             maxlen = DICE_EAP_MAX_SIZE;
866             break;
867         case eRT_Capability:
868             addr = m_capability_offset;
869             maxlen = m_capability_size;
870             break;
871         case eRT_Command:
872             addr = m_cmd_offset;
873             maxlen = m_cmd_size;
874             break;
875         case eRT_Mixer:
876             addr = m_mixer_offset;
877             maxlen = m_mixer_size;
878             break;
879         case eRT_Peak:
880             addr = m_peak_offset;
881             maxlen = m_peak_size;
882             break;
883         case eRT_NewRouting:
884             addr = m_new_routing_offset;
885             maxlen = m_new_routing_size;
886             break;
887         case eRT_NewStreamCfg:
888             addr = m_new_stream_cfg_offset;
889             maxlen = m_new_stream_cfg_size;
890             break;
891         case eRT_CurrentCfg:
892             addr = m_curr_cfg_offset;
893             maxlen = m_curr_cfg_size;
894             break;
895         case eRT_Standalone:
896             addr = m_standalone_offset;
897             maxlen = m_standalone_size;
898             break;
899         case eRT_Application:
900             addr = m_app_offset;
901             maxlen = m_app_size;
902             break;
903         default:
904             debugError("Unsupported base address\n");
905             return 0;
906     };
907
908     // out-of-range check
909     if(length > maxlen) {
910         debugError("requested length too large: %zd > %"PRIu64"\n", length, maxlen);
911         return DICE_INVALID_OFFSET;
912     }
913     return DICE_EAP_BASE + addr + offset;
914 }
915
916 /**
917  * Check whether a device supports eap
918  * @param d the device to check
919  * @return true if the device supports EAP
920  */
921 bool
922 EAP::supportsEAP(Device &d)
923 {
924     DebugModule &m_debugModule = d.m_debugModule;
925     quadlet_t tmp;
926     if(!d.readReg(DICE_EAP_BASE, &tmp)) {
927         debugOutput(DEBUG_LEVEL_VERBOSE, "Could not read from DICE EAP base address\n");
928         return false;
929     }
930     if(!d.readReg(DICE_EAP_BASE + DICE_EAP_ZERO_MARKER_1, &tmp)) {
931         debugOutput(DEBUG_LEVEL_VERBOSE, "Could not read from DICE EAP zero marker\n");
932         return false;
933     }
934     if(tmp != 0) {
935         debugOutput(DEBUG_LEVEL_VERBOSE, "DICE EAP zero marker not zero\n");
936         return false;
937     }
938     return true;
939 }
940
941 // -------------------------------- Mixer ----------------------------------
942 //   Dice matrix-mixer is a one-dimensional array with inputs index varying
943 //    first
944 //
945 //   "ffado convention" is that inputs are rows and outputs are columns
946 //
947 EAP::Mixer::Mixer(EAP &p)
948 : Control::MatrixMixer(&p.m_device, "MatrixMixer")
949 , m_eap(p)
950 , m_coeff(NULL)
951 , m_debugModule(p.m_debugModule)
952 {
953 }
954
955 EAP::Mixer::~Mixer()
956 {
957     if (m_coeff) {
958         free(m_coeff);
959         m_coeff = NULL;
960     }
961 }
962
963 bool
964 EAP::Mixer::init()
965 {
966     if(!m_eap.m_mixer_exposed) {
967         debugError("Device does not expose mixer\n");
968         return false;
969     }
970
971     // remove previous coefficient array
972     if(m_coeff) {
973         free(m_coeff);
974         m_coeff = NULL;
975     }
976    
977     // allocate coefficient array
978     int nb_inputs = m_eap.m_mixer_nb_tx;
979     int nb_outputs = m_eap.m_mixer_nb_rx;
980
981     m_coeff = (fb_quadlet_t *)calloc(nb_outputs * nb_inputs, sizeof(fb_quadlet_t));
982
983     // load initial values
984     if(!loadCoefficients()) {
985         debugWarning("Could not initialize coefficients\n");
986         return false;
987     }
988     updateNameCache();
989     return true;
990 }
991
992 bool
993 EAP::Mixer::loadCoefficients()
994 {
995     if(m_coeff == NULL) {
996         debugError("Coefficient cache not initialized\n");
997         return false;
998     }
999     int nb_inputs = m_eap.m_mixer_nb_tx;
1000     int nb_outputs = m_eap.m_mixer_nb_rx;
1001     if(!m_eap.readRegBlock(eRT_Mixer, 4, m_coeff, nb_inputs * nb_outputs * 4)) {
1002         debugError("Failed to read coefficients\n");
1003         return false;
1004     }
1005     return true;
1006 }
1007
1008 bool
1009 EAP::Mixer::storeCoefficients()
1010 {
1011     if(m_coeff == NULL) {
1012         debugError("Coefficient cache not initialized\n");
1013         return false;
1014     }
1015     if(m_eap.m_mixer_readonly) {
1016         debugWarning("Mixer is read-only\n");
1017         return false;
1018     }
1019     int nb_inputs = m_eap.m_mixer_nb_tx;
1020     int nb_outputs = m_eap.m_mixer_nb_rx;
1021     if(!m_eap.writeRegBlock(eRT_Mixer, 4, m_coeff, nb_inputs * nb_outputs * 4)) {
1022         debugError("Failed to read coefficients\n");
1023         return false;
1024     }
1025     return true;
1026 }
1027
1028 void
1029 EAP::Mixer::updateNameCache()
1030 {
1031     debugWarning("What is this function about?\n");
1032 #if 0
1033     // figure out the number of i/o's
1034     int nb_inputs = m_eap.m_mixer_nb_tx;
1035     int nb_outputs = m_eap.m_mixer_nb_rx;
1036
1037     // clear the previous map
1038     m_input_route_map.clear();
1039     m_output_route_map.clear();
1040
1041     // find the active router configuration
1042     RouterConfig * rcfg = m_eap.getActiveRouterConfig();
1043     if(rcfg == NULL) {
1044         debugError("Could not get active routing info\n");
1045         return;
1046     }
1047
1048     // find the inputs
1049     for(int i=0; i < nb_inputs; i++) {
1050         int ch = i;
1051         // the destination id of the mixer input
1052         int dest_int = m_eap.m_mixer_tx_id;
1053
1054         // from the DICE mixer spec:
1055         // we can have 16 channels per "block"
1056         // if there are more, consecutive block id's are assumed
1057         while(ch > 15) {
1058             ch -= 16;
1059             dest_int += 1;
1060         }
1061         // the destination block and channel corresponding with this
1062         // mixer input is now known
1063         enum eRouteDestination dest = rcfg->intToRouteDestination(dest_int);
1064
1065         // get the source for this mixer channel
1066         m_input_route_map[i] = rcfg->getRouteForDestination(dest, ch);
1067
1068         debugOutput(DEBUG_LEVEL_VERBOSE, "Mixer input channel %2d source: %s (%d)\n", i,
1069                                           srcBlockToString(m_input_route_map[i].src),
1070                                           m_input_route_map[i].srcChannel);
1071     }
1072
1073     // find where the outputs are connected to
1074     for(int i=0; i < nb_outputs; i++) {
1075         int ch = i;
1076         // the source id of the mixer input
1077         int src_int = m_eap.m_mixer_rx_id;
1078
1079         // from the DICE mixer spec:
1080         // we can have 16 channels per "block"
1081         // if there are more, consecutive block id's are assumed
1082         while(ch > 15) {
1083             ch -= 16;
1084             src_int += 1;
1085         }
1086
1087         // the source block and channel corresponding with this
1088         // mixer output is now known
1089         enum eRouteSource src = rcfg->intToRouteSource(src_int);
1090
1091         // get the routing destinations for this mixer channel
1092         m_output_route_map[i] = rcfg->getRoutesForSource(src, ch);
1093
1094         #ifdef DEBUG
1095         std::string destinations;
1096         for ( RouterConfig::RouteVectorIterator it = m_output_route_map[i].begin();
1097             it != m_output_route_map[i].end();
1098             ++it )
1099         {
1100             RouterConfig::Route r = *it;
1101             // check whether the destination is valid
1102             if((r.dst != eRD_Invalid) && (r.dstChannel >= 0)) {
1103                 char tmp[128];
1104                 snprintf(tmp, 128, "%s:%d,", dstBlockToString(r.dst), r.dstChannel);
1105                 destinations += tmp;
1106             }
1107         }
1108         debugOutput(DEBUG_LEVEL_VERBOSE, "Mixer output channel %2d destinations: %s\n", i, destinations.c_str());
1109         #endif
1110     }
1111 #endif
1112 }
1113
1114 void
1115 EAP::Mixer::show()
1116 {
1117     int nb_inputs = m_eap.m_mixer_nb_tx;
1118     int nb_outputs = m_eap.m_mixer_nb_rx;
1119
1120     updateNameCache();
1121
1122     const size_t bufflen = 4096;
1123     char tmp[bufflen];
1124     int cnt;
1125
1126     //
1127     // Caution the user that, displaying as further, because inputs index varies first
1128     //  inputs will appears as columns at the opposite of the "ffado convention"
1129     printMessage("   -- inputs index -->>\n");
1130     cnt = 0;
1131     for(int j=0; j < nb_inputs; j++) {
1132         cnt += snprintf(tmp+cnt, bufflen-cnt, "   %02d   ", j);
1133     }
1134     printMessage("%s\n", tmp);
1135
1136     cnt = 0;
1137     for(int j=0; j < nb_inputs; j++) {
1138         cnt += snprintf(tmp+cnt, bufflen-cnt, "%s ", getRowName(j).data());
1139     }
1140     printMessage("%s\n", tmp);
1141
1142     // display coefficients
1143     for(int i=0; i < nb_outputs; i++) {
1144         cnt = 0;
1145         for(int j=0; j < nb_inputs; j++) {
1146             cnt += snprintf(tmp+cnt, bufflen-cnt, "%07d ", *(m_coeff + nb_inputs * i + j));
1147         }
1148  
1149         // Display destinations name
1150         cnt += snprintf(tmp+cnt, bufflen-cnt, "=[%02d]=> %s", i, getColName(i).data());
1151         printMessage("%s\n", tmp);
1152     }
1153
1154 }
1155
1156 int
1157 EAP::Mixer::canWrite( const int row, const int col)
1158 {
1159     if(m_eap.m_mixer_readonly) {
1160         return false;
1161     }
1162     return (row >= 0 && row < m_eap.m_mixer_nb_tx && col >= 0 && col < m_eap.m_mixer_nb_rx);
1163 }
1164
1165 double
1166 EAP::Mixer::setValue( const int row, const int col, const double val)
1167 {
1168     if(m_eap.m_mixer_readonly) {
1169         debugWarning("Mixer is read-only\n");
1170         return false;
1171     }
1172     int nb_inputs = m_eap.m_mixer_nb_tx;
1173     int addr = ((nb_inputs * col) + row) * 4;
1174     quadlet_t tmp = (quadlet_t) val;
1175     if(!m_eap.writeRegBlock(eRT_Mixer, 4+addr, &tmp, 4)) {
1176         debugError("Failed to write coefficient\n");
1177         return 0;
1178     }
1179     return (double)(tmp);
1180 }
1181
1182 double
1183 EAP::Mixer::getValue( const int row, const int col)
1184 {
1185     int nb_inputs = m_eap.m_mixer_nb_tx;
1186     int addr = ((nb_inputs * col) + row) * 4;
1187     quadlet_t tmp;
1188     if(!m_eap.readRegBlock(eRT_Mixer, 4+addr, &tmp, 4)) {
1189         debugError("Failed to read coefficient\n");
1190         return 0;
1191     }
1192     return (double)(tmp);
1193 }
1194
1195 int
1196 EAP::Mixer::getRowCount()
1197 {
1198     return m_eap.m_mixer_nb_tx;
1199 }
1200
1201 int
1202 EAP::Mixer::getColCount()
1203 {
1204     return m_eap.m_mixer_nb_rx;
1205 }
1206
1207 // full map updates are unsupported
1208 bool
1209 EAP::Mixer::getCoefficientMap(int &) {
1210     return false;
1211 }
1212
1213 bool
1214 EAP::Mixer::storeCoefficientMap(int &) {
1215     if(m_eap.m_mixer_readonly) {
1216         debugWarning("Mixer is read-only\n");
1217         return false;
1218     }
1219     return false;
1220 }
1221
1222 // Names
1223 std::string
1224 EAP::Mixer::getRowName(const int row) {
1225     std::string mixer_src;
1226     if (row < 0 || row > m_eap.m_mixer_nb_tx) return "Invalid";
1227     unsigned int dstid = (eRD_Mixer0<<4) + row; // Mixer has consecutive ID's
1228     debugOutput(DEBUG_LEVEL_VERBOSE, "EAP::Mixer::getRowName( %d ): ID's %d\n", row, dstid);
1229     if (m_eap.m_router){
1230       std::string mixer_dst = m_eap.m_router->getDestinationName(dstid);
1231       mixer_src = m_eap.m_router->getSourceForDestination(mixer_dst);
1232       debugOutput(DEBUG_LEVEL_VERBOSE, "EAP::Mixer::found %s as source for %s\n", mixer_src.data(),
1233                   mixer_dst.data());
1234     }
1235     else {
1236       char tmp[32];
1237       snprintf(tmp, 32, "MixIn:%d", row);
1238       mixer_src = tmp;
1239     }
1240
1241     return mixer_src;
1242 }
1243
1244 std::string
1245 EAP::Mixer::getColName(const int col) {
1246     std::string mixer_dst;
1247     stringlist dest_names;
1248    
1249     // invalid col index
1250     if (col < 0 || col > m_eap.m_mixer_nb_rx) {
1251       mixer_dst.append("Invalid");
1252       return mixer_dst;
1253     }
1254    
1255     unsigned int srcid = (eRS_Mixer<<4) + col; // Mixer has consecutive ID's
1256     debugOutput(DEBUG_LEVEL_VERBOSE, "EAP::Mixer::getColName( %d ): ID's %d\n", col, srcid);
1257     if (m_eap.m_router){
1258       std::string mixer_src = m_eap.m_router->getSourceName(srcid);
1259       dest_names = m_eap.m_router->getDestinationsForSource(mixer_src);
1260       if (dest_names.size() > 0) {
1261         stringlist::iterator it_d = dest_names.begin();
1262         stringlist::iterator it_d_end_m1 = dest_names.end(); --it_d_end_m1;
1263         while (it_d != it_d_end_m1) {
1264           mixer_dst.append((*it_d).c_str()); mixer_dst.append("; ");
1265             it_d++;
1266         }
1267       }
1268     } else {
1269       char tmp[32];
1270       snprintf(tmp, 32, "MixOut:%d", col);
1271       mixer_dst.append(tmp);
1272     }
1273
1274     return mixer_dst;
1275 }
1276
1277 //
1278 // ----------- Router -------------
1279 //
1280
1281 EAP::Router::Router(EAP &p)
1282 : Control::CrossbarRouter(&p.m_device, "Router")
1283 , m_eap(p)
1284 , m_peak( *(new PeakSpace(p)) )
1285 , m_debugModule(p.m_debugModule)
1286 {
1287 }
1288
1289 EAP::Router::~Router()
1290 {
1291     delete &m_peak;
1292 }
1293
1294 void
1295 EAP::Router::update()
1296 {
1297     // Clear and
1298     //   define new sources and destinations for the router
1299     m_sources.clear();
1300     m_eap.setupSources();
1301     m_destinations.clear();
1302     m_eap.setupDestinations();
1303     return;
1304 }
1305
1306 void
1307 EAP::Router::addSource(const std::string& basename, enum eRouteSource srcid,
1308                        unsigned int base, unsigned int cnt, unsigned int offset)
1309 {
1310     std::string name = basename + ":";
1311     char tmp[4];
1312     for (unsigned int i=0; i<cnt; i++) {
1313         snprintf(tmp, 4, "%02d", offset+i);
1314         m_sources[name+tmp] = (srcid<<4) + base+i;
1315     }
1316 }
1317
1318 void
1319 EAP::Router::addDestination(const std::string& basename, enum eRouteDestination dstid,
1320                             unsigned int base, unsigned int cnt, unsigned int offset)
1321 {
1322     std::string name = basename + ":";
1323     char tmp[4];
1324     for (unsigned int i=0; i<cnt; i++) {
1325         snprintf(tmp, 4, "%02d", offset+i);
1326         m_destinations[name+tmp] = (dstid<<4) + base+i;
1327     }
1328 }
1329
1330 std::string
1331 EAP::Router::getSourceName(const int srcid)
1332 {
1333     for (std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it) {
1334         if (it->second == srcid) {
1335             return it->first;
1336         }
1337     }
1338     return "";
1339 }
1340
1341 std::string
1342 EAP::Router::getDestinationName(const int dstid)
1343 {
1344     for (std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it) {
1345         if (it->second == dstid) {
1346             return it->first;
1347         }
1348     }
1349     return "";
1350 }
1351
1352 int
1353 EAP::Router::getSourceIndex(std::string name)
1354 {
1355     if (m_sources.count(name) < 1)
1356         return -1;
1357     return m_sources[name];
1358 }
1359
1360 int
1361 EAP::Router::getDestinationIndex(std::string name)
1362 {
1363     if (m_destinations.count(name) < 1)
1364         return -1;
1365     return m_destinations[name];
1366 }
1367
1368 stringlist
1369 EAP::Router::getSourceNames()
1370 {
1371     stringlist n;
1372
1373     for (std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it)
1374         n.push_back(it->first);
1375     return n;
1376 }
1377
1378 stringlist
1379 EAP::Router::getDestinationNames()
1380 {
1381     stringlist n;
1382     for (std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it)
1383         n.push_back(it->first);
1384     return n;
1385 }
1386
1387 stringlist
1388 EAP::Router::getDestinationsForSource(const std::string& srcname) {
1389     RouterConfig* rcfg = m_eap.getActiveRouterConfig();
1390     if(rcfg == NULL) {
1391         debugError("Could not request active router configuration\n");
1392         return stringlist();
1393     }
1394     stringlist ret;
1395     std::vector<unsigned char> dests = rcfg->getDestinationsForSource(m_sources[srcname]);
1396     for (unsigned int i=0; i<dests.size(); ++i) {
1397         ret.push_back(getDestinationName(dests[i]));
1398     }
1399     return ret;
1400 }
1401 std::string
1402 EAP::Router::getSourceForDestination(const std::string& dstname) {
1403     RouterConfig* rcfg = m_eap.getActiveRouterConfig();
1404     if(rcfg == NULL) {
1405         debugError("Could not request active router configuration\n");
1406         return "";
1407     }
1408     int source = rcfg->getSourceForDestination(m_destinations[dstname]);
1409     return getSourceName(source);
1410 }
1411
1412
1413 bool
1414 EAP::Router::canConnect(const int source, const int dest)
1415 {
1416     debugWarning("TODO: Implement canConnect(0x%02x, 0x%02x)\n", source, dest);
1417
1418     // we can connect anything
1419     // FIXME: can we?
1420     return true;
1421 }
1422
1423 bool
1424 EAP::Router::setConnectionState(const int source, const int dest, const bool enable)
1425 {
1426     debugOutput(DEBUG_LEVEL_VERBOSE,"Router::setConnectionState(0x%02x -> 0x%02x ? %i)\n", source, dest, enable);
1427     // get the routing configuration
1428     RouterConfig *rcfg = m_eap.getActiveRouterConfig();
1429     if(rcfg == NULL) {
1430         debugError("Could not request active router configuration\n");
1431         return false;
1432     }
1433
1434     bool ret = false;
1435     if (enable) {
1436         ret = rcfg->setupRoute(source, dest);
1437     } else {
1438         ret = rcfg->removeRoute(source, dest);
1439     }
1440     m_eap.updateCurrentRouterConfig(*rcfg);
1441     return ret;
1442 }
1443
1444 bool
1445 EAP::Router::getConnectionState(const int source, const int dest)
1446 {
1447     // get the routing configuration
1448     RouterConfig *rcfg = m_eap.getActiveRouterConfig();
1449     if(rcfg == NULL) {
1450         debugError("Could not request active router configuration\n");
1451         return false;
1452     }
1453     if (rcfg->getSourceForDestination(dest) == source) {
1454         return true;
1455     }
1456     return false;
1457 }
1458
1459 bool
1460 EAP::Router::canConnect(const std::string& src, const std::string& dst)
1461 {
1462     int srcidx = getSourceIndex(src);
1463     int dstidx = getDestinationIndex(dst);
1464     return canConnect(srcidx, dstidx);
1465 }
1466
1467 bool
1468 EAP::Router::setConnectionState(const std::string& src, const std::string& dst, const bool enable)
1469 {
1470     int srcidx = getSourceIndex(src);
1471     int dstidx = getDestinationIndex(dst);
1472     return setConnectionState(srcidx, dstidx, enable);
1473 }
1474
1475 bool
1476 EAP::Router::getConnectionState(const std::string& src, const std::string& dst)
1477 {
1478     int srcidx = getSourceIndex(src);
1479     int dstidx = getDestinationIndex(dst);
1480     return getConnectionState(srcidx, dstidx);
1481 }
1482
1483
1484 bool
1485 EAP::Router::clearAllConnections()
1486 {
1487     // build a new empty routing configuration
1488     RouterConfig newcfg = EAP::RouterConfig(m_eap);
1489
1490     // upload the new router config
1491     if(!m_eap.updateCurrentRouterConfig(newcfg)) {
1492         debugError("Could not update router config\n");
1493         return false;
1494     }
1495     return true;
1496 }
1497
1498 bool
1499 EAP::Router::hasPeakMetering()
1500 {
1501     return m_eap.m_router_exposed;
1502 }
1503
1504 double
1505 EAP::Router::getPeakValue(const std::string& dest)
1506 {
1507     m_peak.read();
1508     unsigned char dst = m_destinations[dest];
1509     return m_peak.getPeak(dst);
1510 }
1511
1512 std::map<std::string, double>
1513 EAP::Router::getPeakValues()
1514 {
1515     m_peak.read();
1516     std::map<std::string, double> ret;
1517     std::map<unsigned char, int> peaks = m_peak.getPeaks();
1518     for (std::map<unsigned char, int>::iterator it=peaks.begin(); it!=peaks.end(); ++it) {
1519         ret[getDestinationName(it->first)] = it->second;
1520     }
1521     return ret;
1522 }
1523
1524 void
1525 EAP::Router::show()
1526 {
1527     // print the peak space as it also contains the routing configuration
1528     printMessage("Router sources:\n");
1529     for ( std::map<std::string, int>::iterator it=m_sources.begin(); it!=m_sources.end(); ++it ) {
1530         printMessage(" 0x%02x : %s\n", (*it).second, (*it).first.c_str());
1531     }
1532     printMessage("Router destinations:\n");
1533     for ( std::map<std::string, int>::iterator it=m_destinations.begin(); it!=m_destinations.end(); ++it ) {
1534         printMessage(" 0x%02x : %s\n", (*it).second, (*it).first.c_str());
1535     }
1536     printMessage("Router connections:\n");
1537     stringlist sources = getSourceNames();
1538     stringlist destinations = getDestinationNames();
1539     for (stringlist::iterator it1=sources.begin(); it1!=sources.end(); ++it1) {
1540         for (stringlist::iterator it2=destinations.begin(); it2!=destinations.end(); ++it2) {
1541             if (getConnectionState(*it1, *it2)) {
1542                 printMessage(" %s -> %s\n", it1->c_str(), it2->c_str());
1543             }
1544         }
1545     }
1546     printMessage("Active router config:\n");
1547     m_eap.getActiveRouterConfig()->show();
1548     printMessage("Active peak config:\n");
1549     m_peak.read();
1550     m_peak.show();
1551 }
1552
1553 // ----------- routing config -------------
1554 EAP::RouterConfig::RouterConfig(EAP &p)
1555 : m_eap(p)
1556 , m_base(eRT_None), m_offset(0)
1557 , m_debugModule(p.m_debugModule)
1558 {}
1559
1560 EAP::RouterConfig::RouterConfig(EAP &p, enum eRegBase b, unsigned int o)
1561 : m_eap(p)
1562 , m_base(b), m_offset(o)
1563 , m_debugModule(p.m_debugModule)
1564 {}
1565
1566 EAP::RouterConfig::~RouterConfig()
1567 {}
1568
1569 bool
1570 EAP::RouterConfig::read(enum eRegBase base, unsigned offset)
1571 {
1572     // first clear the current route vector
1573     m_routes2.clear();
1574
1575     uint32_t nb_routes;
1576     if(!m_eap.readRegBlock(base, offset, &nb_routes, 4)) {
1577         debugError("Failed to read number of entries\n");
1578         return false;
1579     }
1580     if(nb_routes == 0) {
1581         debugWarning("No routes found. Base 0x%x, offset 0x%x\n", base, offset);
1582     }
1583
1584     // read the route info
1585     uint32_t tmp_entries[nb_routes];
1586     if(!m_eap.readRegBlock(base, offset+4, tmp_entries, nb_routes*4)) {
1587         debugError("Failed to read router config block information\n");
1588         return false;
1589     }
1590
1591     // decode into the routing map
1592     for(unsigned int i=0; i < nb_routes; i++) {
1593         m_routes2[tmp_entries[i]&0xff] = (tmp_entries[i]>>8)&0xff;
1594     }
1595     return true;
1596 }
1597
1598 bool
1599 EAP::RouterConfig::write(enum eRegBase base, unsigned offset)
1600 {
1601     uint32_t nb_routes = m_routes2.size();
1602     if(nb_routes == 0) {
1603         debugWarning("Writing 0 routes? This will deactivate routing and make the device very silent...\n");
1604     }
1605     if (nb_routes > 128) {
1606         debugError("More then 128 are not possible, only the first 128 routes will get saved!\n");
1607         nb_routes = 128;
1608     }
1609     uint32_t tmp_entries[nb_routes];
1610
1611     // encode from the routing vector
1612     int i=0;
1613     for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) {
1614         tmp_entries[i] = ((it->second<<8) + it->first)&0xffff;
1615         ++i;
1616     }
1617
1618     uint32_t zeros[129];
1619     for (int i=0; i<129; ++i) zeros[i] = 0;
1620     if(!m_eap.writeRegBlock(base, offset, zeros, 129*4)) {
1621         debugError("Failed to write zeros to router config block\n");
1622         return false;
1623     }
1624
1625     // write the result to the device
1626     if(!m_eap.writeRegBlock(base, offset+4, tmp_entries, nb_routes*4)) {
1627         debugError("Failed to write router config block information\n");
1628         return false;
1629     }
1630     if(!m_eap.writeRegBlock(base, offset, &nb_routes, 4)) {
1631         debugError("Failed to write number of entries\n");
1632         return false;
1633     }
1634     return true;
1635 }
1636
1637 bool
1638 EAP::RouterConfig::setupRoute(unsigned char src, unsigned char dest) {
1639     debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::setupRoute( 0x%02x, 0x%02x )\n", src, dest);
1640     m_routes2[dest] = src;
1641     return true;
1642 }
1643
1644 bool
1645 EAP::RouterConfig::removeRoute(unsigned char src, unsigned char dest) {
1646     debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x, 0x%02x )\n", src, dest);
1647     if (m_routes2.count(dest) > 0) {
1648         if (src != m_routes2[dest]) {
1649             return false;
1650         }
1651         return removeRoute(dest);
1652     }
1653     return true;
1654 }
1655
1656 bool
1657 EAP::RouterConfig::removeRoute(unsigned char dest) {
1658     debugOutput(DEBUG_LEVEL_VERBOSE,"RouterConfig::removeRoute( 0x%02x )\n", dest);
1659     m_routes2.erase(dest);
1660     if (m_routes2.count(dest) < 1) {
1661         return false;
1662     }
1663     return true;
1664 }
1665
1666 unsigned char
1667 EAP::RouterConfig::getSourceForDestination(unsigned char dest) {
1668     if (m_routes2.count(dest) > 0) {
1669         return m_routes2[dest];
1670     }
1671     return -1;
1672 }
1673
1674 std::vector<unsigned char>
1675 EAP::RouterConfig::getDestinationsForSource(unsigned char source) {
1676     std::vector<unsigned char> ret;
1677     for (RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it) {
1678         if (it->second == source) {
1679             ret.push_back(it->first);
1680         }
1681     }
1682     return ret;
1683 }
1684
1685 void
1686 EAP::RouterConfig::show()
1687 {
1688     for ( RouteVectorV2::iterator it=m_routes2.begin(); it!=m_routes2.end(); ++it ) {
1689         printMessage("0x%02x -> 0x%02x\n", it->second, it->first);
1690     }
1691 }
1692
1693 //
1694 // ----------- peak space -------------
1695 //
1696
1697 bool
1698 EAP::PeakSpace::read(enum eRegBase base, unsigned offset)
1699 {
1700     uint32_t nb_routes;
1701     // we have to figure out the number of entries through the currently
1702     // active router config
1703     RouterConfig *rcfg = m_eap.getActiveRouterConfig();
1704     if(rcfg == NULL) {
1705         debugError("Could not get active router config\n");
1706         return false;
1707     }
1708     nb_routes = rcfg->getNbRoutes();
1709
1710     // read the peak/route info
1711     uint32_t tmp_entries[nb_routes];
1712     if(!m_eap.readRegBlock(base, offset, tmp_entries, nb_routes*4)) {
1713         debugError("Failed to read peak block information\n");
1714         return false;
1715     }
1716     // parse the peaks into the map
1717     for (unsigned int i=0; i<nb_routes; ++i) {
1718         unsigned char dest = tmp_entries[i]&0xff;
1719         int peak = (tmp_entries[i]&0xfff0000)>>16;
1720         if (m_peaks.count(dest) == 0 || m_peaks[dest] < peak) {
1721             m_peaks[dest] = peak;
1722         }
1723     }
1724     return true;
1725 }
1726
1727
1728 void
1729 EAP::PeakSpace::show()
1730 {
1731     printMessage("  %zi peaks\n", m_peaks.size());
1732     for (std::map<unsigned char, int>::iterator it=m_peaks.begin(); it!=m_peaks.end(); ++it) {
1733         printMessage("0x%02x : %i\n", it->first, it->second);
1734     }
1735 }
1736
1737 int
1738 EAP::PeakSpace::getPeak(unsigned char dst) {
1739     int ret = m_peaks[dst];
1740     m_peaks.erase(dst);
1741     return ret;
1742 }
1743
1744 std::map<unsigned char, int>
1745 EAP::PeakSpace::getPeaks() {
1746     // Create a new empty map
1747     std::map<unsigned char, int> ret;
1748     // Swap the peak map with the new and empty one
1749     ret.swap(m_peaks);
1750     // Return the now filled map of the peaks :-)
1751     return ret;
1752 }
1753
1754 // ----------- stream config block -------------
1755 EAP::StreamConfig::StreamConfig(EAP &p, enum eRegBase b, unsigned int o)
1756 : m_eap(p)
1757 , m_base(b), m_offset(o)
1758 , m_nb_tx(0), m_nb_rx(0)
1759 , m_tx_configs(NULL), m_rx_configs(NULL)
1760 , m_debugModule(p.m_debugModule)
1761 {
1762
1763 }
1764
1765 EAP::StreamConfig::~StreamConfig()
1766 {
1767     if(m_tx_configs) delete[]m_tx_configs;
1768     if(m_rx_configs) delete[]m_rx_configs;
1769 }
1770
1771 bool
1772 EAP::StreamConfig::read(enum eRegBase base, unsigned offset)
1773 {
1774     if(!m_eap.readRegBlock(base, offset, &m_nb_tx, 4)) {
1775         debugError("Failed to read number of tx entries\n");
1776         return false;
1777     }
1778     if(!m_eap.readRegBlock(base, offset+4, &m_nb_rx, 4)) {
1779         debugError("Failed to read number of rx entries\n");
1780         return false;
1781     }
1782     debugOutput(DEBUG_LEVEL_VERBOSE, " Entries: TX: %u, RX: %u\n", m_nb_tx, m_nb_rx);
1783
1784     if(m_tx_configs) {
1785         delete[]m_tx_configs;
1786         m_tx_configs = NULL;
1787     }
1788     if(m_rx_configs) {
1789         delete[]m_rx_configs;
1790         m_rx_configs = NULL;
1791     }
1792    
1793     offset += 8;
1794     if(m_nb_tx > 0) {
1795         m_tx_configs = new struct ConfigBlock[m_nb_tx];
1796         for(unsigned int i=0; i<m_nb_tx; i++) {
1797             fb_quadlet_t *ptr = reinterpret_cast<fb_quadlet_t *>(&(m_tx_configs[i]));
1798             if(!m_eap.readRegBlock(base, offset, ptr, sizeof(struct ConfigBlock))) {
1799                 debugError("Failed to read tx entry %d\n", i);
1800                 return false;
1801             }
1802             offset += sizeof(struct ConfigBlock);
1803         }
1804     }
1805
1806     if(m_nb_rx > 0) {
1807         m_rx_configs = new struct ConfigBlock[m_nb_rx];
1808         for(unsigned int i=0; i<m_nb_rx; i++) {
1809             fb_quadlet_t *ptr = reinterpret_cast<fb_quadlet_t *>(&(m_rx_configs[i]));
1810             if(!m_eap.readRegBlock(base, offset, ptr, sizeof(struct ConfigBlock))) {
1811                 debugError("Failed to read rx entry %d\n", i);
1812                 return false;
1813             }
1814             offset += sizeof(struct ConfigBlock);
1815         }
1816     }
1817     return true;
1818 }
1819
1820 bool
1821 EAP::StreamConfig::write(enum eRegBase base, unsigned offset)
1822 {
1823     if(!m_eap.writeRegBlock(base, offset, &m_nb_tx, 4)) {
1824         debugError("Failed to write number of tx entries\n");
1825         return false;
1826     }
1827     if(!m_eap.writeRegBlock(base, offset+4, &m_nb_rx, 4)) {
1828         debugError("Failed to write number of rx entries\n");
1829         return false;
1830     }
1831
1832     offset += 8;
1833     for(unsigned int i=0; i<m_nb_tx; i++) {
1834         fb_quadlet_t *ptr = reinterpret_cast<fb_quadlet_t *>(&(m_tx_configs[i]));
1835         if(!m_eap.writeRegBlock(base, offset, ptr, sizeof(struct ConfigBlock))) {
1836             debugError("Failed to write tx entry %d\n", i);
1837             return false;
1838         }
1839         offset += sizeof(struct ConfigBlock);
1840     }
1841
1842     for(unsigned int i=0; i<m_nb_rx; i++) {
1843         fb_quadlet_t *ptr = reinterpret_cast<fb_quadlet_t *>(&(m_rx_configs[i]));
1844         if(!m_eap.writeRegBlock(base, offset, ptr, sizeof(struct ConfigBlock))) {
1845             debugError("Failed to write rx entry %d\n", i);
1846             return false;
1847         }
1848         offset += sizeof(struct ConfigBlock);
1849     }
1850     return true;
1851 }
1852
1853 stringlist
1854 EAP::StreamConfig::getNamesForBlock(struct ConfigBlock &b)
1855 {
1856     stringlist names;
1857     char namestring[DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_BYTES+1];
1858
1859     memcpy(namestring, b.names, DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_BYTES);
1860
1861     // Strings from the device are always little-endian,
1862     // so byteswap for big-endian machines
1863     #if __BYTE_ORDER == __BIG_ENDIAN
1864     byteSwapBlock((quadlet_t *)namestring, DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_QUADS);
1865     #endif
1866
1867     namestring[DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_BYTES]='\0';
1868     return m_eap.m_device.splitNameString(std::string(namestring));
1869 }
1870
1871 stringlist
1872 EAP::StreamConfig::getTxNamesString(unsigned int i)
1873 {
1874     return getNamesForBlock(m_tx_configs[i]);
1875 }
1876
1877 stringlist
1878 EAP::StreamConfig::getRxNamesString(unsigned int i)
1879 {
1880     return getNamesForBlock(m_rx_configs[i]);
1881 }
1882
1883 void
1884 EAP::StreamConfig::showConfigBlock(struct ConfigBlock &b)
1885 {
1886     printMessage(" Channel count : %u audio, %u midi\n", b.nb_audio, b.nb_midi);
1887     printMessage(" AC3 Map       : 0x%08X\n", b.ac3_map);
1888     stringlist channel_names  = getNamesForBlock(b);
1889     printMessage("  Channel names :\n");
1890     for ( stringlist::iterator it = channel_names.begin();
1891         it != channel_names.end();
1892         ++it )
1893     {
1894         printMessage("     %s\n", (*it).c_str());
1895     }
1896 }
1897
1898 void
1899 EAP::StreamConfig::show()
1900 {
1901     for(unsigned int i=0; i<m_nb_tx; i++) {
1902         printMessage("TX Config block %d\n", i);
1903         showConfigBlock(m_tx_configs[i]);
1904     }
1905     for(unsigned int i=0; i<m_nb_rx; i++) {
1906         printMessage("RX Config block %d\n", i);
1907         showConfigBlock(m_rx_configs[i]);
1908     }
1909 }
1910
1911 } // namespace Dice
1912
1913
1914 // vim: et
Note: See TracBrowser for help on using the browser.