1230 | | if(snoopMode) { // a stream from the device to another host |
---|
1231 | | fb_quadlet_t reg_isoch; |
---|
1232 | | // check value of ISO_CHANNEL register |
---|
1233 | | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
1234 | | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
1235 | | p->setChannel(-1); |
---|
1236 | | return false; |
---|
1237 | | } |
---|
1238 | | int isochannel = reg_isoch; |
---|
1239 | | debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
1240 | | "(%p) Snooping %s from channel %d\n", |
---|
1241 | | this, dir, isochannel); |
---|
1242 | | p->setChannel(isochannel); |
---|
| 1230 | if (start == true) { |
---|
| 1231 | if(snoopMode) { // a stream from the device to another host |
---|
| 1232 | fb_quadlet_t reg_isoch; |
---|
| 1233 | // check value of ISO_CHANNEL register |
---|
| 1234 | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
| 1235 | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
| 1236 | p->setChannel(-1); |
---|
| 1237 | return false; |
---|
| 1238 | } |
---|
| 1239 | int isochannel = reg_isoch; |
---|
| 1240 | debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
| 1241 | "(%p) Snooping %s from channel %d\n", |
---|
| 1242 | this, dir, isochannel); |
---|
| 1243 | p->setChannel(isochannel); |
---|
| 1244 | } else { |
---|
| 1245 | // allocate ISO channel |
---|
| 1246 | int isochannel = allocateIsoChannel(p->getMaxPacketSize()); |
---|
| 1247 | if(isochannel<0) { |
---|
| 1248 | debugError("Could not allocate iso channel for SP %d (A%s %d)\n", i, dir, n); |
---|
| 1249 | return false; |
---|
| 1250 | } |
---|
| 1251 | debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
| 1252 | "(%p) Allocated channel %u for %s\n", |
---|
| 1253 | this, isochannel, dir); |
---|
| 1254 | p->setChannel(isochannel); |
---|
| 1255 | |
---|
| 1256 | fb_quadlet_t reg_isoch; |
---|
| 1257 | // check value of ISO_CHANNEL register |
---|
| 1258 | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
| 1259 | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
| 1260 | p->setChannel(-1); |
---|
| 1261 | deallocateIsoChannel(isochannel); |
---|
| 1262 | return false; |
---|
| 1263 | } |
---|
| 1264 | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
| 1265 | debugWarning("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08"PRIX32") for A%s %d\n", reg_isoch, dir, n); |
---|
| 1266 | /* The ISO channel has already been registered, probably |
---|
| 1267 | * because the device was running before and jackd just |
---|
| 1268 | * crashed. Let's simply reuse the previously selected |
---|
| 1269 | * ISO channel. |
---|
| 1270 | * |
---|
| 1271 | * FIXME: try to reset the channel register and |
---|
| 1272 | * return to a clean state |
---|
| 1273 | */ |
---|
| 1274 | deallocateIsoChannel(isochannel); |
---|
| 1275 | p->setChannel(reg_isoch); |
---|
| 1276 | #if 0 |
---|
| 1277 | /* FIXME: Looks like it's not necessary to ask the IRM. |
---|
| 1278 | * Just use the already registered ISO channel. |
---|
| 1279 | */ |
---|
| 1280 | // ask the IRM to use this channel |
---|
| 1281 | if (get1394Service().allocateFixedIsoChannelGeneric(reg_isoch,p->getMaxPacketSize()) < 0) { |
---|
| 1282 | debugError("Cannot allocate iso channel (0x%08"PRIX32") for ATX %d\n", reg_isoch, n); |
---|
| 1283 | } |
---|
| 1284 | #endif |
---|
| 1285 | isochannel=reg_isoch; |
---|
| 1286 | } |
---|
| 1287 | |
---|
| 1288 | // write value of ISO_CHANNEL register |
---|
| 1289 | reg_isoch = isochannel; |
---|
| 1290 | if(!(*this.*writeFunc)(n, base_address, reg_isoch)) { |
---|
| 1291 | debugError("Could not write ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
| 1292 | p->setChannel(-1); |
---|
| 1293 | deallocateIsoChannel(isochannel); |
---|
| 1294 | return false; |
---|
| 1295 | } |
---|
| 1296 | } |
---|
| 1297 | return true; |
---|
1244 | | // allocate ISO channel |
---|
1245 | | int isochannel = allocateIsoChannel(p->getMaxPacketSize()); |
---|
1246 | | if(isochannel<0) { |
---|
1247 | | debugError("Could not allocate iso channel for SP %d (A%s %d)\n", i, dir, n); |
---|
1248 | | return false; |
---|
1249 | | } |
---|
1250 | | debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
1251 | | "(%p) Allocated channel %u for %s\n", |
---|
1252 | | this, isochannel, dir); |
---|
1253 | | p->setChannel(isochannel); |
---|
1254 | | |
---|
1255 | | fb_quadlet_t reg_isoch; |
---|
1256 | | // check value of ISO_CHANNEL register |
---|
1257 | | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
1258 | | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
1259 | | p->setChannel(-1); |
---|
1260 | | deallocateIsoChannel(isochannel); |
---|
1261 | | return false; |
---|
1262 | | } |
---|
1263 | | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
1264 | | debugWarning("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08"PRIX32") for A%s %d\n", reg_isoch, dir, n); |
---|
1265 | | /* The ISO channel has already been registered, probably |
---|
1266 | | * because the device was running before and jackd just |
---|
1267 | | * crashed. Let's simply reuse the previously selected |
---|
1268 | | * ISO channel. |
---|
1269 | | * |
---|
1270 | | * FIXME: try to reset the channel register and |
---|
1271 | | * return to a clean state |
---|
1272 | | */ |
---|
1273 | | deallocateIsoChannel(isochannel); |
---|
1274 | | p->setChannel(reg_isoch); |
---|
1275 | | #if 0 |
---|
1276 | | /* FIXME: Looks like it's not necessary to ask the IRM. |
---|
1277 | | * Just use the already registered ISO channel. |
---|
1278 | | */ |
---|
1279 | | // ask the IRM to use this channel |
---|
1280 | | if (get1394Service().allocateFixedIsoChannelGeneric(reg_isoch,p->getMaxPacketSize()) < 0) { |
---|
1281 | | debugError("Cannot allocate iso channel (0x%08"PRIX32") for ATX %d\n", reg_isoch, n); |
---|
| 1299 | // stop |
---|
| 1300 | if(!snoopMode) { |
---|
| 1301 | unsigned int isochannel = p->getChannel(); |
---|
| 1302 | |
---|
| 1303 | fb_quadlet_t reg_isoch; |
---|
| 1304 | // check value of ISO_CHANNEL register |
---|
| 1305 | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
| 1306 | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
| 1307 | return false; |
---|
1283 | | #endif |
---|
1284 | | isochannel=reg_isoch; |
---|
1285 | | } |
---|
1286 | | |
---|
1287 | | // write value of ISO_CHANNEL register |
---|
1288 | | reg_isoch = isochannel; |
---|
1289 | | if(!(*this.*writeFunc)(n, base_address, reg_isoch)) { |
---|
1290 | | debugError("Could not write ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
1291 | | p->setChannel(-1); |
---|
1292 | | deallocateIsoChannel(isochannel); |
---|
1293 | | return false; |
---|
1294 | | } |
---|
1295 | | } |
---|
1296 | | return true; |
---|
| 1309 | if(reg_isoch != isochannel) { |
---|
| 1310 | debugError("ISO_CHANNEL register != 0x%08"PRIX32" (=0x%08"PRIX32") for A%s %d\n", isochannel, reg_isoch, dir, n); |
---|
| 1311 | return false; |
---|
| 1312 | } |
---|
| 1313 | |
---|
| 1314 | // write value of ISO_CHANNEL register |
---|
| 1315 | reg_isoch=0xFFFFFFFFUL; |
---|
| 1316 | if(!writeTxReg(n, base_address, reg_isoch)) { |
---|
| 1317 | debugError("Could not write ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
| 1318 | return false; |
---|
| 1319 | } |
---|
| 1320 | |
---|
| 1321 | // deallocate ISO channel |
---|
| 1322 | if(!deallocateIsoChannel(isochannel)) { |
---|
| 1323 | debugError("Could not deallocate iso channel for SP %d (A%s %d)\n",i, dir, n); |
---|
| 1324 | return false; |
---|
| 1325 | } |
---|
| 1326 | } |
---|
| 1327 | p->setChannel(-1); |
---|
| 1328 | return true; |
---|
| 1329 | } |
---|
| 1330 | } |
---|
| 1331 | |
---|
| 1332 | bool |
---|
| 1333 | Device::startStreamByIndex(int i) { |
---|
| 1334 | return startstopStreamByIndex(i, true); // start stream |
---|
1301 | | bool snoopMode = false; |
---|
1302 | | fb_nodeaddr_t base_address; // holds DICE_REGISTER_TX_ISOC_BASE or DICE_REGISTER_RX_ISOC_BASE |
---|
1303 | | int n; // number of streaming processor |
---|
1304 | | |
---|
1305 | | Streaming::StreamProcessor *p; |
---|
1306 | | |
---|
1307 | | if(!getOption("snoopMode", snoopMode)) { |
---|
1308 | | debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
1309 | | } |
---|
1310 | | |
---|
1311 | | if (!snoopMode && isIsoStreamingEnabled()) { |
---|
1312 | | debugError("Cannot stop streams while streaming is enabled\n"); |
---|
1313 | | return false; |
---|
1314 | | } |
---|
1315 | | |
---|
1316 | | if (i<(int)m_receiveProcessors.size()) { |
---|
1317 | | n=i; |
---|
1318 | | p = m_receiveProcessors.at(n); |
---|
1319 | | base_address = DICE_REGISTER_TX_ISOC_BASE; |
---|
1320 | | setRXTXfuncs (Streaming::Port::E_Capture); |
---|
1321 | | } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { |
---|
1322 | | n=i-m_receiveProcessors.size(); |
---|
1323 | | p=m_transmitProcessors.at(n); |
---|
1324 | | base_address = DICE_REGISTER_RX_ISOC_BASE; |
---|
1325 | | setRXTXfuncs (Streaming::Port::E_Playback); |
---|
1326 | | } else { |
---|
1327 | | debugError("SP index %d out of range!\n",i); |
---|
1328 | | return false; |
---|
1329 | | } |
---|
1330 | | |
---|
1331 | | if(!snoopMode) { |
---|
1332 | | unsigned int isochannel = p->getChannel(); |
---|
1333 | | |
---|
1334 | | fb_quadlet_t reg_isoch; |
---|
1335 | | // check value of ISO_CHANNEL register |
---|
1336 | | if(!(*this.*readFunc)(n, base_address, ®_isoch)) { |
---|
1337 | | debugError("Could not read ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
1338 | | return false; |
---|
1339 | | } |
---|
1340 | | if(reg_isoch != isochannel) { |
---|
1341 | | debugError("ISO_CHANNEL register != 0x%08"PRIX32" (=0x%08"PRIX32") for A%s %d\n", isochannel, reg_isoch, dir, n); |
---|
1342 | | return false; |
---|
1343 | | } |
---|
1344 | | |
---|
1345 | | // write value of ISO_CHANNEL register |
---|
1346 | | reg_isoch=0xFFFFFFFFUL; |
---|
1347 | | if(!writeTxReg(n, base_address, reg_isoch)) { |
---|
1348 | | debugError("Could not write ISO_CHANNEL register for A%s %d\n", dir, n); |
---|
1349 | | return false; |
---|
1350 | | } |
---|
1351 | | |
---|
1352 | | // deallocate ISO channel |
---|
1353 | | if(!deallocateIsoChannel(isochannel)) { |
---|
1354 | | debugError("Could not deallocate iso channel for SP %d (A%s %d)\n",i, dir, n); |
---|
1355 | | return false; |
---|
1356 | | } |
---|
1357 | | } |
---|
1358 | | p->setChannel(-1); |
---|
1359 | | return true; |
---|
| 1339 | return startstopStreamByIndex(i, false); // stop stream |
---|