- Timestamp:
- 12/28/09 15:07:32 (13 years ago)
- Files:
-
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (6 diffs)
- trunk/libffado/src/dice/dice_avdevice.h (modified) (5 diffs)
- trunk/libffado/src/dice/dice_eap.cpp (modified) (102 diffs)
- trunk/libffado/src/dice/dice_eap.h (modified) (2 diffs)
- trunk/libffado/src/dice/focusrite/focusrite_eap.cpp (modified) (1 diff)
- trunk/libffado/src/dice/focusrite/focusrite_eap.h (modified) (2 diffs)
- trunk/libffado/src/dice/focusrite/saffire_pro24.cpp (modified) (3 diffs)
- trunk/libffado/src/dice/focusrite/saffire_pro24.h (modified) (1 diff)
- trunk/libffado/src/dice/focusrite/saffire_pro40.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/dice/dice_avdevice.cpp
r1763 r1766 162 162 } 163 163 164 bool supports_eap = Device::EAP::supportsEAP(*this);164 bool supports_eap = EAP::supportsEAP(*this); 165 165 if (supports_eap) { // FIXME: move to buildMixer() ?? 166 166 m_eap = createEAP(); … … 184 184 } 185 185 186 Device::EAP*186 EAP* 187 187 Device::createEAP() { 188 return new Device::EAP(*this);188 return new EAP(*this); 189 189 } 190 190 … … 1505 1505 } 1506 1506 1507 Device::diceNameVector1507 diceNameVector 1508 1508 Device::getTxNameString(unsigned int i) { 1509 1509 diceNameVector names; … … 1525 1525 } 1526 1526 1527 Device::diceNameVector1527 diceNameVector 1528 1528 Device::getRxNameString(unsigned int i) { 1529 1529 diceNameVector names; … … 1545 1545 } 1546 1546 1547 Device::diceNameVector1547 diceNameVector 1548 1548 Device::getClockSourceNameString() { 1549 1549 diceNameVector names; … … 1603 1603 } 1604 1604 1605 Device::diceNameVector1605 diceNameVector 1606 1606 Device::splitNameString(std::string in) { 1607 1607 diceNameVector names; trunk/libffado/src/dice/dice_avdevice.h
r1742 r1766 40 40 #include "libcontrol/CrossbarRouter.h" 41 41 42 #include "dice_eap.h"43 44 42 #include <string> 45 43 #include <vector> … … 54 52 namespace Dice { 55 53 56 class Notifier; 54 class EAP; 55 56 typedef std::vector< std::string > diceNameVector; 57 typedef std::vector< std::string >::iterator diceNameVectorIterator; 58 57 59 58 60 class Device : public FFADODevice { 59 61 // private: 60 typedef std::vector< std::string > diceNameVector; 61 typedef std::vector< std::string >::iterator diceNameVectorIterator; 62 63 public: 64 class Notifier; 65 class EAP; 66 67 /** 68 * this class represents the EAP interface 69 * available on some devices 70 */ 71 class EAP : public Control::Container 72 { 73 public: 74 enum eWaitReturn { 75 eWR_Error, 76 eWR_Timeout, 77 eWR_Busy, 78 eWR_Done, 79 }; 80 enum eRegBase { 81 eRT_Base, 82 eRT_Capability, 83 eRT_Command, 84 eRT_Mixer, 85 eRT_Peak, 86 eRT_NewRouting, 87 eRT_NewStreamCfg, 88 eRT_CurrentCfg, 89 eRT_Standalone, 90 eRT_Application, 91 eRT_None, 92 }; 93 enum eRouteSource { 94 eRS_AES = 0, 95 eRS_ADAT = 1, 96 eRS_Mixer = 2, 97 eRS_InS0 = 4, 98 eRS_InS1 = 5, 99 eRS_ARM = 10, 100 eRS_ARX0 = 11, 101 eRS_ARX1 = 12, 102 eRS_Muted = 15, 103 eRS_Invalid = 16, 104 }; 105 enum eRouteDestination { 106 eRD_AES = 0, 107 eRD_ADAT = 1, 108 eRD_Mixer0 = 2, 109 eRD_Mixer1 = 3, 110 eRD_InS0 = 4, 111 eRD_InS1 = 5, 112 eRD_ARM = 10, 113 eRD_ATX0 = 11, 114 eRD_ATX1 = 12, 115 eRD_Muted = 15, 116 eRD_Invalid = 16, 117 }; 118 119 public: 120 121 // ---------- 122 class RouterConfig { 123 public: 124 struct Route 125 { 126 enum eRouteSource src; 127 int srcChannel; 128 enum eRouteDestination dst; 129 int dstChannel; 130 int peak; 131 }; 132 typedef std::vector<RouterConfig::Route> RouteVector; 133 typedef std::vector<RouterConfig::Route>::iterator RouteVectorIterator; 134 RouterConfig(EAP &); 135 RouterConfig(EAP &, enum eRegBase, unsigned int offset); 136 virtual ~RouterConfig(); 137 138 virtual bool read() {return read(m_base, m_offset);}; 139 virtual bool write() {return write(m_base, m_offset);}; 140 virtual bool read(enum eRegBase b, unsigned offset); 141 virtual bool write(enum eRegBase b, unsigned offset); 142 virtual void show(); 143 144 145 bool insertRoute(struct Route r) 146 {return insertRoute(r, m_routes.size());}; 147 bool insertRoute(struct Route r, unsigned int index); 148 bool replaceRoute(unsigned int old_index, struct Route new_route); 149 bool replaceRoute(struct Route old_route, struct Route new_route); 150 bool removeRoute(struct Route r); 151 bool removeRoute(unsigned int index); 152 int getRouteIndex(struct Route r); 153 struct Route getRoute(unsigned int index); 154 155 unsigned int getNbRoutes() {return m_routes.size();}; 156 157 struct Route getRouteForDestination(enum eRouteDestination dst, int channel); 158 RouteVector getRoutesForSource(enum eRouteSource src, int channel); 159 160 struct Route decodeRoute(uint32_t val); 161 uint32_t encodeRoute(struct Route r); 162 public: 163 static enum eRouteDestination intToRouteDestination(int); 164 static enum eRouteSource intToRouteSource(int); 165 protected: 166 EAP &m_eap; 167 enum eRegBase m_base; 168 unsigned int m_offset; 169 RouteVector m_routes; 170 protected: 171 DECLARE_DEBUG_MODULE_REFERENCE; 172 }; 173 174 // ---------- 175 // the peak space is a special version of a router config 176 class PeakSpace : public RouterConfig { 177 public: 178 PeakSpace(EAP &p) : RouterConfig(p, eRT_Peak, 0) {}; 179 virtual ~PeakSpace() {}; 180 181 virtual bool read() {return read(m_base, m_offset);}; 182 virtual bool write() {return write(m_base, m_offset);}; 183 virtual bool read(enum eRegBase b, unsigned offset); 184 virtual bool write(enum eRegBase b, unsigned offset); 185 virtual void show(); 186 }; 187 188 // ---------- 189 class StreamConfig { 190 public: 191 struct ConfigBlock { // FIXME: somewhere in the DICE avdevice this is present too 192 uint32_t nb_audio; 193 uint32_t nb_midi; 194 uint32_t names[DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_QUADS]; 195 uint32_t ac3_map; 196 }; 197 void showConfigBlock(struct ConfigBlock &); 198 diceNameVector getNamesForBlock(struct ConfigBlock &b); 199 public: 200 StreamConfig(EAP &, enum eRegBase, unsigned int offset); 201 ~StreamConfig(); 202 203 bool read() {return read(m_base, m_offset);}; 204 bool write() {return write(m_base, m_offset);}; 205 bool read(enum eRegBase b, unsigned offset); 206 bool write(enum eRegBase b, unsigned offset); 207 208 void show(); 209 210 private: 211 EAP &m_eap; 212 enum eRegBase m_base; 213 unsigned int m_offset; 214 215 uint32_t m_nb_tx; 216 uint32_t m_nb_rx; 217 218 struct ConfigBlock *m_tx_configs; 219 struct ConfigBlock *m_rx_configs; 220 221 DECLARE_DEBUG_MODULE_REFERENCE; 222 }; 223 224 public: // mixer control subclass 225 class Mixer : public Control::MatrixMixer { 226 public: 227 Mixer(EAP &); 228 ~Mixer(); 229 230 bool init(); 231 void show(); 232 233 void updateNameCache(); 234 /** 235 * load the coefficients from the device into the local cache 236 * @return 237 */ 238 bool loadCoefficients(); 239 /** 240 * Stores the coefficients from the cache to the device 241 * @return 242 */ 243 bool storeCoefficients(); 244 245 virtual int getRowCount( ); 246 virtual int getColCount( ); 247 248 virtual int canWrite( const int, const int ); 249 virtual double setValue( const int, const int, const double ); 250 virtual double getValue( const int, const int ); 251 252 bool hasNames() const { return false; } 253 254 // TODO: implement connections. 255 bool canConnect() const { return false; } 256 257 // full map updates are unsupported 258 virtual bool getCoefficientMap(int &); 259 virtual bool storeCoefficientMap(int &); 260 261 private: 262 EAP & m_eap; 263 fb_quadlet_t *m_coeff; 264 265 std::map<int, RouterConfig::Route> m_input_route_map; 266 std::map<int, RouterConfig::RouteVector> m_output_route_map; 267 268 DECLARE_DEBUG_MODULE_REFERENCE; 269 }; 270 271 // ---------- 272 class Router : public Control::CrossbarRouter { 273 private: 274 struct Source { 275 std::string name; 276 enum eRouteSource src; 277 int srcChannel; 278 }; 279 typedef std::vector<Source> SourceVector; 280 typedef std::vector<Source>::iterator SourceVectorIterator; 281 282 struct Destination { 283 std::string name; 284 enum eRouteDestination dst; 285 int dstChannel; 286 }; 287 typedef std::vector<Destination> DestinationVector; 288 typedef std::vector<Destination>::iterator DestinationVectorIterator; 289 290 public: 291 Router(EAP &); 292 ~Router(); 293 294 void show(); 295 296 // to be subclassed by the implementing 297 // devices 298 virtual void setupSources(); 299 virtual void setupDestinations(); 300 301 void setupDestinationsAddDestination(const char *name, enum eRouteDestination dstid, 302 unsigned int base, unsigned int cnt); 303 void setupSourcesAddSource(const char *name, enum eRouteSource srcid, 304 unsigned int base, unsigned int cnt); 305 306 int getDestinationIndex(enum eRouteDestination dstid, int channel); 307 int getSourceIndex(enum eRouteSource srcid, int channel); 308 309 // per-coefficient access 310 virtual std::string getSourceName(const int); 311 virtual std::string getDestinationName(const int); 312 virtual int getSourceIndex(std::string); 313 virtual int getDestinationIndex(std::string); 314 virtual NameVector getSourceNames(); 315 virtual NameVector getDestinationNames(); 316 317 virtual Control::CrossbarRouter::Groups getSources(); 318 virtual Control::CrossbarRouter::Groups getDestinations(); 319 320 virtual IntVector getDestinationsForSource(const int); 321 virtual int getSourceForDestination(const int); 322 323 virtual bool canConnect( const int source, const int dest); 324 virtual bool setConnectionState( const int source, const int dest, const bool enable); 325 virtual bool getConnectionState( const int source, const int dest ); 326 327 virtual bool canConnect(std::string, std::string); 328 virtual bool setConnectionState(std::string, std::string, const bool enable); 329 virtual bool getConnectionState(std::string, std::string); 330 331 virtual bool clearAllConnections(); 332 333 virtual int getNbSources(); 334 virtual int getNbDestinations(); 335 336 // functions to access the entire routing map at once 337 // idea is that the row/col nodes that are 1 get a routing entry 338 virtual bool getConnectionMap(int *); 339 virtual bool setConnectionMap(int *); 340 341 // peak metering support 342 virtual bool hasPeakMetering(); 343 virtual bool getPeakValues(double &) {return false;}; 344 virtual double getPeakValue(const int source, const int dest); 345 virtual Control::CrossbarRouter::PeakValues getPeakValues(); 346 347 private: 348 EAP &m_eap; 349 // these contain the sources and destinations available for this 350 // router 351 SourceVector m_sources; 352 DestinationVector m_destinations; 353 354 PeakSpace &m_peak; 355 356 DECLARE_DEBUG_MODULE_REFERENCE; 357 }; 358 359 public: 360 EAP(Device &); 361 virtual ~EAP(); 362 363 static bool supportsEAP(Device &); 364 bool init(); 365 366 void show(); 367 void showApplication(); 368 enum eWaitReturn operationBusy(); 369 enum eWaitReturn waitForOperationEnd(int max_wait_time_ms = 100); 370 371 bool updateConfigurationCache(); 372 RouterConfig * getActiveRouterConfig(); 373 StreamConfig * getActiveStreamConfig(); 374 375 bool updateRouterConfig(RouterConfig&, bool low, bool mid, bool high); 376 bool updateCurrentRouterConfig(RouterConfig&); 377 bool updateStreamConfig(StreamConfig&, bool low, bool mid, bool high); 378 bool updateStreamConfig(RouterConfig&, StreamConfig&, bool low, bool mid, bool high); 379 380 bool loadFlashConfig(); 381 bool storeFlashConfig(); 382 383 private: 384 bool loadRouterConfig(bool low, bool mid, bool high); 385 bool loadStreamConfig(bool low, bool mid, bool high); 386 bool loadRouterAndStreamConfig(bool low, bool mid, bool high); 387 private: 388 bool m_router_exposed; 389 bool m_router_readonly; 390 bool m_router_flashstored; 391 uint16_t m_router_nb_entries; 392 393 bool m_mixer_exposed; 394 bool m_mixer_readonly; 395 bool m_mixer_flashstored; 396 uint8_t m_mixer_tx_id; 397 uint8_t m_mixer_rx_id; 398 uint8_t m_mixer_nb_tx; 399 uint8_t m_mixer_nb_rx; 400 401 bool m_general_support_dynstream; 402 bool m_general_support_flash; 403 bool m_general_peak_enabled; 404 uint8_t m_general_max_tx; 405 uint8_t m_general_max_rx; 406 bool m_general_stream_cfg_stored; 407 uint16_t m_general_chip; 408 409 bool commandHelper(fb_quadlet_t cmd); 410 411 public: 412 bool readReg(enum eRegBase, unsigned offset, quadlet_t *); 413 bool writeReg(enum eRegBase, unsigned offset, quadlet_t); 414 bool readRegBlock(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 415 bool writeRegBlock(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 416 bool readRegBlockSwapped(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 417 bool writeRegBlockSwapped(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 418 fb_nodeaddr_t offsetGen(enum eRegBase, unsigned, size_t); 419 420 protected: 421 DECLARE_DEBUG_MODULE_REFERENCE; 422 423 private: 424 Device & m_device; 425 Mixer* m_mixer; 426 Router* m_router; 427 RouterConfig m_current_cfg_routing_low; 428 RouterConfig m_current_cfg_routing_mid; 429 RouterConfig m_current_cfg_routing_high; 430 StreamConfig m_current_cfg_stream_low; 431 StreamConfig m_current_cfg_stream_mid; 432 StreamConfig m_current_cfg_stream_high; 433 public: 434 Mixer* getMixer() {return m_mixer;}; 435 Router* getRouter() {return m_router;}; 436 437 private: 438 439 fb_quadlet_t m_capability_offset; 440 fb_quadlet_t m_capability_size; 441 fb_quadlet_t m_cmd_offset; 442 fb_quadlet_t m_cmd_size; 443 fb_quadlet_t m_mixer_offset; 444 fb_quadlet_t m_mixer_size; 445 fb_quadlet_t m_peak_offset; 446 fb_quadlet_t m_peak_size; 447 fb_quadlet_t m_new_routing_offset; 448 fb_quadlet_t m_new_routing_size; 449 fb_quadlet_t m_new_stream_cfg_offset; 450 fb_quadlet_t m_new_stream_cfg_size; 451 fb_quadlet_t m_curr_cfg_offset; 452 fb_quadlet_t m_curr_cfg_size; 453 fb_quadlet_t m_standalone_offset; 454 fb_quadlet_t m_standalone_size; 455 fb_quadlet_t m_app_offset; 456 fb_quadlet_t m_app_size; 457 }; 62 friend class EAP; 458 63 459 64 public: … … 602 207 // private: 603 208 public: 604 // notification605 Notifier *m_notifier;606 607 209 /** 608 210 * this class reacts on the DICE device writing to the … … 621 223 }; 622 224 225 // notification 226 Notifier *m_notifier; 227 623 228 624 229 … … 626 231 627 232 } 233 // vim: et 628 234 #endif trunk/libffado/src/dice/dice_eap.cpp
r1763 r1766 70 70 } 71 71 72 73 Device::EAP::EAP(Device &d) 72 IMPL_DEBUG_MODULE( EAP, EAP, DEBUG_LEVEL_NORMAL ); 73 74 EAP::EAP(Device &d) 74 75 : Control::Container(&d, "EAP") 75 , m_debugModule(d.m_debugModule) // NOTE: has to be initialized before creating the config classes76 // otherwise the reference content used by those is bogus77 76 , m_device(d) 78 77 , m_mixer( NULL ) … … 87 86 } 88 87 89 Device::EAP::~EAP()88 EAP::~EAP() 90 89 { 91 90 // remove all control elements registered to this device (w/o free) … … 107 106 108 107 bool 109 Device::EAP::init() {108 EAP::init() { 110 109 if(!supportsEAP(m_device)) { 111 110 debugError("Device does not support EAP"); … … 210 209 211 210 bool 212 Device::EAP::updateConfigurationCache()211 EAP::updateConfigurationCache() 213 212 { 214 213 if(!m_current_cfg_routing_low.read()) { … … 244 243 * @return 245 244 */ 246 Device::EAP::RouterConfig *247 Device::EAP::getActiveRouterConfig()245 EAP::RouterConfig * 246 EAP::getActiveRouterConfig() 248 247 { 249 248 switch(m_device.getCurrentConfig()) { 250 case eDC_Low: return &m_current_cfg_routing_low;251 case eDC_Mid: return &m_current_cfg_routing_mid;252 case eDC_High: return &m_current_cfg_routing_high;249 case Device::eDC_Low: return &m_current_cfg_routing_low; 250 case Device::eDC_Mid: return &m_current_cfg_routing_mid; 251 case Device::eDC_High: return &m_current_cfg_routing_high; 253 252 default: 254 253 debugError("Unsupported configuration mode\n"); … … 261 260 * @return 262 261 */ 263 Device::EAP::StreamConfig *264 Device::EAP::getActiveStreamConfig()262 EAP::StreamConfig * 263 EAP::getActiveStreamConfig() 265 264 { 266 265 switch(m_device.getCurrentConfig()) { 267 case eDC_Low: return &m_current_cfg_stream_low;268 case eDC_Mid: return &m_current_cfg_stream_mid;269 case eDC_High: return &m_current_cfg_stream_high;266 case Device::eDC_Low: return &m_current_cfg_stream_low; 267 case Device::eDC_Mid: return &m_current_cfg_stream_mid; 268 case Device::eDC_High: return &m_current_cfg_stream_high; 270 269 default: 271 270 debugError("Unsupported configuration mode\n"); … … 283 282 */ 284 283 bool 285 Device::EAP::updateRouterConfig(RouterConfig& rcfg, bool low, bool mid, bool high) {284 EAP::updateRouterConfig(RouterConfig& rcfg, bool low, bool mid, bool high) { 286 285 // write the router config to the appropriate memory space on the device 287 286 if(!rcfg.write(eRT_NewRouting, 0)) { … … 305 304 */ 306 305 bool 307 Device::EAP::updateCurrentRouterConfig(RouterConfig& rcfg) {306 EAP::updateCurrentRouterConfig(RouterConfig& rcfg) { 308 307 switch(m_device.getCurrentConfig()) { 309 case eDC_Low: return updateRouterConfig(rcfg, true, false, false);310 case eDC_Mid: return updateRouterConfig(rcfg, false, true, false);311 case eDC_High: return updateRouterConfig(rcfg, false, false, true);308 case Device::eDC_Low: return updateRouterConfig(rcfg, true, false, false); 309 case Device::eDC_Mid: return updateRouterConfig(rcfg, false, true, false); 310 case Device::eDC_High: return updateRouterConfig(rcfg, false, false, true); 312 311 default: 313 312 debugError("Unsupported configuration mode\n"); … … 325 324 */ 326 325 bool 327 Device::EAP::updateStreamConfig(StreamConfig& scfg, bool low, bool mid, bool high) {326 EAP::updateStreamConfig(StreamConfig& scfg, bool low, bool mid, bool high) { 328 327 // write the stream config to the appropriate memory space on the device 329 328 if(!scfg.write(eRT_NewStreamCfg, 0)) { … … 350 349 */ 351 350 bool 352 Device::EAP::updateStreamConfig(RouterConfig& rcfg, StreamConfig& scfg, bool low, bool mid, bool high) {351 EAP::updateStreamConfig(RouterConfig& rcfg, StreamConfig& scfg, bool low, bool mid, bool high) { 353 352 // write the router config to the appropriate memory space on the device 354 353 if(!rcfg.write(eRT_NewRouting, 0)) { … … 372 371 373 372 bool 374 Device::EAP::loadFlashConfig() {373 EAP::loadFlashConfig() { 375 374 bool retval = true; 376 375 debugWarning("Untested code\n"); … … 386 385 387 386 bool 388 Device::EAP::storeFlashConfig() {387 EAP::storeFlashConfig() { 389 388 //debugWarning("Untested code\n") // Works. -Arnold; 390 389 fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_ST_FLASH_CFG; … … 395 394 // helpers 396 395 void 397 Device::EAP::show()396 EAP::show() 398 397 { 399 398 printMessage("== DICE EAP ==\n"); … … 472 471 } 473 472 void 474 Device::EAP::showApplication()473 EAP::showApplication() 475 474 { 476 475 printMessage("--- Application space ---\n"); … … 491 490 // EAP load/store operations 492 491 493 enum Device::EAP::eWaitReturn494 Device::EAP::operationBusy() {492 enum EAP::eWaitReturn 493 EAP::operationBusy() { 495 494 fb_quadlet_t tmp; 496 495 if(!readReg(eRT_Command, DICE_EAP_COMMAND_OPCODE, &tmp)) { … … 505 504 } 506 505 507 enum Device::EAP::eWaitReturn508 Device::EAP::waitForOperationEnd(int max_wait_time_ms) {506 enum EAP::eWaitReturn 507 EAP::waitForOperationEnd(int max_wait_time_ms) { 509 508 int max_waits = max_wait_time_ms; 510 509 … … 526 525 527 526 bool 528 Device::EAP::commandHelper(fb_quadlet_t cmd) {527 EAP::commandHelper(fb_quadlet_t cmd) { 529 528 // check whether another command is still running 530 529 if(operationBusy() == eWR_Busy) { … … 568 567 569 568 bool 570 Device::EAP::loadRouterConfig(bool low, bool mid, bool high) {569 EAP::loadRouterConfig(bool low, bool mid, bool high) { 571 570 fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_ROUTER; 572 571 if(low) cmd |= DICE_EAP_CMD_OPCODE_FLAG_LD_LOW; … … 578 577 579 578 bool 580 Device::EAP::loadStreamConfig(bool low, bool mid, bool high) {579 EAP::loadStreamConfig(bool low, bool mid, bool high) { 581 580 debugWarning("Untested code\n"); 582 581 fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_STRM_CFG; … … 589 588 590 589 bool 591 Device::EAP::loadRouterAndStreamConfig(bool low, bool mid, bool high) {590 EAP::loadRouterAndStreamConfig(bool low, bool mid, bool high) { 592 591 debugWarning("Untested code\n"); 593 592 fb_quadlet_t cmd = DICE_EAP_CMD_OPCODE_LD_RTR_STRM_CFG; … … 601 600 // internal I/O operations 602 601 bool 603 Device::EAP::readReg(enum eRegBase base, unsigned offset, fb_quadlet_t *result) {602 EAP::readReg(enum eRegBase base, unsigned offset, fb_quadlet_t *result) { 604 603 fb_nodeaddr_t addr = offsetGen(base, offset, 4); 605 604 return m_device.readReg(addr, result); … … 607 606 608 607 bool 609 Device::EAP::writeReg(enum eRegBase base, unsigned offset, fb_quadlet_t data) {608 EAP::writeReg(enum eRegBase base, unsigned offset, fb_quadlet_t data) { 610 609 fb_nodeaddr_t addr = offsetGen(base, offset, 4); 611 610 return m_device.writeReg(addr, data); … … 613 612 614 613 bool 615 Device::EAP::readRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) {614 EAP::readRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) { 616 615 fb_nodeaddr_t addr = offsetGen(base, offset, length); 617 616 return m_device.readRegBlock(addr, data, length); … … 619 618 620 619 bool 621 Device::EAP::writeRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) {620 EAP::writeRegBlock(enum eRegBase base, unsigned offset, fb_quadlet_t *data, size_t length) { 622 621 fb_nodeaddr_t addr = offsetGen(base, offset, length); 623 622 return m_device.writeRegBlock(addr, data, length); … … 625 624 626 625 fb_nodeaddr_t 627 Device::EAP::offsetGen(enum eRegBase base, unsigned offset, size_t length) {626 EAP::offsetGen(enum eRegBase base, unsigned offset, size_t length) { 628 627 fb_nodeaddr_t addr; 629 628 fb_nodeaddr_t maxlen; … … 688 687 */ 689 688 bool 690 Device::EAP::supportsEAP(Device &d)689 EAP::supportsEAP(Device &d) 691 690 { 692 691 DebugModule &m_debugModule = d.m_debugModule; … … 708 707 709 708 // ----------- Mixer ------------- 710 Device::EAP::Mixer::Mixer(EAP &p)709 EAP::Mixer::Mixer(EAP &p) 711 710 : Control::MatrixMixer(&p.m_device, "MatrixMixer") 712 711 , m_eap(p) … … 716 715 } 717 716 718 Device::EAP::Mixer::~Mixer()717 EAP::Mixer::~Mixer() 719 718 { 720 719 if (m_coeff) { … … 725 724 726 725 bool 727 Device::EAP::Mixer::init()726 EAP::Mixer::init() 728 727 { 729 728 if(!m_eap.m_mixer_exposed) { … … 754 753 755 754 bool 756 Device::EAP::Mixer::loadCoefficients()755 EAP::Mixer::loadCoefficients() 757 756 { 758 757 if(m_coeff == NULL) { … … 770 769 771 770 bool 772 Device::EAP::Mixer::storeCoefficients()771 EAP::Mixer::storeCoefficients() 773 772 { 774 773 if(m_coeff == NULL) { … … 790 789 791 790 void 792 Device::EAP::Mixer::updateNameCache()791 EAP::Mixer::updateNameCache() 793 792 { 794 793 // figure out the number of i/o's … … 873 872 874 873 void 875 Device::EAP::Mixer::show()874 EAP::Mixer::show() 876 875 { 877 876 int nb_inputs = m_eap.m_mixer_nb_tx; … … 927 926 928 927 int 929 Device::EAP::Mixer::canWrite( const int row, const int col)928 EAP::Mixer::canWrite( const int row, const int col) 930 929 { 931 930 if(m_eap.m_mixer_readonly) { … … 936 935 937 936 double 938 Device::EAP::Mixer::setValue( const int row, const int col, const double val)937 EAP::Mixer::setValue( const int row, const int col, const double val) 939 938 { 940 939 if(m_eap.m_mixer_readonly) { … … 953 952 954 953 double 955 Device::EAP::Mixer::getValue( const int row, const int col)954 EAP::Mixer::getValue( const int row, const int col) 956 955 { 957 956 int nb_inputs = m_eap.m_mixer_nb_tx; … … 966 965 967 966 int 968 Device::EAP::Mixer::getRowCount()967 EAP::Mixer::getRowCount() 969 968 { 970 969 return m_eap.m_mixer_nb_tx; … … 972 971 973 972 int 974 Device::EAP::Mixer::getColCount()973 EAP::Mixer::getColCount() 975 974 { 976 975 return m_eap.m_mixer_nb_rx; … … 979 978 // full map updates are unsupported 980 979 bool 981 Device::EAP::Mixer::getCoefficientMap(int &) {980 EAP::Mixer::getCoefficientMap(int &) { 982 981 return false; 983 982 } 984 983 985 984 bool 986 Device::EAP::Mixer::storeCoefficientMap(int &) {985 EAP::Mixer::storeCoefficientMap(int &) { 987 986 if(m_eap.m_mixer_readonly) { 988 987 debugWarning("Mixer is read-only\n"); … … 990 989 } 991 990 return false; 991 } 992 993 // Names 994 std::string 995 EAP::Mixer::getColName(const int col) { 996 //debugOutput(DEBUG_LEVEL_VERBOSE, "EAP::Mixer::getColName( %i )\n"); 997 char tmp[32]; 998 snprintf(tmp, 32, "%s:%d", srcBlockToString(m_input_route_map[col].src), m_input_route_map[col].srcChannel); 999 return tmp; 1000 } 1001 std::string 1002 EAP::Mixer::getRowName(const int row) { 1003 if (m_output_route_map[row].size() == 0) { 1004 return "Not connected"; 1005 } 1006 if (m_output_route_map[row].size() > 1) { 1007 return "Many"; 1008 } 1009 char tmp[32]; 1010 snprintf(tmp, 32, "%s:%d", dstBlockToString(m_output_route_map[row][0].dst), m_output_route_map[row][0].dstChannel); 1011 return tmp; 992 1012 } 993 1013 … … 997 1017 998 1018 999 Device::EAP::Router::Router(EAP &p)1019 EAP::Router::Router(EAP &p) 1000 1020 : Control::CrossbarRouter(&p.m_device, "Router") 1001 1021 , m_eap(p) … … 1007 1027 } 1008 1028 1009 Device::EAP::Router::~Router()1029 EAP::Router::~Router() 1010 1030 { 1011 1031 delete &m_peak; … … 1013 1033 1014 1034 void 1015 Device::EAP::Router::setupSourcesAddSource(const char *basename, enum eRouteSource srcid,1035 EAP::Router::setupSourcesAddSource(const char *basename, enum eRouteSource srcid, 1016 1036 unsigned int base, unsigned int cnt) 1017 1037 { … … 1026 1046 1027 1047 void 1028 Device::EAP::Router::setupDestinationsAddDestination(const char *basename, enum eRouteDestination dstid,1048 EAP::Router::setupDestinationsAddDestination(const char *basename, enum eRouteDestination dstid, 1029 1049 unsigned int base, unsigned int cnt) 1030 1050 { … … 1040 1060 1041 1061 void 1042 Device::EAP::Router::setupSources() {1062 EAP::Router::setupSources() { 1043 1063 // add the routing sources and destinations for a DICE chip 1044 1064 switch(m_eap.m_general_chip) { … … 1085 1105 1086 1106 void 1087 Device::EAP::Router::setupDestinations() {1107 EAP::Router::setupDestinations() { 1088 1108 // add the routing sources and destinations for a DICE chip 1089 1109 switch(m_eap.m_general_chip) { … … 1131 1151 1132 1152 std::string 1133 Device::EAP::Router::getSourceName(const int srcid)1153 EAP::Router::getSourceName(const int srcid) 1134 1154 { 1135 1155 if((unsigned)srcid < m_sources.size()) { … … 1142 1162 1143 1163 std::string 1144 Device::EAP::Router::getDestinationName(const int dstid)1164 EAP::Router::getDestinationName(const int dstid) 1145 1165 { 1146 1166 if((unsigned)dstid < m_destinations.size()) { … … 1153 1173 1154 1174 int 1155 Device::EAP::Router::getSourceIndex(std::string name)1175 EAP::Router::getSourceIndex(std::string name) 1156 1176 { 1157 1177 int i = 0; … … 1167 1187 1168 1188 int 1169 Device::EAP::Router::getDestinationIndex(std::string name)1189 EAP::Router::getDestinationIndex(std::string name) 1170 1190 { 1171 1191 int i = 0; … … 1181 1201 1182 1202 int 1183 Device::EAP::Router::getSourceIndex(enum eRouteSource srcid, int channel)1203 EAP::Router::getSourceIndex(enum eRouteSource srcid, int channel) 1184 1204 { 1185 1205 int i = 0; … … 1195 1215 1196 1216 int 1197 Device::EAP::Router::getDestinationIndex(enum eRouteDestination dstid, int channel)1217 EAP::Router::getDestinationIndex(enum eRouteDestination dstid, int channel) 1198 1218 { 1199 1219 int i = 0; … … 1209 1229 1210 1230 Control::CrossbarRouter::NameVector 1211 Device::EAP::Router::getSourceNames()1231 EAP::Router::getSourceNames() 1212 1232 { 1213 1233 Control::CrossbarRouter::NameVector n; … … 1222 1242 1223 1243 Control::CrossbarRouter::NameVector 1224 Device::EAP::Router::getDestinationNames()1244 EAP::Router::getDestinationNames() 1225 1245 { 1226 1246 Control::CrossbarRouter::NameVector n; … … 1235 1255 1236 1256 Control::CrossbarRouter::Groups 1237 Device::EAP::Router::getSources()1238 { 1239 debugError(" Device::EAP::Router::getSources() is not yet implemented!");1257 EAP::Router::getSources() 1258 { 1259 debugError("EAP::Router::getSources() is not yet implemented!"); 1240 1260 return Control::CrossbarRouter::Groups(); 1241 1261 } 1242 1262 1243 1263 Control::CrossbarRouter::Groups 1244 Device::EAP::Router::getDestinations()1245 { 1246 debugError(" Device::EAP::Router::getDestinations() is not yet implemented!");1264 EAP::Router::getDestinations() 1265 { 1266 debugError("EAP::Router::getDestinations() is not yet implemented!"); 1247 1267 return Control::CrossbarRouter::Groups(); 1248 1268 } 1249 1269 1250 1270 Control::CrossbarRouter::IntVector 1251 Device::EAP::Router::getDestinationsForSource(const int srcid)1271 EAP::Router::getDestinationsForSource(const int srcid) 1252 1272 { 1253 1273 IntVector retval; … … 1291 1311 1292 1312 int 1293 Device::EAP::Router::getSourceForDestination(const int dstid)1313 EAP::Router::getSourceForDestination(const int dstid) 1294 1314 { 1295 1315 if((unsigned)dstid < m_destinations.size()) { … … 1326 1346 1327 1347 int 1328 Device::EAP::Router::getNbSources()1348 EAP::Router::getNbSources() 1329 1349 { 1330 1350 return m_sources.size(); … … 1332 1352 1333 1353 int 1334 Device::EAP::Router::getNbDestinations()1354 EAP::Router::getNbDestinations() 1335 1355 { 1336 1356 return m_destinations.size(); … … 1338 1358 1339 1359 bool 1340 Device::EAP::Router::canConnect(const int source, const int dest)1360 EAP::Router::canConnect(const int source, const int dest) 1341 1361 { 1342 1362 if((unsigned)source >= m_sources.size()) { … … 1358 1378 1359 1379 bool 1360 Device::EAP::Router::setConnectionState(const int source, const int dest, const bool enable)1380 EAP::Router::setConnectionState(const int source, const int dest, const bool enable) 1361 1381 { 1362 1382 if((unsigned)source >= m_sources.size()) { … … 1380 1400 1381 1401 // build a new routing configuration 1382 RouterConfig newcfg = Device::EAP::RouterConfig(*rcfg);1402 RouterConfig newcfg = EAP::RouterConfig(*rcfg); 1383 1403 1384 1404 // construct the routing entry to find … … 1395 1415 if(enable) { 1396 1416 debugOutput(DEBUG_LEVEL_VERBOSE, "connection %d => %d already present\n", source, dest); 1397 return true;1417 //return true; 1398 1418 } else { 1399 1419 // remove the route … … 1412 1432 1413 1433 bool 1414 Device::EAP::Router::getConnectionState(const int source, const int dest)1434 EAP::Router::getConnectionState(const int source, const int dest) 1415 1435 { 1416 1436 if((unsigned)source >= m_sources.size()) { … … 1434 1454 1435 1455 // build a new routing configuration 1436 RouterConfig newcfg = Device::EAP::RouterConfig(*rcfg);1456 RouterConfig newcfg = EAP::RouterConfig(*rcfg); 1437 1457 1438 1458 // construct the routing entry to find … … 1452 1472 1453 1473 bool 1454 Device::EAP::Router::canConnect(std::string src, std::string dst)1474 EAP::Router::canConnect(std::string src, std::string dst) 1455 1475 { 1456 1476 int srcidx = getSourceIndex(src); … … 1460 1480 1461 1481 bool 1462 Device::EAP::Router::setConnectionState(std::string src, std::string dst, const bool enable)1482 EAP::Router::setConnectionState(std::string src, std::string dst, const bool enable) 1463 1483 { 1464 1484 int srcidx = getSourceIndex(src); … … 1468 1488 1469 1489 bool 1470 Device::EAP::Router::getConnectionState(std::string src, std::string dst)1490 EAP::Router::getConnectionState(std::string src, std::string dst) 1471 1491 { 1472 1492 int srcidx = getSourceIndex(src); … … 1482 1502 // allocated by the user 1483 1503 bool 1484 Device::EAP::Router::getConnectionMap(int *map)1504 EAP::Router::getConnectionMap(int *map) 1485 1505 { 1486 1506 unsigned int nb_sources = getNbSources(); … … 1518 1538 1519 1539 bool 1520 Device::EAP::Router::setConnectionMap(int *map)1540 EAP::Router::setConnectionMap(int *map) 1521 1541 { 1522 1542 return false; … … 1524 1544 1525 1545 bool 1526 Device::EAP::Router::clearAllConnections()1546 EAP::Router::clearAllConnections() 1527 1547 { 1528 1548 // build a new empty routing configuration 1529 RouterConfig newcfg = Device::EAP::RouterConfig(m_eap);1549 RouterConfig newcfg = EAP::RouterConfig(m_eap); 1530 1550 1531 1551 // upload the new router config … … 1538 1558 1539 1559 bool 1540 Device::EAP::Router::hasPeakMetering()1560 EAP::Router::hasPeakMetering() 1541 1561 { 1542 1562 return m_eap.m_router_exposed; … … 1544 1564 1545 1565 double 1546 Device::EAP::Router::getPeakValue(const int source, const int dest)1566 EAP::Router::getPeakValue(const int source, const int dest) 1547 1567 { 1548 1568 if((unsigned)source >= m_sources.size()) { … … 1583 1603 1584 1604 Control::CrossbarRouter::PeakValues 1585 Device::EAP::Router::getPeakValues()1605 EAP::Router::getPeakValues() 1586 1606 { 1587 1607 m_peak.read(); … … 1598 1618 1599 1619 void 1600 Device::EAP::Router::show()1620 EAP::Router::show() 1601 1621 { 1602 1622 // print the peak space as it also contains the routing configuration … … 1607 1627 1608 1628 // ----------- routing config ------------- 1609 Device::EAP::RouterConfig::RouterConfig(EAP &p)1629 EAP::RouterConfig::RouterConfig(EAP &p) 1610 1630 : m_eap(p) 1611 1631 , m_base(eRT_None), m_offset(0) … … 1613 1633 {} 1614 1634 1615 Device::EAP::RouterConfig::RouterConfig(EAP &p, enum eRegBase b, unsigned int o)1635 EAP::RouterConfig::RouterConfig(EAP &p, enum eRegBase b, unsigned int o) 1616 1636 : m_eap(p) 1617 1637 , m_base(b), m_offset(o) … … 1619 1639 {} 1620 1640 1621 Device::EAP::RouterConfig::~RouterConfig()1641 EAP::RouterConfig::~RouterConfig() 1622 1642 {} 1623 1643 1624 1644 bool 1625 Device::EAP::RouterConfig::read(enum eRegBase base, unsigned offset)1645 EAP::RouterConfig::read(enum eRegBase base, unsigned offset) 1626 1646 { 1627 1647 // first clear the current route vector … … 1652 1672 1653 1673 bool 1654 Device::EAP::RouterConfig::write(enum eRegBase base, unsigned offset)1674 EAP::RouterConfig::write(enum eRegBase base, unsigned offset) 1655 1675 { 1656 1676 uint32_t nb_routes = m_routes.size(); … … 1683 1703 1684 1704 bool 1685 Device::EAP::RouterConfig::insertRoute(struct Route r, unsigned int index)1705 EAP::RouterConfig::insertRoute(struct Route r, unsigned int index) 1686 1706 { 1687 1707 unsigned int nb_routes = getNbRoutes(); … … 1701 1721 1702 1722 bool 1703 Device::EAP::RouterConfig::replaceRoute(unsigned int old_index, struct Route new_route)1723 EAP::RouterConfig::replaceRoute(unsigned int old_index, struct Route new_route) 1704 1724 { 1705 1725 if(old_index >= getNbRoutes()) { … … 1715 1735 1716 1736 bool 1717 Device::EAP::RouterConfig::replaceRoute(struct Route old_route, struct Route new_route)1737 EAP::RouterConfig::replaceRoute(struct Route old_route, struct Route new_route) 1718 1738 { 1719 1739 int idx = getRouteIndex(old_route); … … 1726 1746 1727 1747 bool 1728 Device::EAP::RouterConfig::removeRoute(struct Route r)1748 EAP::RouterConfig::removeRoute(struct Route r) 1729 1749 { 1730 1750 int idx = getRouteIndex(r); … … 1737 1757 1738 1758 bool 1739 Device::EAP::RouterConfig::removeRoute(unsigned int index)1759 EAP::RouterConfig::removeRoute(unsigned int index) 1740 1760 { 1741 1761 if(index >= getNbRoutes()) { … … 1749 1769 1750 1770 int 1751 Device::EAP::RouterConfig::getRouteIndex(struct Route r)1771 EAP::RouterConfig::getRouteIndex(struct Route r) 1752 1772 { 1753 1773 int i = 0; … … 1763 1783 } 1764 1784 1765 struct Device::EAP::RouterConfig::Route1766 Device::EAP::RouterConfig::getRoute(unsigned int idx)1785 struct EAP::RouterConfig::Route 1786 EAP::RouterConfig::getRoute(unsigned int idx) 1767 1787 { 1768 1788 if( (idx < 0) || (idx >= m_routes.size()) ) { … … 1775 1795 1776 1796 #define CASE_INT_EQUAL_RETURN(_x) case (int)(_x): return _x; 1777 enum Device::EAP::eRouteDestination1778 Device::EAP::RouterConfig::intToRouteDestination(int dst)1797 enum EAP::eRouteDestination 1798 EAP::RouterConfig::intToRouteDestination(int dst) 1779 1799 { 1780 1800 switch(dst) { … … 1793 1813 } 1794 1814 1795 enum Device::EAP::eRouteSource1796 Device::EAP::RouterConfig::intToRouteSource(int src)1815 enum EAP::eRouteSource 1816 EAP::RouterConfig::intToRouteSource(int src) 1797 1817 { 1798 1818 switch(src) { … … 1810 1830 } 1811 1831 1812 struct Device::EAP::RouterConfig::Route1813 Device::EAP::RouterConfig::decodeRoute(uint32_t val) {1832 struct EAP::RouterConfig::Route 1833 EAP::RouterConfig::decodeRoute(uint32_t val) { 1814 1834 int routerval = val & 0xFFFF; 1815 1835 int peak = (val >> 16) & 0x0FFF; … … 1823 1843 1824 1844 uint32_t 1825 Device::EAP::RouterConfig::encodeRoute(struct Route r) {1845 EAP::RouterConfig::encodeRoute(struct Route r) { 1826 1846 if(r.src == eRS_Invalid || r.dst == eRD_Invalid) { 1827 1847 debugWarning("Encoding invalid source/dest (%d/%d)\n", r.src, r.dst); … … 1840 1860 } 1841 1861 1842 struct Device::EAP::RouterConfig::Route1843 Device::EAP::RouterConfig::getRouteForDestination(enum eRouteDestination dst, int channel)1862 struct EAP::RouterConfig::Route 1863 EAP::RouterConfig::getRouteForDestination(enum eRouteDestination dst, int channel) 1844 1864 { 1845 1865 for ( RouteVectorIterator it = m_routes.begin(); … … 1861 1881 } 1862 1882 1863 std::vector<struct Device::EAP::RouterConfig::Route>1864 Device::EAP::RouterConfig::getRoutesForSource(enum eRouteSource src, int channel)1883 std::vector<struct EAP::RouterConfig::Route> 1884 EAP::RouterConfig::getRoutesForSource(enum eRouteSource src, int channel) 1865 1885 { 1866 1886 std::vector<struct Route>routes; … … 1881 1901 1882 1902 void 1883 Device::EAP::RouterConfig::show()1903 EAP::RouterConfig::show() 1884 1904 { 1885 1905 for ( RouteVectorIterator it = m_routes.begin(); … … 1898 1918 1899 1919 bool 1900 Device::EAP::PeakSpace::read(enum eRegBase base, unsigned offset)1920 EAP::PeakSpace::read(enum eRegBase base, unsigned offset) 1901 1921 { 1902 1922 // first clear the current route vector … … 1929 1949 1930 1950 bool 1931 Device::EAP::PeakSpace::write(enum eRegBase base, unsigned offset)1951 EAP::PeakSpace::write(enum eRegBase base, unsigned offset) 1932 1952 { 1933 1953 debugError("Peak space is read-only\n"); … … 1936 1956 1937 1957 void 1938 Device::EAP::PeakSpace::show()1958 EAP::PeakSpace::show() 1939 1959 { 1940 1960 for ( RouteVectorIterator it = m_routes.begin(); … … 1951 1971 1952 1972 // ----------- stream config block ------------- 1953 Device::EAP::StreamConfig::StreamConfig(EAP &p, enum eRegBase b, unsigned int o)1973 EAP::StreamConfig::StreamConfig(EAP &p, enum eRegBase b, unsigned int o) 1954 1974 : m_eap(p) 1955 1975 , m_base(b), m_offset(o) … … 1961 1981 } 1962 1982 1963 Device::EAP::StreamConfig::~StreamConfig()1983 EAP::StreamConfig::~StreamConfig() 1964 1984 { 1965 1985 if(m_tx_configs) delete[]m_tx_configs; … … 1968 1988 1969 1989 bool 1970 Device::EAP::StreamConfig::read(enum eRegBase base, unsigned offset)1990 EAP::StreamConfig::read(enum eRegBase base, unsigned offset) 1971 1991 { 1972 1992 if(!m_eap.readRegBlock(base, offset, &m_nb_tx, 4)) { … … 2017 2037 2018 2038 bool 2019 Device::EAP::StreamConfig::write(enum eRegBase base, unsigned offset)2039 EAP::StreamConfig::write(enum eRegBase base, unsigned offset) 2020 2040 { 2021 2041 if(!m_eap.writeRegBlock(base, offset, &m_nb_tx, 4)) { … … 2049 2069 } 2050 2070 2051 Device::diceNameVector2052 Device::EAP::StreamConfig::getNamesForBlock(struct ConfigBlock &b)2071 diceNameVector 2072 EAP::StreamConfig::getNamesForBlock(struct ConfigBlock &b) 2053 2073 { 2054 2074 diceNameVector names; … … 2068 2088 2069 2089 void 2070 Device::EAP::StreamConfig::showConfigBlock(struct ConfigBlock &b)2090 EAP::StreamConfig::showConfigBlock(struct ConfigBlock &b) 2071 2091 { 2072 2092 debugOutput(DEBUG_LEVEL_VERBOSE, " Channel count : %u audio, %u midi\n", b.nb_audio, b.nb_midi); … … 2083 2103 2084 2104 void 2085 Device::EAP::StreamConfig::show()2105 EAP::StreamConfig::show() 2086 2106 { 2087 2107 for(unsigned int i=0; i<m_nb_tx; i++) { trunk/libffado/src/dice/dice_eap.h
r1630 r1766 21 21 * 22 22 */ 23 #ifndef __DICE_EAP_H 24 #define __DICE_EAP_H 25 26 #include "dice_avdevice.h" 23 27 24 28 #define DICE_EAP_BASE 0x0000000000200000ULL … … 117 121 #define DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_QUADS (64) 118 122 #define DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_BYTES (4*DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_QUADS) 123 124 namespace Dice { 125 126 /** 127 * this class represents the EAP interface 128 * available on some devices 129 */ 130 class EAP : public Control::Container 131 { 132 public: 133 enum eWaitReturn { 134 eWR_Error, 135 eWR_Timeout, 136 eWR_Busy, 137 eWR_Done, 138 }; 139 enum eRegBase { 140 eRT_Base, 141 eRT_Capability, 142 eRT_Command, 143 eRT_Mixer, 144 eRT_Peak, 145 eRT_NewRouting, 146 eRT_NewStreamCfg, 147 eRT_CurrentCfg, 148 eRT_Standalone, 149 eRT_Application, 150 eRT_None, 151 }; 152 enum eRouteSource { 153 eRS_AES = 0, 154 eRS_ADAT = 1, 155 eRS_Mixer = 2, 156 eRS_InS0 = 4, 157 eRS_InS1 = 5, 158 eRS_ARM = 10, 159 eRS_ARX0 = 11, 160 eRS_ARX1 = 12, 161 eRS_Muted = 15, 162 eRS_Invalid = 16, 163 }; 164 enum eRouteDestination { 165 eRD_AES = 0, 166 eRD_ADAT = 1, 167 eRD_Mixer0 = 2, 168 eRD_Mixer1 = 3, 169 eRD_InS0 = 4, 170 eRD_InS1 = 5, 171 eRD_ARM = 10, 172 eRD_ATX0 = 11, 173 eRD_ATX1 = 12, 174 eRD_Muted = 15, 175 eRD_Invalid = 16, 176 }; 177 178 public: 179 180 // ---------- 181 class RouterConfig { 182 public: 183 struct Route 184 { 185 enum eRouteSource src; 186 int srcChannel; 187 enum eRouteDestination dst; 188 int dstChannel; 189 int peak; 190 }; 191 typedef std::vector<RouterConfig::Route> RouteVector; 192 typedef std::vector<RouterConfig::Route>::iterator RouteVectorIterator; 193 RouterConfig(EAP &); 194 RouterConfig(EAP &, enum eRegBase, unsigned int offset); 195 virtual ~RouterConfig(); 196 197 virtual bool read() {return read(m_base, m_offset);}; 198 virtual bool write() {return write(m_base, m_offset);}; 199 virtual bool read(enum eRegBase b, unsigned offset); 200 virtual bool write(enum eRegBase b, unsigned offset); 201 virtual void show(); 202 203 204 bool insertRoute(struct Route r) 205 {return insertRoute(r, m_routes.size());}; 206 bool insertRoute(struct Route r, unsigned int index); 207 bool replaceRoute(unsigned int old_index, struct Route new_route); 208 bool replaceRoute(struct Route old_route, struct Route new_route); 209 bool removeRoute(struct Route r); 210 bool removeRoute(unsigned int index); 211 int getRouteIndex(struct Route r); 212 struct Route getRoute(unsigned int index); 213 214 unsigned int getNbRoutes() {return m_routes.size();}; 215 216 struct Route getRouteForDestination(enum eRouteDestination dst, int channel); 217 RouteVector getRoutesForSource(enum eRouteSource src, int channel); 218 219 struct Route decodeRoute(uint32_t val); 220 uint32_t encodeRoute(struct Route r); 221 public: 222 static enum eRouteDestination intToRouteDestination(int); 223 static enum eRouteSource intToRouteSource(int); 224 protected: 225 EAP &m_eap; 226 enum eRegBase m_base; 227 unsigned int m_offset; 228 RouteVector m_routes; 229 protected: 230 DECLARE_DEBUG_MODULE_REFERENCE; 231 }; 232 233 // ---------- 234 // the peak space is a special version of a router config 235 class PeakSpace : public RouterConfig { 236 public: 237 PeakSpace(EAP &p) : RouterConfig(p, eRT_Peak, 0) {}; 238 virtual ~PeakSpace() {}; 239 240 virtual bool read() {return read(m_base, m_offset);}; 241 virtual bool write() {return write(m_base, m_offset);}; 242 virtual bool read(enum eRegBase b, unsigned offset); 243 virtual bool write(enum eRegBase b, unsigned offset); 244 virtual void show(); 245 }; 246 247 // ---------- 248 class StreamConfig { 249 public: 250 struct ConfigBlock { // FIXME: somewhere in the DICE avdevice this is present too 251 uint32_t nb_audio; 252 uint32_t nb_midi; 253 uint32_t names[DICE_EAP_CHANNEL_CONFIG_NAMESTR_LEN_QUADS]; 254 uint32_t ac3_map; 255 }; 256 void showConfigBlock(struct ConfigBlock &); 257 diceNameVector getNamesForBlock(struct ConfigBlock &b); 258 public: 259 StreamConfig(EAP &, enum eRegBase, unsigned int offset); 260 ~StreamConfig(); 261 262 bool read() {return read(m_base, m_offset);}; 263 bool write() {return write(m_base, m_offset);}; 264 bool read(enum eRegBase b, unsigned offset); 265 bool write(enum eRegBase b, unsigned offset); 266 267 void show(); 268 269 private: 270 EAP &m_eap; 271 enum eRegBase m_base; 272 unsigned int m_offset; 273 274 uint32_t m_nb_tx; 275 uint32_t m_nb_rx; 276 277 struct ConfigBlock *m_tx_configs; 278 struct ConfigBlock *m_rx_configs; 279 280 DECLARE_DEBUG_MODULE_REFERENCE; 281 }; 282 283 public: // mixer control subclass 284 class Mixer : public Control::MatrixMixer { 285 public: 286 Mixer(EAP &); 287 ~Mixer(); 288 289 bool init(); 290 void show(); 291 292 void updateNameCache(); 293 /** 294 * load the coefficients from the device into the local cache 295 * @return 296 */ 297 bool loadCoefficients(); 298 /** 299 * Stores the coefficients from the cache to the device 300 * @return 301 */ 302 bool storeCoefficients(); 303 304 virtual int getRowCount( ); 305 virtual int getColCount( ); 306 307 virtual int canWrite( const int, const int ); 308 virtual double setValue( const int, const int, const double ); 309 virtual double getValue( const int, const int ); 310 311 bool hasNames() const { return true; } 312 std::string getRowName( const int ); 313 std::string getColName( const int ); 314 315 // TODO: implement connections. 316 bool canConnect() const { return false; } 317 318 // full map updates are unsupported 319 virtual bool getCoefficientMap(int &); 320 virtual bool storeCoefficientMap(int &); 321 322 private: 323 EAP & m_eap; 324 fb_quadlet_t *m_coeff; 325 326 std::map<int, RouterConfig::Route> m_input_route_map; 327 std::map<int, RouterConfig::RouteVector> m_output_route_map; 328 329 DECLARE_DEBUG_MODULE_REFERENCE; 330 }; 331 332 // ---------- 333 class Router : public Control::CrossbarRouter { 334 private: 335 struct Source { 336 std::string name; 337 enum eRouteSource src; 338 int srcChannel; 339 }; 340 typedef std::vector<Source> SourceVector; 341 typedef std::vector<Source>::iterator SourceVectorIterator; 342 343 struct Destination { 344 std::string name; 345 enum eRouteDestination dst; 346 int dstChannel; 347 }; 348 typedef std::vector<Destination> DestinationVector; 349 typedef std::vector<Destination>::iterator DestinationVectorIterator; 350 351 public: 352 Router(EAP &); 353 ~Router(); 354 355 void show(); 356 357 // to be subclassed by the implementing 358 // devices 359 virtual void setupSources(); 360 virtual void setupDestinations(); 361 362 void setupDestinationsAddDestination(const char *name, enum eRouteDestination dstid, 363 unsigned int base, unsigned int cnt); 364 void setupSourcesAddSource(const char *name, enum eRouteSource srcid, 365 unsigned int base, unsigned int cnt); 366 367 int getDestinationIndex(enum eRouteDestination dstid, int channel); 368 int getSourceIndex(enum eRouteSource srcid, int channel); 369 370 // per-coefficient access 371 virtual std::string getSourceName(const int); 372 virtual std::string getDestinationName(const int); 373 virtual int getSourceIndex(std::string); 374 virtual int getDestinationIndex(std::string); 375 virtual NameVector getSourceNames(); 376 virtual NameVector getDestinationNames(); 377 378 virtual Control::CrossbarRouter::Groups getSources(); 379 virtual Control::CrossbarRouter::Groups getDestinations(); 380 381 virtual IntVector getDestinationsForSource(const int); 382 virtual int getSourceForDestination(const int); 383 384 virtual bool canConnect( const int source, const int dest); 385 virtual bool setConnectionState( const int source, const int dest, const bool enable); 386 virtual bool getConnectionState( const int source, const int dest ); 387 388 virtual bool canConnect(std::string, std::string); 389 virtual bool setConnectionState(std::string, std::string, const bool enable); 390 virtual bool getConnectionState(std::string, std::string); 391 392 virtual bool clearAllConnections(); 393 394 virtual int getNbSources(); 395 virtual int getNbDestinations(); 396 397 // functions to access the entire routing map at once 398 // idea is that the row/col nodes that are 1 get a routing entry 399 virtual bool getConnectionMap(int *); 400 virtual bool setConnectionMap(int *); 401 402 // peak metering support 403 virtual bool hasPeakMetering(); 404 virtual bool getPeakValues(double &) {return false;}; 405 virtual double getPeakValue(const int source, const int dest); 406 virtual Control::CrossbarRouter::PeakValues getPeakValues(); 407 408 private: 409 EAP &m_eap; 410 // these contain the sources and destinations available for this 411 // router 412 SourceVector m_sources; 413 DestinationVector m_destinations; 414 415 PeakSpace &m_peak; 416 417 DECLARE_DEBUG_MODULE_REFERENCE; 418 }; 419 420 public: 421 EAP(Device &); 422 virtual ~EAP(); 423 424 static bool supportsEAP(Device &); 425 bool init(); 426 427 void show(); 428 void showApplication(); 429 enum eWaitReturn operationBusy(); 430 enum eWaitReturn waitForOperationEnd(int max_wait_time_ms = 100); 431 432 bool updateConfigurationCache(); 433 RouterConfig * getActiveRouterConfig(); 434 StreamConfig * getActiveStreamConfig(); 435 436 bool updateRouterConfig(RouterConfig&, bool low, bool mid, bool high); 437 bool updateCurrentRouterConfig(RouterConfig&); 438 bool updateStreamConfig(StreamConfig&, bool low, bool mid, bool high); 439 bool updateStreamConfig(RouterConfig&, StreamConfig&, bool low, bool mid, bool high); 440 441 bool loadFlashConfig(); 442 bool storeFlashConfig(); 443 444 private: 445 bool loadRouterConfig(bool low, bool mid, bool high); 446 bool loadStreamConfig(bool low, bool mid, bool high); 447 bool loadRouterAndStreamConfig(bool low, bool mid, bool high); 448 private: 449 bool m_router_exposed; 450 bool m_router_readonly; 451 bool m_router_flashstored; 452 uint16_t m_router_nb_entries; 453 454 bool m_mixer_exposed; 455 bool m_mixer_readonly; 456 bool m_mixer_flashstored; 457 uint8_t m_mixer_tx_id; 458 uint8_t m_mixer_rx_id; 459 uint8_t m_mixer_nb_tx; 460 uint8_t m_mixer_nb_rx; 461 462 bool m_general_support_dynstream; 463 bool m_general_support_flash; 464 bool m_general_peak_enabled; 465 uint8_t m_general_max_tx; 466 uint8_t m_general_max_rx; 467 bool m_general_stream_cfg_stored; 468 uint16_t m_general_chip; 469 470 bool commandHelper(fb_quadlet_t cmd); 471 472 public: 473 bool readReg(enum eRegBase, unsigned offset, quadlet_t *); 474 bool writeReg(enum eRegBase, unsigned offset, quadlet_t); 475 bool readRegBlock(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 476 bool writeRegBlock(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 477 bool readRegBlockSwapped(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 478 bool writeRegBlockSwapped(enum eRegBase, unsigned, fb_quadlet_t *, size_t); 479 fb_nodeaddr_t offsetGen(enum eRegBase, unsigned, size_t); 480 481 protected: 482 DECLARE_DEBUG_MODULE; //_REFERENCE; 483 484 private: 485 Device & m_device; 486 Mixer* m_mixer; 487 Router* m_router; 488 RouterConfig m_current_cfg_routing_low; 489 RouterConfig m_current_cfg_routing_mid; 490 RouterConfig m_current_cfg_routing_high; 491 StreamConfig m_current_cfg_stream_low; 492 StreamConfig m_current_cfg_stream_mid; 493 StreamConfig m_current_cfg_stream_high; 494 public: 495 Mixer* getMixer() {return m_mixer;}; 496 Router* getRouter() {return m_router;}; 497 498 private: 499 500 fb_quadlet_t m_capability_offset; 501 fb_quadlet_t m_capability_size; 502 fb_quadlet_t m_cmd_offset; 503 fb_quadlet_t m_cmd_size; 504 fb_quadlet_t m_mixer_offset; 505 fb_quadlet_t m_mixer_size; 506 fb_quadlet_t m_peak_offset; 507 fb_quadlet_t m_peak_size; 508 fb_quadlet_t m_new_routing_offset; 509 fb_quadlet_t m_new_routing_size; 510 fb_quadlet_t m_new_stream_cfg_offset; 511 fb_quadlet_t m_new_stream_cfg_size; 512 fb_quadlet_t m_curr_cfg_offset; 513 fb_quadlet_t m_curr_cfg_size; 514 fb_quadlet_t m_standalone_offset; 515 fb_quadlet_t m_standalone_size; 516 fb_quadlet_t m_app_offset; 517 fb_quadlet_t m_app_size; 518 }; 519 520 }; 521 522 #endif // __DICE_EAP_H trunk/libffado/src/dice/focusrite/focusrite_eap.cpp
r1737 r1766 51 51 52 52 53 FocusriteEAP::FocusriteEAP(Dice::Device& dev) : Dice:: Device::EAP(dev) {53 FocusriteEAP::FocusriteEAP(Dice::Device& dev) : Dice::EAP(dev) { 54 54 } 55 55 trunk/libffado/src/dice/focusrite/focusrite_eap.h
r1734 r1766 26 26 #define DICE_FOCUSRITE_FOCUSRITE_EAP_H 27 27 28 #include "dice/dice_ avdevice.h"28 #include "dice/dice_eap.h" 29 29 30 30 #include "libieee1394/configrom.h" … … 33 33 namespace Focusrite { 34 34 35 class FocusriteEAP : public Dice:: Device::EAP35 class FocusriteEAP : public Dice::EAP 36 36 { 37 37 public: trunk/libffado/src/dice/focusrite/saffire_pro24.cpp
r1734 r1766 92 92 if (Dice::Device::discover()) { 93 93 fb_quadlet_t* tmp = (fb_quadlet_t *)calloc(2, sizeof(fb_quadlet_t)); 94 getEAP()->readRegBlock(Dice:: Device::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t));94 getEAP()->readRegBlock(Dice::EAP::eRT_Application, 0x00, tmp, 1*sizeof(fb_quadlet_t)); 95 95 //hexDumpQuadlets(tmp, 2); // DEBUG 96 96 if (tmp[0] != 0x00010004 ) { … … 99 99 return false; 100 100 } 101 //getEAP()->readRegBlock(Dice:: Device::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG101 //getEAP()->readRegBlock(Dice::EAP::eRT_Command, 0x00, tmp, 2*sizeof(fb_quadlet_t)); // DEBUG 102 102 //hexDumpQuadlets(tmp, 2); // DEBUG 103 103 … … 124 124 Dice::Device::showDevice(); 125 125 } 126 Dice:: Device::EAP* SaffirePro24::createEAP() {126 Dice::EAP* SaffirePro24::createEAP() { 127 127 return new SaffirePro24EAP(*this); 128 128 } 129 129 130 130 bool SaffirePro24::setNickName( std::string name ) { 131 return getEAP()->writeRegBlock( Dice:: Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() );131 return getEAP()->writeRegBlock( Dice::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name.c_str(), name.size() ); 132 132 } 133 133 134 134 std::string SaffirePro24::getNickName() { 135 135 char name[16]; 136 getEAP()->readRegBlock( Dice:: Device::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 );136 getEAP()->readRegBlock( Dice::EAP::eRT_Application, 0x40, (fb_quadlet_t*)name, 16 ); 137 137 return std::string( name ); 138 138 } trunk/libffado/src/dice/focusrite/saffire_pro24.h
r1734 r1766 62 62 Poti* getDimPoti(std::string); 63 63 }; 64 Dice:: Device::EAP* createEAP();64 Dice::EAP* createEAP(); 65 65 66 66 class LineInstSwitch; trunk/libffado/src/dice/focusrite/saffire_pro40.cpp
r1729 r1766 24 24 #include "saffire_pro40.h" 25 25 26 #include "focusrite_eap.h" 27 26 28 namespace Dice { 27 29 namespace Focusrite { … … 47 49 48 50 bool SaffirePro40::setNickName(std::string name) { 49 return getEAP()->writeRegBlock(Dice:: Device::EAP::eRT_Application, 0x44, (quadlet_t*)name.c_str(), name.size());51 return getEAP()->writeRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name.c_str(), name.size()); 50 52 } 51 53 std::string SaffirePro40::getNickName() { 52 54 char name[16]; 53 getEAP()->readRegBlock(Dice:: Device::EAP::eRT_Application, 0x44, (quadlet_t*)name, 16);55 getEAP()->readRegBlock(Dice::EAP::eRT_Application, 0x44, (quadlet_t*)name, 16); 54 56 return std::string(name); 55 57 }