Changeset 445 for trunk/libffado/src/bounce
- Timestamp:
- 04/02/07 12:35:17 (16 years ago)
- Files:
-
- trunk/libffado/src/bounce/bounce_avdevice.cpp (modified) (31 diffs)
- trunk/libffado/src/bounce/bounce_avdevice.h (modified) (6 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.cpp (modified) (27 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bounce/bounce_avdevice.cpp
r436 r445 1 /* bounce_avdevice.cpp2 * Copyright (C) 200 6by Pieter Palmers3 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library is distributed in the hope that it will be useful, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 20 23 */ 24 21 25 #include "bounce/bounce_avdevice.h" 22 26 … … 45 49 static VendorModelEntry supportedDeviceList[] = 46 50 { 47 {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "F reeBoB", "Bounce"},51 {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FFADO", "Bounce"}, 48 52 }; 49 53 … … 80 84 ++i ) 81 85 { 82 if ( 86 if ( 83 87 // ( supportedDeviceList[i].vendor_id == vendorId ) 84 88 ( supportedDeviceList[i].model_id == modelId ) 85 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 89 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 86 90 ) 87 91 { … … 98 102 debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 99 103 m_nodeId ); 100 104 101 105 // unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 102 106 unsigned int modelId = m_pConfigRom->getModelId(); … … 108 112 { 109 113 if ( //( supportedDeviceList[i].vendor_id == vendorId ) 110 ( supportedDeviceList[i].model_id == modelId ) 111 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 114 ( supportedDeviceList[i].model_id == modelId ) 115 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 112 116 ) 113 117 { … … 168 172 169 173 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to processor\n"); 170 174 171 175 std::string id=std::string("dev?"); 172 176 if(!getOption("id", id)) { 173 177 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 174 178 } 175 179 176 180 int i=0; 177 181 for (i=0;i<BOUNCE_NB_AUDIO_CHANNELS;i++) { … … 205 209 free(buff); 206 210 } 207 211 208 212 for (i=0;i<BOUNCE_NB_MIDI_CHANNELS;i++) { 209 213 char *buff; … … 237 241 } 238 242 239 243 return true; 240 244 } 241 245 … … 243 247 BounceDevice::prepare() { 244 248 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 245 249 246 250 bool snoopMode=false; 247 251 if(!getOption("snoopMode", snoopMode)) { … … 251 255 // create & add streamprocessors 252 256 Streaming::StreamProcessor *p; 253 257 254 258 p=new Streaming::AmdtpReceiveStreamProcessor( 255 259 m_p1394Service->getPort(), … … 285 289 BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 286 290 } 287 291 288 292 if(!p->init()) { 289 293 debugFatal("Could not initialize transmit processor %s!\n", … … 335 339 int n=i; 336 340 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 337 341 338 342 // allocate ISO channel 339 343 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 343 347 } 344 348 p->setChannel(isochannel); 345 349 346 350 fb_quadlet_t reg_isoch; 347 351 // check value of ISO_CHANNEL register … … 358 362 return false; 359 363 } 360 364 361 365 // write value of ISO_CHANNEL register 362 366 reg_isoch=isochannel; … … 367 371 return false; 368 372 } 369 373 370 374 return true; 371 375 372 376 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 373 377 int n=i-m_receiveProcessors.size(); 374 378 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 375 379 376 380 // allocate ISO channel 377 381 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 381 385 } 382 386 p->setChannel(isochannel); 383 387 384 388 fb_quadlet_t reg_isoch; 385 389 // check value of ISO_CHANNEL register … … 396 400 return false; 397 401 } 398 402 399 403 // write value of ISO_CHANNEL register 400 404 reg_isoch=isochannel; … … 405 409 return false; 406 410 } 407 411 408 412 return true; 409 413 } 410 414 411 415 debugError("SP index %d out of range!\n",i); 412 416 413 417 return false; 414 418 } … … 420 424 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 421 425 unsigned int isochannel=p->getChannel(); 422 426 423 427 fb_quadlet_t reg_isoch; 424 428 // check value of ISO_CHANNEL register … … 431 435 return false; 432 436 } 433 437 434 438 // write value of ISO_CHANNEL register 435 439 reg_isoch=0xFFFFFFFFUL; … … 438 442 return false; 439 443 } 440 444 441 445 // deallocate ISO channel 442 446 if(!deallocateIsoChannel(isochannel)) { … … 444 448 return false; 445 449 } 446 450 447 451 p->setChannel(-1); 448 452 return true; 449 453 450 454 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 451 455 int n=i-m_receiveProcessors.size(); 452 456 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 453 457 454 458 unsigned int isochannel=p->getChannel(); 455 459 456 460 fb_quadlet_t reg_isoch; 457 461 // check value of ISO_CHANNEL register … … 464 468 return false; 465 469 } 466 470 467 471 // write value of ISO_CHANNEL register 468 472 reg_isoch=0xFFFFFFFFUL; … … 471 475 return false; 472 476 } 473 477 474 478 // deallocate ISO channel 475 479 if(!deallocateIsoChannel(isochannel)) { … … 477 481 return false; 478 482 } 479 483 480 484 p->setChannel(-1); 481 485 return true; 482 486 } 483 487 484 488 debugError("SP index %d out of range!\n",i); 485 489 return false; … … 491 495 int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 492 496 unsigned int bandwidth=8+packet_size; 493 497 494 498 int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 495 499 496 500 debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 497 501 ch, bandwidth); 498 502 499 503 return ch; 500 504 } … … 510 514 BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 511 515 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 512 516 513 517 if(offset >= BOUNCE_INVALID_OFFSET) { 514 518 debugError("invalid offset: 0x%016llX\n", offset); 515 519 return false; 516 520 } 517 521 518 522 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 519 523 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 520 524 521 525 if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 522 526 debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); … … 524 528 } 525 529 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 526 530 527 531 return true; 528 532 } … … 530 534 bool 531 535 BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 532 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 536 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 533 537 offset, data); 534 538 535 539 if(offset >= BOUNCE_INVALID_OFFSET) { 536 540 debugError("invalid offset: 0x%016llX\n", offset); 537 541 return false; 538 542 } 539 543 540 544 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 541 545 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 542 546 543 547 if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 544 548 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); … … 548 552 } 549 553 550 bool 554 bool 551 555 BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 552 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 556 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 553 557 offset, length); 554 558 555 559 if(offset >= BOUNCE_INVALID_OFFSET) { 556 560 debugError("invalid offset: 0x%016llX\n", offset); 557 561 return false; 558 562 } 559 563 560 564 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 561 565 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 562 566 563 567 if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 564 568 debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); … … 568 572 } 569 573 570 bool 574 bool 571 575 BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 572 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 576 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 573 577 offset, length); 574 578 575 579 if(offset >= BOUNCE_INVALID_OFFSET) { 576 580 debugError("invalid offset: 0x%016llX\n", offset); 577 581 return false; 578 582 } 579 583 580 584 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 581 585 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; trunk/libffado/src/bounce/bounce_avdevice.h
r436 r445 1 /* bounce_avdevice.h2 * Copyright (C) 200 6by Pieter Palmers3 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library is distributed in the hope that it will be useful, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 20 23 */ 24 21 25 #ifndef BOUNCEDEVICE_H 22 26 #define BOUNCEDEVICE_H … … 66 70 public: 67 71 BounceDevice( std::auto_ptr<ConfigRom>( configRom ), 68 69 72 Ieee1394Service& ieee1394Service, 73 int nodeId ); 70 74 virtual ~BounceDevice(); 71 75 72 76 static bool probe( ConfigRom& configRom ); 73 77 bool discover(); 74 78 75 79 bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 76 80 int getSamplingFrequency( ); 77 81 78 82 bool prepare(); 79 83 bool lock(); … … 86 90 bool startStreamByIndex(int i); 87 91 bool stopStreamByIndex(int i); 88 92 89 93 void showDevice(); 90 94 … … 99 103 100 104 bool addPortsToProcessor( 101 Streaming::StreamProcessor *processor, 105 Streaming::StreamProcessor *processor, 102 106 Streaming::Port::E_Direction direction); 103 107 104 108 private: // generic helpers 105 109 int allocateIsoChannel(unsigned int packet_size); … … 112 116 bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 113 117 bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 114 118 115 119 private: 116 120 BounceNotifier *m_Notifier; 117 121 /** 118 * this class reacts on the other side writing to the 122 * this class reacts on the other side writing to the 119 123 * hosts address space 120 124 */ … … 126 130 BounceNotifier(BounceDevice *, nodeaddr_t start); 127 131 virtual ~BounceNotifier(); 128 132 129 133 private: 130 134 BounceDevice *m_bouncedevice; trunk/libffado/src/bounce/bounce_slave_avdevice.cpp
r435 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 6 4 * 7 * http://freebob.sf.net 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 8 7 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>8 * FFADO is based upon FreeBoB 10 9 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 15 13 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.14 * This library 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 GNU 17 * Lesser General Public License for more details. 20 18 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 27 23 */ 28 24 … … 42 38 { 43 39 //{vendor_id, model_id, unit_specifier_id, vendor_name, model_name}, 44 {0x0B0001, 0x0B0001, 0x0B0001, "F reeBoB", "Bounce Slave"},40 {0x0B0001, 0x0B0001, 0x0B0001, "FFADO", "Bounce Slave"}, 45 41 }; 46 42 … … 80 76 debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing memory space...\n"); 81 77 fb_quadlet_t result=0xFFFFFFFFLU; 82 78 83 79 // initialize the ISO channel registers 84 80 // this will write to our own registers … … 91 87 return false; 92 88 } 93 89 94 90 // set everything such that we can be discovered 95 91 m_original_config_rom=save_config_rom( m_p1394Service->getHandle() ); 96 92 97 93 if ( init_config_rom( m_p1394Service->getHandle() ) < 0 ) { 98 94 debugError("Could not initalize local config rom\n"); 99 95 return false; 100 96 } 101 97 102 98 // refresh our config rom cache 103 99 if ( !m_pConfigRom->initialize() ) { … … 122 118 bool 123 119 BounceSlaveDevice::lock() { 124 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 120 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 125 121 m_model->vendor_name, m_model->model_name, m_nodeId); 126 122 127 123 // get a notifier to handle device notifications 128 124 nodeaddr_t notify_address; … … 131 127 BOUNCE_REGISTER_LENGTH, 132 128 BOUNCE_REGISTER_LENGTH); 133 129 134 130 if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 135 131 debugError("Could not find free ARM block for notification\n"); 136 132 return false; 137 133 } 138 134 139 135 m_Notifier=new BounceSlaveDevice::BounceSlaveNotifier(this, notify_address); 140 136 141 137 if(!m_Notifier) { 142 138 debugError("Could not allocate notifier\n"); 143 139 return false; 144 140 } 145 141 146 142 if (!m_p1394Service->registerARMHandler(m_Notifier)) { 147 143 debugError("Could not register notifier\n"); … … 150 146 return false; 151 147 } 152 148 153 149 // (re)initialize the memory space 154 150 if (!initMemSpace()) { … … 156 152 return false; 157 153 } 158 154 159 155 return true; 160 156 } … … 177 173 BounceSlaveDevice::prepare() { 178 174 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceSlaveDevice...\n" ); 179 175 180 176 // create & add streamprocessors 181 177 Streaming::StreamProcessor *p; 182 178 183 179 p=new Streaming::AmdtpSlaveReceiveStreamProcessor( 184 180 m_p1394Service->getPort(), … … 206 202 m_samplerate, 207 203 BOUNCE_NB_AUDIO_CHANNELS); 208 204 209 205 if(!p->init()) { 210 206 debugFatal("Could not initialize transmit processor!\n"); … … 227 223 bool 228 224 BounceSlaveDevice::startStreamByIndex(int i) { 229 225 230 226 if (i<(int)m_receiveProcessors.size()) { 231 227 int n=i; 232 228 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 233 229 234 230 // the other side sends on this channel 235 231 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_RX_ISOCHANNEL; 236 232 iso_channel_offset += ((unsigned)n)*4; 237 233 238 234 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFFLU)) { 239 235 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 240 236 return false; 241 237 } 242 238 243 239 fb_quadlet_t result; 244 240 // this will read from our own registers … … 247 243 return false; 248 244 } 249 245 250 246 // set ISO channel 251 247 p->setChannel(result); 252 248 253 249 return true; 254 250 255 251 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 256 252 int n=i-m_receiveProcessors.size(); 257 253 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 258 254 259 255 // the other side sends on this channel 260 256 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_TX_ISOCHANNEL; 261 257 iso_channel_offset += ((unsigned)n)*4; 262 258 263 259 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFF)) { 264 260 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 265 261 return false; 266 262 } 267 263 268 264 fb_quadlet_t result; 269 265 // this will read from our own registers … … 272 268 return false; 273 269 } 274 270 275 271 // set ISO channel 276 272 p->setChannel(result); … … 279 275 280 276 } 281 277 282 278 debugError("SP index %d out of range!\n",i); 283 279 284 280 return false; 285 281 } … … 301 297 debugWarning("Could not retrieve isoTimeoutSecs parameter, defauling to 120secs\n"); 302 298 } 303 299 304 300 int wait_cycles=timeoutSecs*10; // two seconds 305 301 306 302 fb_quadlet_t reg=v; 307 303 308 304 while ((v == reg) && wait_cycles) { 309 305 wait_cycles--; … … 318 314 return false; 319 315 } 320 316 321 317 return true; 322 318 } … … 326 322 327 323 328 struct BounceSlaveDevice::configrom_backup 324 struct BounceSlaveDevice::configrom_backup 329 325 BounceSlaveDevice::save_config_rom(raw1394handle_t handle) 330 326 { … … 333 329 /* get the current rom image */ 334 330 retval=raw1394_get_config_rom(handle, tmp.rom, 0x100, &tmp.rom_size, &tmp.rom_version); 335 // 331 // tmp.rom_size=rom1394_get_size(tmp.rom); 336 332 // printf("save_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,tmp.rom_size,tmp.rom_version); 337 333 … … 339 335 } 340 336 341 int 337 int 342 338 BounceSlaveDevice::restore_config_rom(raw1394handle_t handle, struct BounceSlaveDevice::configrom_backup old) 343 339 { 344 340 int retval; 345 341 // int i; 346 342 347 343 quadlet_t current_rom[0x100]; 348 344 size_t current_rom_size; … … 371 367 } 372 368 373 int 369 int 374 370 BounceSlaveDevice::init_config_rom(raw1394handle_t handle) 375 371 { … … 380 376 rom1394_directory dir; 381 377 char *leaf; 382 378 383 379 /* get the current rom image */ 384 380 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); … … 391 387 // } 392 388 // printf("\n"); 393 389 394 390 /* get the local directory */ 395 391 rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir); 396 392 397 393 /* change the vendor description for kicks */ 398 394 i = strlen(dir.textual_leafs[0]); 399 strncpy(dir.textual_leafs[0], F REEBOB_BOUNCE_SERVER_VENDORNAME " ", i);400 401 dir.vendor_id=F REEBOB_BOUNCE_SERVER_VENDORID;402 dir.model_id=F REEBOB_BOUNCE_SERVER_MODELID;403 395 strncpy(dir.textual_leafs[0], FFADO_BOUNCE_SERVER_VENDORNAME " ", i); 396 397 dir.vendor_id=FFADO_BOUNCE_SERVER_VENDORID; 398 dir.model_id=FFADO_BOUNCE_SERVER_MODELID; 399 404 400 /* update the rom */ 405 401 retval = rom1394_set_directory(rom, &dir); … … 411 407 // } 412 408 // printf("\n"); 413 409 414 410 /* free the allocated mem for the textual leaves */ 415 411 rom1394_free_directory( &dir); 416 412 417 413 /* add an AV/C unit directory */ 418 dir.unit_spec_id = F REEBOB_BOUNCE_SERVER_SPECID;414 dir.unit_spec_id = FFADO_BOUNCE_SERVER_SPECID; 419 415 dir.unit_sw_version = 0x00010001; 420 leaf = F REEBOB_BOUNCE_SERVER_MODELNAME;416 leaf = FFADO_BOUNCE_SERVER_MODELNAME; 421 417 dir.nr_textual_leafs = 1; 422 418 dir.textual_leafs = &leaf; 423 419 424 420 /* manipulate the rom */ 425 421 retval = rom1394_add_unit( rom, &dir); 426 422 427 423 /* get the computed size of the rom image */ 428 424 rom_size = rom1394_get_size(rom); 429 425 430 426 // printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size); 431 427 // for (i = 0; i < rom_size; i++) … … 435 431 // } 436 432 // printf("\n"); 437 // 433 // 438 434 /* convert computed rom size from quadlets to bytes before update */ 439 435 rom_size *= sizeof(quadlet_t); 440 436 retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); 441 437 // printf("update_config_rom returned %d\n",retval); 442 438 443 439 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 444 440 // printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); … … 449 445 // } 450 446 // printf("\n"); 451 452 // 453 447 448 // printf("You need to reload your ieee1394 modules to reset the rom.\n"); 449 454 450 return 0; 455 451 } … … 459 455 460 456 BounceSlaveDevice::BounceSlaveNotifier::BounceSlaveNotifier(BounceSlaveDevice *d, nodeaddr_t start) 461 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 457 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 462 458 RAW1394_ARM_READ | RAW1394_ARM_WRITE, // allowed operations 463 459 0, //RAW1394_ARM_READ | RAW1394_ARM_WRITE, // operations to be notified of … … 468 464 } 469 465 470 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 466 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 471 467 { 472 468 trunk/libffado/src/bounce/bounce_slave_avdevice.h
r435 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 * 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 7 * 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library 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 GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 23 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_BOUNCESLAVEDEVICE__ 29 #define __FREEBOB_BOUNCESLAVEDEVICE__ 25 #ifndef __FFADO_BOUNCESLAVEDEVICE__ 26 #define __FFADO_BOUNCESLAVEDEVICE__ 30 27 31 28 #include "debugmodule/debugmodule.h" 32 29 #include "bounce_avdevice.h" 33 30 34 #define F REEBOB_MAX_NAME_LEN 25631 #define FFADO_MAX_NAME_LEN 256 35 32 36 #define F REEBOB_BOUNCE_SERVER_VENDORNAME "FreeBoBServer"37 #define F REEBOB_BOUNCE_SERVER_MODELNAME "freebob-server"33 #define FFADO_BOUNCE_SERVER_VENDORNAME "FFADO Server" 34 #define FFADO_BOUNCE_SERVER_MODELNAME "ffado-server" 38 35 39 36 // NOTE: this is currently free, but it is not really allowed to use 40 #define F REEBOB_BOUNCE_SERVER_VENDORID 0x000B000141 #define F REEBOB_BOUNCE_SERVER_MODELID 0x000B000142 #define F REEBOB_BOUNCE_SERVER_SPECID 0x000B000137 #define FFADO_BOUNCE_SERVER_VENDORID 0x000B0001 38 #define FFADO_BOUNCE_SERVER_MODELID 0x000B0001 39 #define FFADO_BOUNCE_SERVER_SPECID 0x000B0001 43 40 44 41 namespace Bounce { … … 51 48 Ieee1394Service& ieee1394Service ); 52 49 virtual ~BounceSlaveDevice(); 53 50 54 51 static bool probe( ConfigRom& configRom ); 55 52 bool discover(); … … 57 54 bool lock(); 58 55 bool unlock(); 59 56 60 57 bool startStreamByIndex(int i); 61 58 bool stopStreamByIndex(int i); … … 65 62 bool initMemSpace(); 66 63 bool restoreMemSpace(); 67 64 68 65 private: // configrom shit 69 66 … … 74 71 }; 75 72 struct configrom_backup m_original_config_rom; 76 77 struct configrom_backup 73 74 struct configrom_backup 78 75 save_config_rom(raw1394handle_t handle); 79 76 int restore_config_rom(raw1394handle_t handle, struct configrom_backup old); 80 77 int init_config_rom(raw1394handle_t handle); 81 78 82 79 private: 83 80 BounceSlaveNotifier *m_Notifier; 84 81 /** 85 * this class reacts on the ohter side writing to the 82 * this class reacts on the ohter side writing to the 86 83 * hosts address space 87 84 */ … … 91 88 BounceSlaveNotifier(BounceSlaveDevice *, nodeaddr_t start); 92 89 virtual ~BounceSlaveNotifier(); 93 90 94 91 private: 95 92 BounceSlaveDevice *m_bounceslavedevice; … … 99 96 } // end of namespace Bounce 100 97 101 #endif /* __F REEBOB_BOUNCESLAVEDEVICE__ */98 #endif /* __FFADO_BOUNCESLAVEDEVICE__ */ 102 99 103 100