Changeset 1136
- Timestamp:
- 05/08/08 02:38:15 (15 years ago)
- Files:
-
- trunk/libffado/src/bebob/focusrite/focusrite_cmd.cpp (modified) (2 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (modified) (2 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (2 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.cpp (modified) (5 diffs)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (1 diff)
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (4 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmd.cpp (modified) (4 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmd.h (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmds_flash.cpp (modified) (4 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp (modified) (2 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp (modified) (2 diffs)
- trunk/libffado/src/libavc/musicsubunit/avc_descriptor_music.cpp (modified) (2 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (7 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (1 diff)
- trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (7 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (9 diffs)
- trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (5 diffs)
- trunk/libffado/src/libutil/ByteSwap.h (modified) (9 diffs)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/tests/dumpiso_mod.cpp (modified) (1 diff)
- trunk/libffado/tests/scan-devreg.cpp (modified) (1 diff)
- trunk/libffado/tests/test-bufferops.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/focusrite/focusrite_cmd.cpp
r1135 r1136 54 54 result &= se.write(m_arg1,"FocusriteVendorDependentCmd arg1"); 55 55 result &= se.write(m_arg2,"FocusriteVendorDependentCmd arg2"); 56 // FIXME: this is not consistent, we should not have to care about CondSwap 32 here57 result &= se.write(CondSwap 32(m_id),"FocusriteVendorDependentCmd ID");58 result &= se.write(CondSwap 32(m_value),"FocusriteVendorDependentCmd value");56 // FIXME: this is not consistent, we should not have to care about CondSwapFromBus32 here 57 result &= se.write(CondSwapToBus32(m_id),"FocusriteVendorDependentCmd ID"); 58 result &= se.write(CondSwapToBus32(m_value),"FocusriteVendorDependentCmd value"); 59 59 60 60 return result; … … 69 69 result &= de.read(&m_arg2); 70 70 result &= de.read(&m_id); 71 m_id=CondSwap 32(m_id);71 m_id=CondSwapFromBus32(m_id); 72 72 result &= de.read(&m_value); 73 m_value=CondSwap 32(m_value);73 m_value=CondSwapFromBus32(m_value); 74 74 75 75 return result; trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp
r1135 r1136 140 140 fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 141 141 142 if(!get1394Service().write_quadlet( nodeId, addr, CondSwap 32(data) ) ) {142 if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { 143 143 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 144 144 return false; … … 161 161 } 162 162 163 result=CondSwap 32(result);163 result=CondSwapFromBus32(result); 164 164 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08llX\n", result); 165 165 trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp
r1135 r1136 757 757 char *ptr = (char *) &name[i*4]; 758 758 tmp = *((uint32_t *)ptr); 759 tmp = CondSwap 32(tmp);759 tmp = CondSwapToBus32(tmp); 760 760 if ( !setSpecificValue(FR_SAFFIREPRO_CMD_ID_DEVICE_NAME_1 + i, tmp ) ) { 761 761 debugError( "setSpecificValue failed\n" ); … … 776 776 return ""; 777 777 } 778 tmp = CondSwap 32(tmp);778 tmp = CondSwapFromBus32(tmp); 779 779 unsigned int j; 780 780 char *ptr = (char *) &tmp; trunk/libffado/src/bounce/bounce_slave_avdevice.cpp
r1135 r1136 367 367 // { 368 368 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 369 // printf(" %08x", CondSwap 32(current_rom[i]));369 // printf(" %08x", CondSwapFromBus32(current_rom[i])); 370 370 // } 371 371 // printf("\n"); … … 391 391 // { 392 392 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 393 // printf(" %08x", CondSwap 32(rom[i]));393 // printf(" %08x", CondSwapFromBus32(rom[i])); 394 394 // } 395 395 // printf("\n"); … … 411 411 // { 412 412 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 413 // printf(" %08x", CondSwap 32(rom[i]));413 // printf(" %08x", CondSwapFromBus32(rom[i])); 414 414 // } 415 415 // printf("\n"); … … 435 435 // { 436 436 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 437 // printf(" %08x", CondSwap 32(rom[i]));437 // printf(" %08x", CondSwapFromBus32(rom[i])); 438 438 // } 439 439 // printf("\n"); … … 449 449 // { 450 450 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 451 // printf(" %08x", CondSwap 32(rom[i]));451 // printf(" %08x", CondSwapFromBus32(rom[i])); 452 452 // } 453 453 // printf("\n"); trunk/libffado/src/debugmodule/debugmodule.cpp
r1135 r1136 802 802 for (i = 0; i< length; i += 1) { 803 803 printf( "%02d %04X: %08X (%08X)" 804 "\n", i, i*4, data[i],CondSwap 32(data[i]));805 } 806 } 807 808 804 "\n", i, i*4, data[i],CondSwapFromBus32(data[i])); 805 } 806 } 807 808 trunk/libffado/src/dice/dice_avdevice.cpp
r1135 r1136 1463 1463 } 1464 1464 1465 *result=CondSwap 32(*result);1465 *result=CondSwapFromBus32(*result); 1466 1466 1467 1467 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); … … 1483 1483 fb_nodeid_t nodeId=getNodeId() | 0xFFC0; 1484 1484 1485 if(!get1394Service().write_quadlet( nodeId, addr, CondSwap 32(data) ) ) {1485 if(!get1394Service().write_quadlet( nodeId, addr, CondSwapToBus32(data) ) ) { 1486 1486 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 1487 1487 return false; … … 1509 1509 1510 1510 for(unsigned int i=0;i<length/4;i++) { 1511 *(data+i)=CondSwap 32(*(data+i));1511 *(data+i)=CondSwapFromBus32(*(data+i)); 1512 1512 } 1513 1513 … … 1531 1531 1532 1532 for(unsigned int i=0;i<length/4;i++) { 1533 data_out[i]=CondSwap 32(*(data+i));1533 data_out[i]=CondSwapFromBus32(*(data+i)); 1534 1534 } 1535 1535 trunk/libffado/src/fireworks/efc/efc_cmd.cpp
r1135 r1136 110 110 bool result=true; 111 111 112 result &= se.write(CondSwap 32(m_length), "EFC length");112 result &= se.write(CondSwapToBus32(m_length), "EFC length"); 113 113 114 114 unsigned int i=0; … … 123 123 // serialize the header 124 124 quadlet_t *header_as_quadlets=(quadlet_t *)&m_header; 125 result &= se.write(CondSwap 32(*(header_as_quadlets+i)), "EFC header version"); i++;126 result &= se.write(CondSwap 32(*(header_as_quadlets+i)), "EFC header seqnum"); i++;127 result &= se.write(CondSwap 32(*(header_as_quadlets+i)), "EFC header category"); i++;128 result &= se.write(CondSwap 32(*(header_as_quadlets+i)), "EFC header command"); i++;129 result &= se.write(CondSwap 32(*(header_as_quadlets+i)), "EFC header return value"); i++;125 result &= se.write(CondSwapToBus32(*(header_as_quadlets+i)), "EFC header version"); i++; 126 result &= se.write(CondSwapToBus32(*(header_as_quadlets+i)), "EFC header seqnum"); i++; 127 result &= se.write(CondSwapToBus32(*(header_as_quadlets+i)), "EFC header category"); i++; 128 result &= se.write(CondSwapToBus32(*(header_as_quadlets+i)), "EFC header command"); i++; 129 result &= se.write(CondSwapToBus32(*(header_as_quadlets+i)), "EFC header return value"); i++; 130 130 131 131 return result; … … 138 138 139 139 result &= de.read(&m_length); 140 m_length=CondSwap 32(m_length);140 m_length=CondSwapFromBus32(m_length); 141 141 142 142 // read the EFC header … … 144 144 for (unsigned int i=0; i<sizeof(m_header)/4; i++) { 145 145 result &= de.read((header_as_quadlets+i)); 146 *(header_as_quadlets+i)=CondSwap 32(*(header_as_quadlets+i));146 *(header_as_quadlets+i)=CondSwapFromBus32(*(header_as_quadlets+i)); 147 147 } 148 148 trunk/libffado/src/fireworks/efc/efc_cmd.h
r1135 r1136 100 100 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \ 101 101 { __result__ &= __de__.read(__value__); \ 102 *(__value__)=CondSwap 32(*(__value__)); } \102 *(__value__)=CondSwapFromBus32(*(__value__)); } \ 103 103 104 104 trunk/libffado/src/fireworks/efc/efc_cmds_flash.cpp
r1135 r1136 48 48 49 49 result &= EfcCmd::serialize ( se ); 50 result &= se.write(CondSwap 32(m_address), "Address" );50 result &= se.write(CondSwapToBus32(m_address), "Address" ); 51 51 52 52 return result; … … 90 90 result &= EfcCmd::serialize ( se ); 91 91 92 result &= se.write(CondSwap 32(m_address), "Address" );93 result &= se.write(CondSwap 32(m_nb_quadlets), "Length (quadlets)" );92 result &= se.write(CondSwapToBus32(m_address), "Address" ); 93 result &= se.write(CondSwapToBus32(m_nb_quadlets), "Length (quadlets)" ); 94 94 95 95 return result; … … 152 152 result &= EfcCmd::serialize ( se ); 153 153 154 result &= se.write(CondSwap 32(m_address), "Address" );155 result &= se.write(CondSwap 32(m_nb_quadlets), "Length (quadlets)" );156 157 for (unsigned int i=0; i < m_nb_quadlets; i++) { 158 result &= se.write(CondSwap 32(m_data[i]), "Data");154 result &= se.write(CondSwapToBus32(m_address), "Address" ); 155 result &= se.write(CondSwapToBus32(m_nb_quadlets), "Length (quadlets)" ); 156 157 for (unsigned int i=0; i < m_nb_quadlets; i++) { 158 result &= se.write(CondSwapToBus32(m_data[i]), "Data"); 159 159 } 160 160 return result; … … 200 200 201 201 result &= EfcCmd::serialize ( se ); 202 result &= se.write(CondSwap 32(m_lock), "Locked" );202 result &= se.write(CondSwapToBus32(m_lock), "Locked" ); 203 203 204 204 return result; trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp
r1135 r1136 98 98 result &= EfcCmd::serialize ( se ); 99 99 100 result &= se.write(CondSwap 32(m_clock), "Clock" );101 result &= se.write(CondSwap 32(m_samplerate), "Samplerate" );102 result &= se.write(CondSwap 32(m_index), "Index" );100 result &= se.write(CondSwapToBus32(m_clock), "Clock" ); 101 result &= se.write(CondSwapToBus32(m_samplerate), "Samplerate" ); 102 result &= se.write(CondSwapToBus32(m_index), "Index" ); 103 103 104 104 return result; trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp
r1135 r1136 60 60 result &= EfcCmd::serialize ( se ); 61 61 62 result &= se.write(CondSwap 32(m_value), "Value" );62 result &= se.write(CondSwapToBus32(m_value), "Value" ); 63 63 } 64 64 return result; trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp
r1135 r1136 73 73 result &= EfcCmd::serialize ( se ); 74 74 75 result &= se.write(CondSwap 32(m_channel), "Channel" );75 result &= se.write(CondSwapToBus32(m_channel), "Channel" ); 76 76 77 77 } else { … … 82 82 result &= EfcCmd::serialize ( se ); 83 83 84 result &= se.write(CondSwap 32(m_channel), "Channel" );85 result &= se.write(CondSwap 32(m_value), "Value" );84 result &= se.write(CondSwapToBus32(m_channel), "Channel" ); 85 result &= se.write(CondSwapToBus32(m_value), "Value" ); 86 86 } 87 87 trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp
r1135 r1136 106 106 result &= EfcCmd::serialize ( se ); 107 107 108 result &= se.write(CondSwap 32(m_input), "Input" );109 result &= se.write(CondSwap 32(m_output), "Output" );108 result &= se.write(CondSwapToBus32(m_input), "Input" ); 109 result &= se.write(CondSwapToBus32(m_output), "Output" ); 110 110 111 111 } else { … … 116 116 result &= EfcCmd::serialize ( se ); 117 117 118 result &= se.write(CondSwap 32(m_input), "Input" );119 result &= se.write(CondSwap 32(m_output), "Output" );120 result &= se.write(CondSwap 32(m_value), "Value" );118 result &= se.write(CondSwapToBus32(m_input), "Input" ); 119 result &= se.write(CondSwapToBus32(m_output), "Output" ); 120 result &= se.write(CondSwapToBus32(m_value), "Value" ); 121 121 } 122 122 return result; trunk/libffado/src/libavc/musicsubunit/avc_descriptor_music.cpp
r1135 r1136 53 53 result &= AVCInfoBlock::serialize(se); 54 54 55 quadlet_t tmp=CondSwap 32(m_current_latency_capability);55 quadlet_t tmp=CondSwapToBus32(m_current_latency_capability); 56 56 57 57 result &= se.write(m_current_transmit_capability, "AVCMusicGeneralStatusInfoBlock m_current_transmit_capability"); … … 75 75 result &= de.read(&m_current_receive_capability); 76 76 result &= de.read(&m_current_latency_capability); 77 m_current_latency_capability=CondSwap 32(m_current_latency_capability);77 m_current_latency_capability=CondSwapFromBus32(m_current_latency_capability); 78 78 79 79 return result; trunk/libffado/src/libieee1394/ieee1394service.cpp
r1135 r1136 388 388 CSR_REGISTER_BASE | CSR_CYCLE_TIME, 389 389 sizeof(uint32_t), cycle_timer ) == 0 ) { 390 *cycle_timer = CondSwap 32(*cycle_timer);390 *cycle_timer = CondSwapFromBus32(*cycle_timer); 391 391 return true; 392 392 } else { … … 479 479 return write( nodeId, addr, sizeof( data )/4, 480 480 reinterpret_cast<fb_quadlet_t*>( &data ) ); 481 }482 483 fb_octlet_t484 Ieee1394Service::byteSwap_octlet(fb_octlet_t value) {485 #if __BYTE_ORDER == __BIG_ENDIAN486 return value;487 #elif __BYTE_ORDER == __LITTLE_ENDIAN488 fb_quadlet_t in_hi = (value >> 32) & 0xFFFFFFFF;489 fb_quadlet_t in_lo = value & 0xFFFFFFFF;490 in_hi = CondSwap32(in_hi);491 in_lo = CondSwap32(in_lo);492 fb_octlet_t value_new = in_lo;493 value_new <<= 32;494 value_new |= in_hi;495 return value_new;496 #else497 #error Unknown endiannes498 #endif499 481 } 500 482 … … 520 502 521 503 // do endiannes swapping 522 compare_value = byteSwap_octlet(compare_value);523 swap_value = byteSwap_octlet(swap_value);504 compare_value = CondSwapToBus64(compare_value); 505 swap_value = CondSwapToBus64(swap_value); 524 506 525 507 // do separate locking here (no MutexLockHelper) since … … 543 525 #endif 544 526 545 *result = byteSwap_octlet(*result);527 *result = CondSwapFromBus64(*result); 546 528 547 529 return (retval == 0); … … 557 539 m_handle_lock->Lock(); 558 540 for (int i = 0; i < len; ++i) { 559 buf[i] = CondSwap 32( buf[i] );541 buf[i] = CondSwapFromBus32( buf[i] ); 560 542 } 561 543 … … 569 551 570 552 for ( unsigned int i = 0; i < *resp_len; ++i ) { 571 result[i] = CondSwap 32( result[i] );553 result[i] = CondSwapToBus32( result[i] ); 572 554 } 573 555 … … 1114 1096 if (result < 0) 1115 1097 return -1; 1116 return CondSwap 32(buffer);1098 return CondSwapFromBus32(buffer); 1117 1099 } 1118 1100 trunk/libffado/src/libieee1394/ieee1394service.h
r1134 r1136 345 345 arm_handler_vec_t m_armHandlers; 346 346 347 fb_octlet_t byteSwap_octlet(fb_octlet_t value);348 349 347 public: 350 348 void setVerboseLevel(int l); trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r1135 r1136 102 102 (length >= 2*sizeof(quadlet_t)); 103 103 if(ok) { 104 m_last_timestamp = sytRecvToFullTicks2((uint32_t)CondSwap 16(packet->syt), pkt_ctr);104 m_last_timestamp = sytRecvToFullTicks2((uint32_t)CondSwapFromBus16(packet->syt), pkt_ctr); 105 105 //#ifdef DEBUG 106 106 #if 0 … … 108 108 109 109 //=> convert the SYT to a full timestamp in ticks 110 uint64_t old_last_timestamp = sytRecvToFullTicks((uint32_t)CondSwap 16(packet->syt),110 uint64_t old_last_timestamp = sytRecvToFullTicks((uint32_t)CondSwapFromBus16(packet->syt), 111 111 CYCLE_TIMER_GET_CYCLES(pkt_ctr), now); 112 112 if(m_last_timestamp != old_last_timestamp) { … … 224 224 225 225 for(j = 0; j < nevents; j += 1) { 226 *(buffer)=(CondSwap 32((*target_event) ) & 0x00FFFFFF);226 *(buffer)=(CondSwapFromBus32((*target_event) ) & 0x00FFFFFF); 227 227 buffer++; 228 228 target_event+=m_dimension; … … 258 258 259 259 for(j = 0; j < nevents; j += 1) { 260 unsigned int v = CondSwap 32(*target_event) & 0x00FFFFFF;260 unsigned int v = CondSwapFromBus32(*target_event) & 0x00FFFFFF; 261 261 // sign-extend highest bit of 24-bit int 262 262 int tmp = (int)(v << 8) / 256; … … 295 295 296 296 for(j = 0; j < nevents; j += 1) { 297 *(buffer)=(CondSwap 32((*target_event) ) & 0x00FFFFFF);297 *(buffer)=(CondSwapFromBus32((*target_event) ) & 0x00FFFFFF); 298 298 buffer++; 299 299 target_event+=m_dimension; … … 329 329 330 330 for(j = 0; j < nevents; j += 1) { 331 unsigned int v = CondSwap 32(*target_event) & 0x00FFFFFF;331 unsigned int v = CondSwapFromBus32(*target_event) & 0x00FFFFFF; 332 332 // sign-extend highest bit of 24-bit int 333 333 int tmp = (int)(v << 8) / 256; … … 365 365 for (j = p.location;j < nevents; j += 8) { 366 366 target_event = (quadlet_t *) (data + ((j * m_dimension) + p.position)); 367 sample_int=CondSwap 32(*target_event);367 sample_int=CondSwapFromBus32(*target_event); 368 368 // FIXME: this assumes that 2X and 3X speed isn't used, 369 369 // because only the 1X slot is put into the ringbuffer trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp
r1135 r1136 353 353 // convert the timestamp to SYT format 354 354 uint16_t timestamp_SYT = TICKS_TO_SYT ( ts ); 355 packet->syt = CondSwap 16 ( timestamp_SYT );355 packet->syt = CondSwapToBus16 ( timestamp_SYT ); 356 356 357 357 // FIXME: use a precomputed value here … … 683 683 unsigned int tmp = ((int) v); 684 684 tmp = ( tmp >> 8 ) | 0x40000000; 685 *target_event = CondSwap 32((quadlet_t)tmp);685 *target_event = CondSwapToBus32((quadlet_t)tmp); 686 686 buffer++; 687 687 target_event += m_dimension; … … 839 839 for(;j < nevents; j += 1) { 840 840 uint32_t in = (uint32_t)(*buffer); 841 *target_event = CondSwap 32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000));841 *target_event = CondSwapToBus32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 842 842 buffer++; 843 843 target_event += m_dimension; … … 884 884 { 885 885 uint32_t in = (uint32_t)(*buffer); 886 *target_event = CondSwap 32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000));886 *target_event = CondSwapToBus32((quadlet_t)((in & 0x00FFFFFF) | 0x40000000)); 887 887 buffer++; 888 888 target_event += m_dimension; … … 933 933 934 934 tmp = ( tmp >> 8 ) | 0x40000000; 935 *target_event = CondSwap 32((quadlet_t)tmp);935 *target_event = CondSwapToBus32((quadlet_t)tmp); 936 936 buffer++; 937 937 target_event += m_dimension; … … 968 968 for (j = p.location;j < nevents; j += 8) { 969 969 target_event = (quadlet_t *) (data + ((j * m_dimension) + p.position)); 970 *target_event = CondSwap 32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));970 *target_event = CondSwapToBus32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 971 971 } 972 972 } … … 1001 1001 tmpval = ((*buffer)<<16) & 0x00FF0000; 1002 1002 tmpval = IEC61883_AM824_SET_LABEL(tmpval, IEC61883_AM824_LABEL_MIDI_1X); 1003 *target_event = CondSwap 32(tmpval);1003 *target_event = CondSwapToBus32(tmpval); 1004 1004 1005 1005 // debugOutput ( DEBUG_LEVEL_VERBOSE, "MIDI port %s, pos=%u, loc=%u, nevents=%u, dim=%d\n", … … 1011 1011 // or because this would exceed the maximum rate 1012 1012 // FIXME: this can be ifdef optimized since it's a constant 1013 *target_event = CondSwap 32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));1013 *target_event = CondSwapToBus32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 1014 1014 } 1015 1015 buffer+=8; … … 1019 1019 target_event = (quadlet_t *)(data + ((j * m_dimension) + p.position)); 1020 1020 __builtin_prefetch(target_event, 1, 0); // prefetch events for write, no temporal locality 1021 *target_event = CondSwap 32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));1021 *target_event = CondSwapToBus32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 1022 1022 } 1023 1023 } trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r1135 r1136 131 131 // for 2x rates, 32 for 4x rates). 132 132 quadlet_t *quadlet = (quadlet_t *)data; 133 unsigned int dbs = get_bits(CondSwap 32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size134 unsigned int fdf_size = get_bits(CondSwap 32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits133 unsigned int dbs = get_bits(CondSwapFromBus32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size 134 unsigned int fdf_size = get_bits(CondSwapFromBus32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 135 135 136 136 // Don't even attempt to process a packet if it isn't what … … 150 150 // received. Since every frame from the MOTU has its own timestamp 151 151 // we can just pick it straight from the packet. 152 uint32_t last_sph = CondSwap 32(*(quadlet_t *)(data+8+(n_events-1)*event_length));152 uint32_t last_sph = CondSwapFromBus32(*(quadlet_t *)(data+8+(n_events-1)*event_length)); 153 153 m_last_timestamp = sphRecvToFullTicks(last_sph, m_Parent.get1394Service().getCycleTimer()); 154 154 … … 174 174 quadlet_t* quadlet = (quadlet_t*) data; 175 175 176 unsigned int dbs = get_bits(CondSwap 32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size177 unsigned int fdf_size = get_bits(CondSwap 32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits176 unsigned int dbs = get_bits(CondSwapFromBus32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size 177 unsigned int fdf_size = get_bits(CondSwapFromBus32(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 178 178 // this is only called for packets that return eCRV_OK on processPacketHeader 179 179 // so event_length won't become 0 trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r1135 r1136 293 293 // network byte order). After byte order swap, the 24-bit 294 294 // MSB is in the second byte of val. 295 signed int val = CondSwap 32(lrintf(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx)));295 signed int val = CondSwapToBus32(lrintf(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx))); 296 296 memcpy(sample,((char *)&val)+1,3); 297 297 if ((a_cx+=int_tpf) >= 24576000) { … … 309 309 for (int i=0; i < n_events; i++, quadlet += dbs) { 310 310 int64_t ts_frame = addTicks(m_last_timestamp, (unsigned int)lrintf(i * ticks_per_frame)); 311 *quadlet = CondSwap 32(fullTicksToSph(ts_frame));311 *quadlet = CondSwapToBus32(fullTicksToSph(ts_frame)); 312 312 //fprintf(stderr,"tx: %d/%d\n", 313 313 // CYCLE_TIMER_GET_CYCLES(fullTicksToSph(ts_frame)), … … 405 405 for (int i=0; i < n_events; i++, quadlet += dbs) { 406 406 int64_t ts_frame = addTicks(m_last_timestamp, (unsigned int)lrintf(i * ticks_per_frame)); 407 *quadlet = CondSwap 32(fullTicksToSph(ts_frame));407 *quadlet = CondSwapToBus32(fullTicksToSph(ts_frame)); 408 408 } 409 409 … … 428 428 // present. For data-less packets the dbc is the same as the previously 429 429 // transmitted block. 430 *quadlet = CondSwap 32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));430 *quadlet = CondSwapToBus32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 431 431 quadlet++; 432 *quadlet = CondSwap 32(0x8222ffff);432 *quadlet = CondSwapToBus32(0x8222ffff); 433 433 quadlet++; 434 434 return n_events; … … 445 445 // present. For data-less packets the dbc is the same as the previously 446 446 // transmitted block. 447 *quadlet = CondSwap 32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));447 *quadlet = CondSwapToBus32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 448 448 quadlet++; 449 *quadlet = CondSwap 32(0x8222ffff);449 *quadlet = CondSwapToBus32(0x8222ffff); 450 450 quadlet++; 451 451 *length = 8; trunk/libffado/src/libutil/ByteSwap.h
r1135 r1136 35 35 #include <stdio.h> 36 36 37 static inline uint64_t 38 ByteSwap64(uint64_t d) 39 { 40 return bswap_64(d); 41 } 42 43 static inline uint32_t 44 ByteSwap32(uint32_t d) 45 { 46 return bswap_32(d); 47 } 48 49 static inline uint16_t 50 ByteSwap16(uint16_t d) 51 { 52 return bswap_16(d); 53 } 54 55 37 56 #if __BYTE_ORDER == __BIG_ENDIAN 38 57 … … 40 59 41 60 static inline uint64_t 42 CondSwap64(uint64_t d) 43 { 44 return d; 45 } 46 47 static inline uint32_t 48 CondSwap32(uint32_t d) 49 { 50 return d; 51 } 52 53 static inline uint16_t 54 CondSwap16(uint16_t d) 61 CondSwapToBus64(uint64_t d) 62 { 63 return d; 64 } 65 66 static inline uint32_t 67 CondSwapToBus32(uint32_t d) 68 { 69 return d; 70 } 71 72 static inline uint16_t 73 CondSwapToBus16(uint16_t d) 74 { 75 return d; 76 } 77 78 static inline uint64_t 79 CondSwapFromBus64(uint64_t d) 80 { 81 return d; 82 } 83 84 static inline uint32_t 85 CondSwapFromBus32(uint32_t d) 86 { 87 return d; 88 } 89 90 static inline uint16_t 91 CondSwapFromBus16(uint16_t d) 55 92 { 56 93 return d; … … 72 109 73 110 static inline uint64_t 74 CondSwap64(uint64_t d) 75 { 76 return bswap_64(d); 77 } 78 79 static inline uint32_t 80 CondSwap32(uint32_t d) 81 { 82 return bswap_32(d); 83 } 84 85 static inline uint16_t 86 CondSwap16(uint16_t d) 87 { 88 return bswap_16(d); 111 CondSwapToBus64(uint64_t d) 112 { 113 return ByteSwap64(d); 114 } 115 116 static inline uint32_t 117 CondSwapToBus32(uint32_t d) 118 { 119 return ByteSwap32(d); 120 } 121 122 static inline uint16_t 123 CondSwapToBus16(uint16_t d) 124 { 125 return ByteSwap16(d); 126 } 127 128 static inline uint64_t 129 CondSwapFromBus64(uint64_t d) 130 { 131 return ByteSwap64(d); 132 } 133 134 static inline uint32_t 135 CondSwapFromBus32(uint32_t d) 136 { 137 return ByteSwap32(d); 138 } 139 140 static inline uint16_t 141 CondSwapFromBus16(uint16_t d) 142 { 143 return ByteSwap16(d); 89 144 } 90 145 … … 99 154 // Work input until data reaches 16 byte alignment 100 155 while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 101 *data = CondSwap32(*data);156 *data = ByteSwap32(*data); 102 157 data++; 103 158 nb_elements--; … … 136 191 // and do the remaining ones 137 192 while (nb_elements > 0) { 138 *data = CondSwap32(*data);193 *data = ByteSwap32(*data); 139 194 data++; 140 195 nb_elements--; … … 148 203 // Work input until data reaches 16 byte alignment 149 204 while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 150 *data = CondSwap32(*data);205 *data = ByteSwap32(*data); 151 206 data++; 152 207 nb_elements--; … … 182 237 // and do the remaining ones 183 238 while (nb_elements > 0) { 184 *data = CondSwap32(*data);239 *data = ByteSwap32(*data); 185 240 data++; 186 241 nb_elements--; … … 195 250 unsigned int i=0; 196 251 for(; i<nb_elements; i++) { 197 *data = CondSwap32(*data);252 *data = ByteSwap32(*data); 198 253 data++; 199 254 } … … 205 260 unsigned int i=0; 206 261 for(; i<nb_elements; i++) { 207 *data = CondSwap32(*data);262 *data = ByteSwap32(*data); 208 263 data++; 209 264 } trunk/libffado/src/motu/motu_avdevice.cpp
r1135 r1136 1389 1389 } 1390 1390 1391 return CondSwap 32(quadlet);1391 return CondSwapFromBus32(quadlet); 1392 1392 } 1393 1393 … … 1398 1398 1399 1399 unsigned int err = 0; 1400 data = CondSwap 32(data);1400 data = CondSwapToBus32(data); 1401 1401 1402 1402 // Note: 1394Service::write() expects a physical ID, not the node id trunk/libffado/src/rme/rme_avdevice.cpp
r1135 r1136 252 252 debugError("Error doing RME read from register 0x%06x\n",reg); 253 253 } 254 return CondSwap 32(quadlet);254 return CondSwapFromBus32(quadlet); 255 255 } 256 256 … … 259 259 260 260 unsigned int err = 0; 261 data = CondSwap 32(data);261 data = CondSwapToBus32(data); 262 262 if (get1394Service().write(0xffc0 | getNodeId(), reg, 1, &data) <= 0) { 263 263 err = 1; trunk/libffado/tests/dumpiso_mod.cpp
r1135 r1136 210 210 (length >= 2*sizeof(quadlet_t)); 211 211 if(ok) { 212 timestamp = sytRecvToFullTicks((uint32_t)CondSwap 16(packet->syt),212 timestamp = sytRecvToFullTicks((uint32_t)CondSwapFromBus16(packet->syt), 213 213 cycle, cycle_timer); 214 214 } trunk/libffado/tests/scan-devreg.cpp
r1135 r1136 284 284 continue; 285 285 } else { 286 quadlet = CondSwap 32(quadlet);286 quadlet = CondSwapFromBus32(quadlet); 287 287 } 288 288 trunk/libffado/tests/test-bufferops.cpp
r1135 r1136 65 65 66 66 for (i=0; i<nb_quadlets; i++) { 67 buffer_ref[i] = CondSwap 32(buffer_1[i]);67 buffer_ref[i] = CondSwapToBus32(buffer_1[i]); 68 68 } 69 69