235 | | switch ( samplingFrequency ) { |
---|
236 | | default: |
---|
237 | | case 22050: |
---|
238 | | case 24000: |
---|
239 | | supported=false; |
---|
240 | | break; |
---|
241 | | case 32000: |
---|
242 | | supported=maskedCheckNotZeroGlobalReg( |
---|
243 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
244 | | DICE_CLOCKCAP_RATE_32K); |
---|
245 | | select=DICE_RATE_32K; |
---|
246 | | break; |
---|
247 | | case 44100: |
---|
248 | | supported=maskedCheckNotZeroGlobalReg( |
---|
249 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
250 | | DICE_CLOCKCAP_RATE_44K1); |
---|
251 | | select=DICE_RATE_44K1; |
---|
252 | | break; |
---|
253 | | case 48000: |
---|
254 | | supported=maskedCheckNotZeroGlobalReg( |
---|
255 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
256 | | DICE_CLOCKCAP_RATE_48K); |
---|
257 | | select=DICE_RATE_48K; |
---|
258 | | break; |
---|
259 | | case 88200: |
---|
260 | | supported=maskedCheckNotZeroGlobalReg( |
---|
261 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
262 | | DICE_CLOCKCAP_RATE_88K2); |
---|
263 | | select=DICE_RATE_88K2; |
---|
264 | | break; |
---|
265 | | case 96000: |
---|
266 | | supported=maskedCheckNotZeroGlobalReg( |
---|
267 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
268 | | DICE_CLOCKCAP_RATE_96K); |
---|
269 | | select=DICE_RATE_96K; |
---|
270 | | break; |
---|
271 | | case 176400: |
---|
272 | | supported=maskedCheckNotZeroGlobalReg( |
---|
273 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
274 | | DICE_CLOCKCAP_RATE_176K4); |
---|
275 | | select=DICE_RATE_176K4; |
---|
276 | | break; |
---|
277 | | case 192000: |
---|
278 | | supported=maskedCheckNotZeroGlobalReg( |
---|
279 | | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
280 | | DICE_CLOCKCAP_RATE_192K); |
---|
281 | | select=DICE_RATE_192K; |
---|
282 | | break; |
---|
283 | | } |
---|
284 | | |
---|
285 | | if (!supported) { |
---|
286 | | debugWarning("Unsupported sample rate: %d\n", (samplingFrequency)); |
---|
287 | | return false; |
---|
288 | | } |
---|
289 | | |
---|
290 | | if (isIsoStreamingEnabled()) { |
---|
291 | | debugError("Cannot change samplerate while streaming is enabled\n"); |
---|
292 | | return false; |
---|
293 | | } |
---|
294 | | |
---|
295 | | fb_quadlet_t clockreg; |
---|
296 | | if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { |
---|
297 | | debugError("Could not read CLOCK_SELECT register\n"); |
---|
298 | | return false; |
---|
299 | | } |
---|
300 | | |
---|
301 | | clockreg = DICE_SET_RATE(clockreg, select); |
---|
302 | | |
---|
303 | | if (!writeGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, clockreg)) { |
---|
304 | | debugError("Could not write CLOCK_SELECT register\n"); |
---|
305 | | return false; |
---|
306 | | } |
---|
307 | | |
---|
308 | | // check if the write succeeded |
---|
309 | | fb_quadlet_t clockreg_verify; |
---|
310 | | if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg_verify)) { |
---|
311 | | debugError("Could not read CLOCK_SELECT register\n"); |
---|
312 | | return false; |
---|
313 | | } |
---|
314 | | |
---|
315 | | if(clockreg != clockreg_verify) { |
---|
316 | | debugError("Samplerate register write failed\n"); |
---|
317 | | return false; |
---|
318 | | } |
---|
319 | | |
---|
| 239 | bool snoopMode = false; |
---|
| 240 | if(!getOption("snoopMode", snoopMode)) { |
---|
| 241 | debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
| 242 | } |
---|
| 243 | |
---|
| 244 | if(snoopMode) { |
---|
| 245 | int current_sr = getSamplingFrequency(); |
---|
| 246 | if (current_sr != samplingFrequency ) { |
---|
| 247 | debugError("In snoop mode it is impossible to set the sample rate.\n"); |
---|
| 248 | debugError("Please start the client with the correct setting.\n"); |
---|
| 249 | return false; |
---|
| 250 | } |
---|
| 251 | return true; |
---|
| 252 | } else { |
---|
| 253 | switch ( samplingFrequency ) { |
---|
| 254 | default: |
---|
| 255 | case 22050: |
---|
| 256 | case 24000: |
---|
| 257 | supported=false; |
---|
| 258 | break; |
---|
| 259 | case 32000: |
---|
| 260 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 261 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 262 | DICE_CLOCKCAP_RATE_32K); |
---|
| 263 | select=DICE_RATE_32K; |
---|
| 264 | break; |
---|
| 265 | case 44100: |
---|
| 266 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 267 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 268 | DICE_CLOCKCAP_RATE_44K1); |
---|
| 269 | select=DICE_RATE_44K1; |
---|
| 270 | break; |
---|
| 271 | case 48000: |
---|
| 272 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 273 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 274 | DICE_CLOCKCAP_RATE_48K); |
---|
| 275 | select=DICE_RATE_48K; |
---|
| 276 | break; |
---|
| 277 | case 88200: |
---|
| 278 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 279 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 280 | DICE_CLOCKCAP_RATE_88K2); |
---|
| 281 | select=DICE_RATE_88K2; |
---|
| 282 | break; |
---|
| 283 | case 96000: |
---|
| 284 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 285 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 286 | DICE_CLOCKCAP_RATE_96K); |
---|
| 287 | select=DICE_RATE_96K; |
---|
| 288 | break; |
---|
| 289 | case 176400: |
---|
| 290 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 291 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 292 | DICE_CLOCKCAP_RATE_176K4); |
---|
| 293 | select=DICE_RATE_176K4; |
---|
| 294 | break; |
---|
| 295 | case 192000: |
---|
| 296 | supported=maskedCheckNotZeroGlobalReg( |
---|
| 297 | DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, |
---|
| 298 | DICE_CLOCKCAP_RATE_192K); |
---|
| 299 | select=DICE_RATE_192K; |
---|
| 300 | break; |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | if (!supported) { |
---|
| 304 | debugWarning("Unsupported sample rate: %d\n", (samplingFrequency)); |
---|
| 305 | return false; |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | if (isIsoStreamingEnabled()) { |
---|
| 309 | debugError("Cannot change samplerate while streaming is enabled\n"); |
---|
| 310 | return false; |
---|
| 311 | } |
---|
| 312 | |
---|
| 313 | fb_quadlet_t clockreg; |
---|
| 314 | if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { |
---|
| 315 | debugError("Could not read CLOCK_SELECT register\n"); |
---|
| 316 | return false; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | clockreg = DICE_SET_RATE(clockreg, select); |
---|
| 320 | |
---|
| 321 | if (!writeGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, clockreg)) { |
---|
| 322 | debugError("Could not write CLOCK_SELECT register\n"); |
---|
| 323 | return false; |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | // check if the write succeeded |
---|
| 327 | fb_quadlet_t clockreg_verify; |
---|
| 328 | if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg_verify)) { |
---|
| 329 | debugError("Could not read CLOCK_SELECT register\n"); |
---|
| 330 | return false; |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | if(clockreg != clockreg_verify) { |
---|
| 334 | debugError("Samplerate register write failed\n"); |
---|
| 335 | return false; |
---|
| 336 | } |
---|
| 337 | } |
---|
| 710 | fb_quadlet_t nb_audio; |
---|
| 711 | fb_quadlet_t nb_midi; |
---|
| 712 | unsigned int nb_channels = 0; |
---|
| 713 | |
---|
| 714 | bool snoopMode = false; |
---|
| 715 | if(!getOption("snoopMode", snoopMode)) { |
---|
| 716 | debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | // get the device specific and/or global SP configuration |
---|
| 720 | Util::Configuration &config = getDeviceManager().getConfiguration(); |
---|
| 721 | // base value is the config.h value |
---|
| 722 | float recv_sp_dll_bw = STREAMPROCESSOR_DLL_BW_HZ; |
---|
| 723 | float xmit_sp_dll_bw = STREAMPROCESSOR_DLL_BW_HZ; |
---|
| 724 | |
---|
| 725 | int xmit_max_cycles_early_transmit = AMDTP_MAX_CYCLES_TO_TRANSMIT_EARLY; |
---|
| 726 | int xmit_transfer_delay = AMDTP_TRANSMIT_TRANSFER_DELAY; |
---|
| 727 | int xmit_min_cycles_before_presentation = AMDTP_MIN_CYCLES_BEFORE_PRESENTATION; |
---|
| 728 | |
---|
| 729 | // we can override that globally |
---|
| 730 | config.getValueForSetting("streaming.common.recv_sp_dll_bw", recv_sp_dll_bw); |
---|
| 731 | config.getValueForSetting("streaming.common.xmit_sp_dll_bw", xmit_sp_dll_bw); |
---|
| 732 | config.getValueForSetting("streaming.amdtp.xmit_max_cycles_early_transmit", xmit_max_cycles_early_transmit); |
---|
| 733 | config.getValueForSetting("streaming.amdtp.xmit_transfer_delay", xmit_transfer_delay); |
---|
| 734 | config.getValueForSetting("streaming.amdtp.xmit_min_cycles_before_presentation", xmit_min_cycles_before_presentation); |
---|
| 735 | |
---|
| 736 | // or override in the device section |
---|
| 737 | uint32_t vendorid = getConfigRom().getNodeVendorId(); |
---|
| 738 | uint32_t modelid = getConfigRom().getModelId(); |
---|
| 739 | config.getValueForDeviceSetting(vendorid, modelid, "recv_sp_dll_bw", recv_sp_dll_bw); |
---|
| 740 | config.getValueForDeviceSetting(vendorid, modelid, "xmit_sp_dll_bw", xmit_sp_dll_bw); |
---|
| 741 | config.getValueForDeviceSetting(vendorid, modelid, "xmit_max_cycles_early_transmit", xmit_max_cycles_early_transmit); |
---|
| 742 | config.getValueForDeviceSetting(vendorid, modelid, "xmit_transfer_delay", xmit_transfer_delay); |
---|
| 743 | config.getValueForDeviceSetting(vendorid, modelid, "xmit_min_cycles_before_presentation", xmit_min_cycles_before_presentation); |
---|
| 744 | |
---|
| 745 | diceNameVector names_audio; |
---|
| 746 | diceNameVector names_midi; |
---|
834 | | // construct the streamprocessor |
---|
835 | | Streaming::AmdtpTransmitStreamProcessor *p; |
---|
836 | | p=new Streaming::AmdtpTransmitStreamProcessor(*this, |
---|
837 | | nb_channels); |
---|
| 894 | enum Streaming::Port::E_Direction port_type; |
---|
| 895 | float dll_bw; |
---|
| 896 | if (snoopMode) { |
---|
| 897 | // we are snooping, so this is receive too. |
---|
| 898 | p = new Streaming::AmdtpReceiveStreamProcessor(*this, nb_channels); |
---|
| 899 | port_type = Streaming::Port::E_Capture; |
---|
| 900 | dll_bw = recv_sp_dll_bw; |
---|
| 901 | } else { |
---|
| 902 | // this is a normal situation |
---|
| 903 | Streaming::AmdtpTransmitStreamProcessor *t; |
---|
| 904 | t = new Streaming::AmdtpTransmitStreamProcessor(*this, nb_channels); |
---|
| 905 | #if AMDTP_ALLOW_PAYLOAD_IN_NODATA_XMIT |
---|
| 906 | // the DICE-II cannot handle payload in the NO-DATA packets. |
---|
| 907 | // the other DICE chips don't need payload. Therefore |
---|
| 908 | // we disable it. |
---|
| 909 | t->sendPayloadForNoDataPackets(false); |
---|
| 910 | #endif |
---|
| 911 | |
---|
| 912 | // transmit control parameters |
---|
| 913 | t->setMaxCyclesToTransmitEarly(xmit_max_cycles_early_transmit); |
---|
| 914 | t->setTransferDelay(xmit_transfer_delay); |
---|
| 915 | t->setMinCyclesBeforePresentation(xmit_min_cycles_before_presentation); |
---|
| 916 | |
---|
| 917 | p = t; |
---|
| 918 | port_type = Streaming::Port::E_Playback; |
---|
| 919 | dll_bw = xmit_sp_dll_bw; |
---|
| 920 | } |
---|
952 | | nodeaddr_t notify_address; |
---|
953 | | notify_address = get1394Service().findFreeARMBlock( |
---|
954 | | DICE_NOTIFIER_BASE_ADDRESS, |
---|
955 | | DICE_NOTIFIER_BLOCK_LENGTH, |
---|
956 | | DICE_NOTIFIER_BLOCK_LENGTH); |
---|
957 | | |
---|
958 | | if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { |
---|
959 | | debugError("Could not find free ARM block for notification\n"); |
---|
960 | | return false; |
---|
961 | | } |
---|
962 | | |
---|
963 | | m_notifier=new DiceAvDevice::DiceNotifier(this, notify_address); |
---|
964 | | |
---|
965 | | if(!m_notifier) { |
---|
966 | | debugError("Could not allocate notifier\n"); |
---|
967 | | return false; |
---|
968 | | } |
---|
969 | | |
---|
970 | | if (!get1394Service().registerARMHandler(m_notifier)) { |
---|
971 | | debugError("Could not register notifier\n"); |
---|
| 1053 | nodeaddr_t notify_address; |
---|
| 1054 | notify_address = get1394Service().findFreeARMBlock( |
---|
| 1055 | DICE_NOTIFIER_BASE_ADDRESS, |
---|
| 1056 | DICE_NOTIFIER_BLOCK_LENGTH, |
---|
| 1057 | DICE_NOTIFIER_BLOCK_LENGTH); |
---|
| 1058 | |
---|
| 1059 | if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { |
---|
| 1060 | debugError("Could not find free ARM block for notification\n"); |
---|
| 1061 | return false; |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | m_notifier=new DiceAvDevice::DiceNotifier(this, notify_address); |
---|
| 1065 | |
---|
| 1066 | if(!m_notifier) { |
---|
| 1067 | debugError("Could not allocate notifier\n"); |
---|
| 1068 | return false; |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | if (!get1394Service().registerARMHandler(m_notifier)) { |
---|
| 1072 | debugError("Could not register notifier\n"); |
---|
| 1073 | delete m_notifier; |
---|
| 1074 | m_notifier=NULL; |
---|
| 1075 | return false; |
---|
| 1076 | } |
---|
| 1077 | |
---|
| 1078 | // register this notifier |
---|
| 1079 | fb_nodeaddr_t addr = DICE_REGISTER_BASE |
---|
| 1080 | + m_global_reg_offset |
---|
| 1081 | + DICE_REGISTER_GLOBAL_OWNER; |
---|
| 1082 | |
---|
| 1083 | // registry offsets should always be smaller than 0x7FFFFFFF |
---|
| 1084 | // because otherwise base + offset > 64bit |
---|
| 1085 | if(m_global_reg_offset & 0x80000000) { |
---|
| 1086 | debugError("register offset not initialized yet\n"); |
---|
| 1087 | return false; |
---|
| 1088 | } |
---|
| 1089 | |
---|
| 1090 | fb_nodeaddr_t swap_value = ((0xFFC0) | get1394Service().getLocalNodeId()); |
---|
| 1091 | swap_value = swap_value << 48; |
---|
| 1092 | swap_value |= m_notifier->getStart(); |
---|
| 1093 | |
---|
| 1094 | if (!get1394Service().lockCompareSwap64(getNodeId() | 0xFFC0, |
---|
| 1095 | addr, DICE_OWNER_NO_OWNER, |
---|
| 1096 | swap_value, &result )) { |
---|
| 1097 | debugWarning("Could not register ourselves as device owner\n"); |
---|
| 1098 | return false; |
---|
| 1099 | } |
---|
| 1100 | |
---|
| 1101 | if (result != DICE_OWNER_NO_OWNER) { |
---|
| 1102 | debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016llX\n", result); |
---|
| 1103 | return false; |
---|
| 1104 | } |
---|
| 1105 | |
---|
| 1106 | return true; |
---|
| 1107 | } |
---|
| 1108 | } |
---|
| 1109 | |
---|
| 1110 | |
---|
| 1111 | bool |
---|
| 1112 | DiceAvDevice::unlock() { |
---|
| 1113 | fb_octlet_t result; |
---|
| 1114 | |
---|
| 1115 | bool snoopMode = false; |
---|
| 1116 | if(!getOption("snoopMode", snoopMode)) { |
---|
| 1117 | debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | if (snoopMode) { |
---|
| 1121 | debugWarning("Unlock not supported in snoop mode\n"); |
---|
| 1122 | return true; //FIXME: this should be false |
---|
| 1123 | } else { |
---|
| 1124 | if(!m_notifier) { |
---|
| 1125 | debugWarning("Request to unlock, but no notifier present!\n"); |
---|
| 1126 | return false; |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | fb_nodeaddr_t addr = DICE_REGISTER_BASE |
---|
| 1130 | + m_global_reg_offset |
---|
| 1131 | + DICE_REGISTER_GLOBAL_OWNER; |
---|
| 1132 | |
---|
| 1133 | // registry offsets should always be smaller than 0x7FFFFFFF |
---|
| 1134 | // because otherwise base + offset > 64bit |
---|
| 1135 | if(m_global_reg_offset & 0x80000000) { |
---|
| 1136 | debugError("register offset not initialized yet\n"); |
---|
| 1137 | return false; |
---|
| 1138 | } |
---|
| 1139 | |
---|
| 1140 | fb_nodeaddr_t compare_value = ((0xFFC0) | get1394Service().getLocalNodeId()); |
---|
| 1141 | compare_value <<= 48; |
---|
| 1142 | compare_value |= m_notifier->getStart(); |
---|
| 1143 | |
---|
| 1144 | if (!get1394Service().lockCompareSwap64( getNodeId() | 0xFFC0, addr, compare_value, |
---|
| 1145 | DICE_OWNER_NO_OWNER, &result )) { |
---|
| 1146 | debugWarning("Could not unregister ourselves as device owner\n"); |
---|
| 1147 | return false; |
---|
| 1148 | } |
---|
| 1149 | |
---|
| 1150 | get1394Service().unregisterARMHandler(m_notifier); |
---|
974 | | return false; |
---|
975 | | } |
---|
976 | | |
---|
977 | | // register this notifier |
---|
978 | | fb_nodeaddr_t addr = DICE_REGISTER_BASE |
---|
979 | | + m_global_reg_offset |
---|
980 | | + DICE_REGISTER_GLOBAL_OWNER; |
---|
981 | | |
---|
982 | | // registry offsets should always be smaller than 0x7FFFFFFF |
---|
983 | | // because otherwise base + offset > 64bit |
---|
984 | | if(m_global_reg_offset & 0x80000000) { |
---|
985 | | debugError("register offset not initialized yet\n"); |
---|
986 | | return false; |
---|
987 | | } |
---|
988 | | |
---|
989 | | fb_nodeaddr_t swap_value = ((0xFFC0) | get1394Service().getLocalNodeId()); |
---|
990 | | swap_value = swap_value << 48; |
---|
991 | | swap_value |= m_notifier->getStart(); |
---|
992 | | |
---|
993 | | if (!get1394Service().lockCompareSwap64(getNodeId() | 0xFFC0, |
---|
994 | | addr, DICE_OWNER_NO_OWNER, |
---|
995 | | swap_value, &result )) { |
---|
996 | | debugWarning("Could not register ourselves as device owner\n"); |
---|
997 | | return false; |
---|
998 | | } |
---|
999 | | |
---|
1000 | | if (result != DICE_OWNER_NO_OWNER) { |
---|
1001 | | debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016llX\n", result); |
---|
1002 | | return false; |
---|
1003 | | } |
---|
1004 | | |
---|
1005 | | return true; |
---|
1006 | | } |
---|
1007 | | |
---|
1008 | | |
---|
1009 | | bool |
---|
1010 | | DiceAvDevice::unlock() { |
---|
1011 | | fb_octlet_t result; |
---|
1012 | | |
---|
1013 | | if(!m_notifier) { |
---|
1014 | | debugWarning("Request to unlock, but no notifier present!\n"); |
---|
1015 | | return false; |
---|
1016 | | } |
---|
1017 | | |
---|
1018 | | fb_nodeaddr_t addr = DICE_REGISTER_BASE |
---|
1019 | | + m_global_reg_offset |
---|
1020 | | + DICE_REGISTER_GLOBAL_OWNER; |
---|
1021 | | |
---|
1022 | | // registry offsets should always be smaller than 0x7FFFFFFF |
---|
1023 | | // because otherwise base + offset > 64bit |
---|
1024 | | if(m_global_reg_offset & 0x80000000) { |
---|
1025 | | debugError("register offset not initialized yet\n"); |
---|
1026 | | return false; |
---|
1027 | | } |
---|
1028 | | |
---|
1029 | | fb_nodeaddr_t compare_value = ((0xFFC0) | get1394Service().getLocalNodeId()); |
---|
1030 | | compare_value <<= 48; |
---|
1031 | | compare_value |= m_notifier->getStart(); |
---|
1032 | | |
---|
1033 | | if (!get1394Service().lockCompareSwap64( getNodeId() | 0xFFC0, addr, compare_value, |
---|
1034 | | DICE_OWNER_NO_OWNER, &result )) { |
---|
1035 | | debugWarning("Could not unregister ourselves as device owner\n"); |
---|
1036 | | return false; |
---|
1037 | | } |
---|
1038 | | |
---|
1039 | | get1394Service().unregisterARMHandler(m_notifier); |
---|
1040 | | delete m_notifier; |
---|
1041 | | m_notifier=NULL; |
---|
1042 | | |
---|
1043 | | return true; |
---|
| 1153 | |
---|
| 1154 | return true; |
---|
| 1155 | } |
---|
| 1214 | return false; |
---|
| 1215 | } |
---|
| 1216 | |
---|
| 1217 | if (i<(int)m_receiveProcessors.size()) { |
---|
| 1218 | int n=i; |
---|
| 1219 | Streaming::StreamProcessor *p = m_receiveProcessors.at(n); |
---|
| 1220 | |
---|
| 1221 | if(snoopMode) { // a stream from the device to another host |
---|
| 1222 | fb_quadlet_t reg_isoch; |
---|
| 1223 | // check value of ISO_CHANNEL register |
---|
| 1224 | if(!readTxReg(n, DICE_REGISTER_TX_ISOC_BASE, ®_isoch)) { |
---|
| 1225 | debugError("Could not read ISO_CHANNEL register for ATX %d\n", n); |
---|
| 1226 | p->setChannel(-1); |
---|
| 1227 | return false; |
---|
| 1228 | } |
---|
| 1229 | int isochannel = reg_isoch; |
---|
| 1230 | debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Snooping RX from channel %d\n", isochannel); |
---|
| 1231 | p->setChannel(isochannel); |
---|
| 1232 | } else { |
---|
| 1233 | // allocate ISO channel |
---|
| 1234 | int isochannel = allocateIsoChannel(p->getMaxPacketSize()); |
---|
| 1235 | if(isochannel<0) { |
---|
| 1236 | debugError("Could not allocate iso channel for SP %d (ATX %d)\n",i,n); |
---|
| 1237 | return false; |
---|
| 1238 | } |
---|
| 1239 | debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Allocated channel %lu for RX\n", isochannel); |
---|
| 1240 | p->setChannel(isochannel); |
---|
| 1241 | |
---|
| 1242 | fb_quadlet_t reg_isoch; |
---|
| 1243 | // check value of ISO_CHANNEL register |
---|
| 1244 | if(!readTxReg(n, DICE_REGISTER_TX_ISOC_BASE, ®_isoch)) { |
---|
| 1245 | debugError("Could not read ISO_CHANNEL register for ATX %d\n", n); |
---|
| 1246 | p->setChannel(-1); |
---|
| 1247 | deallocateIsoChannel(isochannel); |
---|
| 1248 | return false; |
---|
| 1249 | } |
---|
| 1250 | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
| 1251 | debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ATX %d\n", reg_isoch, n); |
---|
| 1252 | p->setChannel(-1); |
---|
| 1253 | deallocateIsoChannel(isochannel); |
---|
| 1254 | return false; |
---|
| 1255 | } |
---|
| 1256 | |
---|
| 1257 | // write value of ISO_CHANNEL register |
---|
| 1258 | reg_isoch = isochannel; |
---|
| 1259 | if(!writeTxReg(n, DICE_REGISTER_TX_ISOC_BASE, reg_isoch)) { |
---|
| 1260 | debugError("Could not write ISO_CHANNEL register for ATX %d\n", n); |
---|
| 1261 | p->setChannel(-1); |
---|
| 1262 | deallocateIsoChannel(isochannel); |
---|
| 1263 | return false; |
---|
| 1264 | } |
---|
| 1265 | } |
---|
| 1266 | return true; |
---|
| 1267 | |
---|
| 1268 | } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { |
---|
| 1269 | int n=i-m_receiveProcessors.size(); |
---|
| 1270 | Streaming::StreamProcessor *p=m_transmitProcessors.at(n); |
---|
| 1271 | |
---|
| 1272 | if(snoopMode) { // a stream from the device to another host |
---|
| 1273 | fb_quadlet_t reg_isoch; |
---|
| 1274 | // check value of ISO_CHANNEL register |
---|
| 1275 | if(!readRxReg(n, DICE_REGISTER_RX_ISOC_BASE, ®_isoch)) { |
---|
| 1276 | debugError("Could not read ISO_CHANNEL register for ARX %d\n", n); |
---|
| 1277 | p->setChannel(-1); |
---|
| 1278 | return false; |
---|
| 1279 | } |
---|
| 1280 | int isochannel = reg_isoch; |
---|
| 1281 | debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Snooping TX from channel %d\n", isochannel); |
---|
| 1282 | p->setChannel(isochannel); |
---|
| 1283 | } else { |
---|
| 1284 | // allocate ISO channel |
---|
| 1285 | int isochannel = allocateIsoChannel(p->getMaxPacketSize()); |
---|
| 1286 | if(isochannel<0) { |
---|
| 1287 | debugError("Could not allocate iso channel for SP %d (ARX %d)\n",i,n); |
---|
| 1288 | return false; |
---|
| 1289 | } |
---|
| 1290 | debugOutput(DEBUG_LEVEL_VERBOSE, "(%p) Allocated channel %lu for TX\n", isochannel); |
---|
| 1291 | p->setChannel(isochannel); |
---|
| 1292 | |
---|
| 1293 | fb_quadlet_t reg_isoch; |
---|
| 1294 | // check value of ISO_CHANNEL register |
---|
| 1295 | if(!readRxReg(n, DICE_REGISTER_RX_ISOC_BASE, ®_isoch)) { |
---|
| 1296 | debugError("Could not read ISO_CHANNEL register for ARX %d\n", n); |
---|
| 1297 | p->setChannel(-1); |
---|
| 1298 | deallocateIsoChannel(isochannel); |
---|
| 1299 | return false; |
---|
| 1300 | } |
---|
| 1301 | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
| 1302 | debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ARX %d\n", reg_isoch, n); |
---|
| 1303 | p->setChannel(-1); |
---|
| 1304 | deallocateIsoChannel(isochannel); |
---|
| 1305 | return false; |
---|
| 1306 | } |
---|
| 1307 | |
---|
| 1308 | // write value of ISO_CHANNEL register |
---|
| 1309 | reg_isoch=isochannel; |
---|
| 1310 | if(!writeRxReg(n, DICE_REGISTER_RX_ISOC_BASE, reg_isoch)) { |
---|
| 1311 | debugError("Could not write ISO_CHANNEL register for ARX %d\n", n); |
---|
| 1312 | p->setChannel(-1); |
---|
| 1313 | deallocateIsoChannel(isochannel); |
---|
| 1314 | return false; |
---|
| 1315 | } |
---|
| 1316 | } |
---|
| 1317 | return true; |
---|
| 1318 | } |
---|
| 1319 | |
---|
| 1320 | debugError("SP index %d out of range!\n",i); |
---|
| 1321 | return false; |
---|
| 1322 | } |
---|
| 1323 | |
---|
| 1324 | bool |
---|
| 1325 | DiceAvDevice::stopStreamByIndex(int i) { |
---|
| 1326 | bool snoopMode = false; |
---|
| 1327 | if(!getOption("snoopMode", snoopMode)) { |
---|
| 1328 | debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); |
---|
| 1329 | } |
---|
| 1330 | |
---|
| 1331 | if (!snoopMode && isIsoStreamingEnabled()) { |
---|
| 1332 | debugError("Cannot stop streams while streaming is enabled\n"); |
---|
1084 | | |
---|
1085 | | // allocate ISO channel |
---|
1086 | | int isochannel=allocateIsoChannel(p->getMaxPacketSize()); |
---|
1087 | | if(isochannel<0) { |
---|
1088 | | debugError("Could not allocate iso channel for SP %d (ATX %d)\n",i,n); |
---|
1089 | | return false; |
---|
1090 | | } |
---|
1091 | | p->setChannel(isochannel); |
---|
1092 | | |
---|
1093 | | fb_quadlet_t reg_isoch; |
---|
1094 | | // check value of ISO_CHANNEL register |
---|
1095 | | if(!readTxReg(n, DICE_REGISTER_TX_ISOC_BASE, ®_isoch)) { |
---|
1096 | | debugError("Could not read ISO_CHANNEL register for ATX %d\n", n); |
---|
1097 | | p->setChannel(-1); |
---|
1098 | | deallocateIsoChannel(isochannel); |
---|
1099 | | return false; |
---|
1100 | | } |
---|
1101 | | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
1102 | | debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ATX %d\n", reg_isoch, n); |
---|
1103 | | p->setChannel(-1); |
---|
1104 | | deallocateIsoChannel(isochannel); |
---|
1105 | | return false; |
---|
1106 | | } |
---|
1107 | | |
---|
1108 | | // write value of ISO_CHANNEL register |
---|
1109 | | reg_isoch=isochannel; |
---|
1110 | | if(!writeTxReg(n, DICE_REGISTER_TX_ISOC_BASE, reg_isoch)) { |
---|
1111 | | debugError("Could not write ISO_CHANNEL register for ATX %d\n", n); |
---|
1112 | | p->setChannel(-1); |
---|
1113 | | deallocateIsoChannel(isochannel); |
---|
1114 | | return false; |
---|
1115 | | } |
---|
1116 | | |
---|
| 1339 | if(snoopMode) { // a stream from the device to another host |
---|
| 1340 | // nothing to do |
---|
| 1341 | } else { |
---|
| 1342 | unsigned int isochannel = p->getChannel(); |
---|
| 1343 | |
---|
| 1344 | fb_quadlet_t reg_isoch; |
---|
| 1345 | // check value of ISO_CHANNEL register |
---|
| 1346 | if(!readTxReg(n, DICE_REGISTER_TX_ISOC_BASE, ®_isoch)) { |
---|
| 1347 | debugError("Could not read ISO_CHANNEL register for ATX %d\n", n); |
---|
| 1348 | return false; |
---|
| 1349 | } |
---|
| 1350 | if(reg_isoch != isochannel) { |
---|
| 1351 | debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ATX %d\n", isochannel, reg_isoch, n); |
---|
| 1352 | return false; |
---|
| 1353 | } |
---|
| 1354 | |
---|
| 1355 | // write value of ISO_CHANNEL register |
---|
| 1356 | reg_isoch=0xFFFFFFFFUL; |
---|
| 1357 | if(!writeTxReg(n, DICE_REGISTER_TX_ISOC_BASE, reg_isoch)) { |
---|
| 1358 | debugError("Could not write ISO_CHANNEL register for ATX %d\n", n); |
---|
| 1359 | return false; |
---|
| 1360 | } |
---|
| 1361 | |
---|
| 1362 | // deallocate ISO channel |
---|
| 1363 | if(!deallocateIsoChannel(isochannel)) { |
---|
| 1364 | debugError("Could not deallocate iso channel for SP %d (ATX %d)\n",i,n); |
---|
| 1365 | return false; |
---|
| 1366 | } |
---|
| 1367 | } |
---|
| 1368 | p->setChannel(-1); |
---|
1123 | | // allocate ISO channel |
---|
1124 | | int isochannel=allocateIsoChannel(p->getMaxPacketSize()); |
---|
1125 | | if(isochannel<0) { |
---|
1126 | | debugError("Could not allocate iso channel for SP %d (ARX %d)\n",i,n); |
---|
1127 | | return false; |
---|
1128 | | } |
---|
1129 | | p->setChannel(isochannel); |
---|
1130 | | |
---|
1131 | | fb_quadlet_t reg_isoch; |
---|
1132 | | // check value of ISO_CHANNEL register |
---|
1133 | | if(!readRxReg(n, DICE_REGISTER_RX_ISOC_BASE, ®_isoch)) { |
---|
1134 | | debugError("Could not read ISO_CHANNEL register for ARX %d\n", n); |
---|
1135 | | p->setChannel(-1); |
---|
1136 | | deallocateIsoChannel(isochannel); |
---|
1137 | | return false; |
---|
1138 | | } |
---|
1139 | | if(reg_isoch != 0xFFFFFFFFUL) { |
---|
1140 | | debugError("ISO_CHANNEL register != 0xFFFFFFFF (=0x%08X) for ARX %d\n", reg_isoch, n); |
---|
1141 | | p->setChannel(-1); |
---|
1142 | | deallocateIsoChannel(isochannel); |
---|
1143 | | return false; |
---|
1144 | | } |
---|
1145 | | |
---|
1146 | | // write value of ISO_CHANNEL register |
---|
1147 | | reg_isoch=isochannel; |
---|
1148 | | if(!writeRxReg(n, DICE_REGISTER_RX_ISOC_BASE, reg_isoch)) { |
---|
1149 | | debugError("Could not write ISO_CHANNEL register for ARX %d\n", n); |
---|
1150 | | p->setChannel(-1); |
---|
1151 | | deallocateIsoChannel(isochannel); |
---|
1152 | | return false; |
---|
1153 | | } |
---|
1154 | | |
---|
1155 | | return true; |
---|
1156 | | } |
---|
1157 | | |
---|
1158 | | debugError("SP index %d out of range!\n",i); |
---|
1159 | | |
---|
1160 | | return false; |
---|
1161 | | } |
---|
1162 | | |
---|
1163 | | bool |
---|
1164 | | DiceAvDevice::stopStreamByIndex(int i) { |
---|
1165 | | |
---|
1166 | | if (isIsoStreamingEnabled()) { |
---|
1167 | | debugError("Cannot stop streams while streaming is enabled\n"); |
---|
1168 | | return false; |
---|
1169 | | } |
---|
1170 | | |
---|
1171 | | if (i<(int)m_receiveProcessors.size()) { |
---|
1172 | | int n=i; |
---|
1173 | | Streaming::StreamProcessor *p=m_receiveProcessors.at(n); |
---|
1174 | | unsigned int isochannel=p->getChannel(); |
---|
1175 | | |
---|
1176 | | fb_quadlet_t reg_isoch; |
---|
1177 | | // check value of ISO_CHANNEL register |
---|
1178 | | if(!readTxReg(n, DICE_REGISTER_TX_ISOC_BASE, ®_isoch)) { |
---|
1179 | | debugError("Could not read ISO_CHANNEL register for ATX %d\n", n); |
---|
1180 | | return false; |
---|
1181 | | } |
---|
1182 | | if(reg_isoch != isochannel) { |
---|
1183 | | debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ATX %d\n", isochannel, reg_isoch, n); |
---|
1184 | | return false; |
---|
1185 | | } |
---|
1186 | | |
---|
1187 | | // write value of ISO_CHANNEL register |
---|
1188 | | reg_isoch=0xFFFFFFFFUL; |
---|
1189 | | if(!writeTxReg(n, DICE_REGISTER_TX_ISOC_BASE, reg_isoch)) { |
---|
1190 | | debugError("Could not write ISO_CHANNEL register for ATX %d\n", n); |
---|
1191 | | return false; |
---|
1192 | | } |
---|
1193 | | |
---|
1194 | | // deallocate ISO channel |
---|
1195 | | if(!deallocateIsoChannel(isochannel)) { |
---|
1196 | | debugError("Could not deallocate iso channel for SP %d (ATX %d)\n",i,n); |
---|
1197 | | return false; |
---|
1198 | | } |
---|
1199 | | |
---|
1200 | | p->setChannel(-1); |
---|
1201 | | return true; |
---|
1202 | | |
---|
1203 | | } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { |
---|
1204 | | int n=i-m_receiveProcessors.size(); |
---|
1205 | | Streaming::StreamProcessor *p=m_transmitProcessors.at(n); |
---|
1206 | | |
---|
1207 | | unsigned int isochannel=p->getChannel(); |
---|
1208 | | |
---|
1209 | | fb_quadlet_t reg_isoch; |
---|
1210 | | // check value of ISO_CHANNEL register |
---|
1211 | | if(!readRxReg(n, DICE_REGISTER_RX_ISOC_BASE, ®_isoch)) { |
---|
1212 | | debugError("Could not read ISO_CHANNEL register for ARX %d\n", n); |
---|
1213 | | return false; |
---|
1214 | | } |
---|
1215 | | if(reg_isoch != isochannel) { |
---|
1216 | | debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ARX %d\n", isochannel, reg_isoch, n); |
---|
1217 | | return false; |
---|
1218 | | } |
---|
1219 | | |
---|
1220 | | // write value of ISO_CHANNEL register |
---|
1221 | | reg_isoch=0xFFFFFFFFUL; |
---|
1222 | | if(!writeRxReg(n, DICE_REGISTER_RX_ISOC_BASE, reg_isoch)) { |
---|
1223 | | debugError("Could not write ISO_CHANNEL register for ARX %d\n", n); |
---|
1224 | | return false; |
---|
1225 | | } |
---|
1226 | | |
---|
1227 | | // deallocate ISO channel |
---|
1228 | | if(!deallocateIsoChannel(isochannel)) { |
---|
1229 | | debugError("Could not deallocate iso channel for SP %d (ARX %d)\n",i,n); |
---|
1230 | | return false; |
---|
| 1375 | if(snoopMode) { // a stream from the device to another host |
---|
| 1376 | // nothing to do |
---|
| 1377 | } else { |
---|
| 1378 | unsigned int isochannel = p->getChannel(); |
---|
| 1379 | |
---|
| 1380 | fb_quadlet_t reg_isoch; |
---|
| 1381 | // check value of ISO_CHANNEL register |
---|
| 1382 | if(!readRxReg(n, DICE_REGISTER_RX_ISOC_BASE, ®_isoch)) { |
---|
| 1383 | debugError("Could not read ISO_CHANNEL register for ARX %d\n", n); |
---|
| 1384 | return false; |
---|
| 1385 | } |
---|
| 1386 | if(reg_isoch != isochannel) { |
---|
| 1387 | debugError("ISO_CHANNEL register != 0x%08X (=0x%08X) for ARX %d\n", isochannel, reg_isoch, n); |
---|
| 1388 | return false; |
---|
| 1389 | } |
---|
| 1390 | |
---|
| 1391 | // write value of ISO_CHANNEL register |
---|
| 1392 | reg_isoch=0xFFFFFFFFUL; |
---|
| 1393 | if(!writeRxReg(n, DICE_REGISTER_RX_ISOC_BASE, reg_isoch)) { |
---|
| 1394 | debugError("Could not write ISO_CHANNEL register for ARX %d\n", n); |
---|
| 1395 | return false; |
---|
| 1396 | } |
---|
| 1397 | |
---|
| 1398 | // deallocate ISO channel |
---|
| 1399 | if(!deallocateIsoChannel(isochannel)) { |
---|
| 1400 | debugError("Could not deallocate iso channel for SP %d (ARX %d)\n",i,n); |
---|
| 1401 | return false; |
---|
| 1402 | } |
---|