Changeset 1135
- Timestamp:
- 05/08/08 02:00:38 (15 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_dl_mgr.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/focusrite/focusrite_cmd.cpp (modified) (3 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp (modified) (3 diffs)
- trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp (modified) (3 diffs)
- trunk/libffado/src/bebob/terratec/terratec_cmd.cpp (modified) (1 diff)
- trunk/libffado/src/bounce/bounce_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/bounce/bounce_slave_avdevice.cpp (modified) (5 diffs)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (2 diffs)
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (5 diffs)
- trunk/libffado/src/fireworks/efc/efc_avc_cmd.cpp (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmd.cpp (modified) (5 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmd.h (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmds_flash.cpp (modified) (5 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp (modified) (1 diff)
- trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp (modified) (2 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp (modified) (2 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp (modified) (3 diffs)
- trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp (modified) (3 diffs)
- trunk/libffado/src/genericavc/avc_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/ccm/avc_signal_source.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_connect.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_extended_plug_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_extended_subunit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_generic.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_plug_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_signal_format.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_subunit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_unit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/general/avc_vendor_dependent_cmd.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/musicsubunit/avc_descriptor_music.cpp (modified) (3 diffs)
- trunk/libffado/src/libavc/streamformat/avc_extended_stream_format.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (6 diffs)
- trunk/libffado/src/libieee1394/IsoHandler.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp (modified) (8 diffs)
- trunk/libffado/src/libstreaming/amdtp/AmdtpTransmitStreamProcessor.cpp (modified) (10 diffs)
- trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (4 diffs)
- trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (6 diffs)
- trunk/libffado/src/libutil/ByteSwap.h (modified) (9 diffs)
- trunk/libffado/src/libutil/cmd_serialize.cpp (modified) (1 diff)
- trunk/libffado/src/metrichalo/mh_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/tests/dumpiso_mod.cpp (modified) (2 diffs)
- trunk/libffado/tests/scan-devreg.cpp (modified) (2 diffs)
- trunk/libffado/tests/streaming/test-isohandling.cpp (modified) (1 diff)
- trunk/libffado/tests/test-bufferops.cpp (modified) (1 diff)
- trunk/libffado/tests/test-ieee1394service.cpp (modified) (1 diff)
- trunk/libffado/tests/test-timestampedbuffer.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_dl_mgr.cpp
r1134 r1135 32 32 #include "libutil/Time.h" 33 33 34 #include <netinet/in.h>34 #include "libutil/ByteSwap.h" 35 35 36 36 #include <cstdio> trunk/libffado/src/bebob/focusrite/focusrite_cmd.cpp
r1134 r1135 24 24 #include "focusrite_cmd.h" 25 25 26 #include <netinet/in.h>26 #include "libutil/ByteSwap.h" 27 27 #include <iostream> 28 28 … … 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 ntohlhere57 result &= se.write( htonl(m_id),"FocusriteVendorDependentCmd ID");58 result &= se.write( htonl(m_value),"FocusriteVendorDependentCmd value");56 // FIXME: this is not consistent, we should not have to care about CondSwap32 here 57 result &= se.write(CondSwap32(m_id),"FocusriteVendorDependentCmd ID"); 58 result &= se.write(CondSwap32(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= ntohl(m_id);71 m_id=CondSwap32(m_id); 72 72 result &= de.read(&m_value); 73 m_value= ntohl(m_value);73 m_value=CondSwap32(m_value); 74 74 75 75 return result; trunk/libffado/src/bebob/focusrite/focusrite_generic.cpp
r1134 r1135 25 25 #include "focusrite_cmd.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 29 29 namespace BeBoB { … … 140 140 fb_nodeid_t nodeId = getNodeId() | 0xFFC0; 141 141 142 if(!get1394Service().write_quadlet( nodeId, addr, htonl(data) ) ) {142 if(!get1394Service().write_quadlet( nodeId, addr, CondSwap32(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= ntohl(result);163 result=CondSwap32(result); 164 164 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08llX\n", result); 165 165 trunk/libffado/src/bebob/focusrite/focusrite_saffirepro.cpp
r1134 r1135 28 28 #include "libutil/Time.h" 29 29 30 #include <netinet/in.h>30 #include "libutil/ByteSwap.h" 31 31 32 32 namespace BeBoB { … … 757 757 char *ptr = (char *) &name[i*4]; 758 758 tmp = *((uint32_t *)ptr); 759 tmp = htonl(tmp);759 tmp = CondSwap32(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 = ntohl(tmp);778 tmp = CondSwap32(tmp); 779 779 unsigned int j; 780 780 char *ptr = (char *) &tmp; trunk/libffado/src/bebob/terratec/terratec_cmd.cpp
r1134 r1135 24 24 #include "terratec_cmd.h" 25 25 26 #include <netinet/in.h>26 #include "libutil/ByteSwap.h" 27 27 #include <iostream> 28 28 trunk/libffado/src/bounce/bounce_avdevice.cpp
r1134 r1135 42 42 43 43 #include <string> 44 #include <netinet/in.h>44 #include "libutil/ByteSwap.h" 45 45 46 46 namespace Bounce { trunk/libffado/src/bounce/bounce_slave_avdevice.cpp
r1134 r1135 367 367 // { 368 368 // if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4); 369 // printf(" %08x", ntohl(current_rom[i]));369 // printf(" %08x", CondSwap32(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", ntohl(rom[i]));393 // printf(" %08x", CondSwap32(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", ntohl(rom[i]));413 // printf(" %08x", CondSwap32(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", ntohl(rom[i]));437 // printf(" %08x", CondSwap32(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", ntohl(rom[i]));451 // printf(" %08x", CondSwap32(rom[i])); 452 452 // } 453 453 // printf("\n"); trunk/libffado/src/debugmodule/debugmodule.cpp
r1134 r1135 27 27 28 28 #include <stdarg.h> 29 #include <netinet/in.h>29 #include "libutil/ByteSwap.h" 30 30 31 31 #include <iostream> … … 802 802 for (i = 0; i< length; i += 1) { 803 803 printf( "%02d %04X: %08X (%08X)" 804 "\n", i, i*4, data[i], ntohl(data[i]));805 } 806 } 807 808 804 "\n", i, i*4, data[i],CondSwap32(data[i])); 805 } 806 } 807 808 trunk/libffado/src/dice/dice_avdevice.cpp
r1134 r1135 33 33 #include <stdint.h> 34 34 #include <assert.h> 35 #include <netinet/in.h>35 #include "libutil/ByteSwap.h" 36 36 #include <libraw1394/csr.h> 37 37 … … 1463 1463 } 1464 1464 1465 *result= ntohl(*result);1465 *result=CondSwap32(*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, htonl(data) ) ) {1485 if(!get1394Service().write_quadlet( nodeId, addr, CondSwap32(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)= ntohl(*(data+i));1511 *(data+i)=CondSwap32(*(data+i)); 1512 1512 } 1513 1513 … … 1531 1531 1532 1532 for(unsigned int i=0;i<length/4;i++) { 1533 data_out[i]= ntohl(*(data+i));1533 data_out[i]=CondSwap32(*(data+i)); 1534 1534 } 1535 1535 trunk/libffado/src/fireworks/efc/efc_avc_cmd.cpp
r1134 r1135 24 24 #include "efc_avc_cmd.h" 25 25 26 #include <netinet/in.h>26 #include "libutil/ByteSwap.h" 27 27 #include <iostream> 28 28 trunk/libffado/src/fireworks/efc/efc_cmd.cpp
r1134 r1135 25 25 #include "efc_cmds_hardware.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 110 110 bool result=true; 111 111 112 result &= se.write( htonl(m_length), "EFC length");112 result &= se.write(CondSwap32(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( htonl(*(header_as_quadlets+i)), "EFC header version"); i++;126 result &= se.write( htonl(*(header_as_quadlets+i)), "EFC header seqnum"); i++;127 result &= se.write( htonl(*(header_as_quadlets+i)), "EFC header category"); i++;128 result &= se.write( htonl(*(header_as_quadlets+i)), "EFC header command"); i++;129 result &= se.write( htonl(*(header_as_quadlets+i)), "EFC header return value"); i++;125 result &= se.write(CondSwap32(*(header_as_quadlets+i)), "EFC header version"); i++; 126 result &= se.write(CondSwap32(*(header_as_quadlets+i)), "EFC header seqnum"); i++; 127 result &= se.write(CondSwap32(*(header_as_quadlets+i)), "EFC header category"); i++; 128 result &= se.write(CondSwap32(*(header_as_quadlets+i)), "EFC header command"); i++; 129 result &= se.write(CondSwap32(*(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= ntohl(m_length);140 m_length=CondSwap32(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)= ntohl(*(header_as_quadlets+i));146 *(header_as_quadlets+i)=CondSwap32(*(header_as_quadlets+i)); 147 147 } 148 148 trunk/libffado/src/fireworks/efc/efc_cmd.h
r1134 r1135 100 100 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \ 101 101 { __result__ &= __de__.read(__value__); \ 102 *(__value__)= ntohl(*(__value__)); } \102 *(__value__)=CondSwap32(*(__value__)); } \ 103 103 104 104 trunk/libffado/src/fireworks/efc/efc_cmds_flash.cpp
r1134 r1135 25 25 #include "efc_cmds_flash.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 48 48 49 49 result &= EfcCmd::serialize ( se ); 50 result &= se.write( htonl(m_address), "Address" );50 result &= se.write(CondSwap32(m_address), "Address" ); 51 51 52 52 return result; … … 90 90 result &= EfcCmd::serialize ( se ); 91 91 92 result &= se.write( htonl(m_address), "Address" );93 result &= se.write( htonl(m_nb_quadlets), "Length (quadlets)" );92 result &= se.write(CondSwap32(m_address), "Address" ); 93 result &= se.write(CondSwap32(m_nb_quadlets), "Length (quadlets)" ); 94 94 95 95 return result; … … 152 152 result &= EfcCmd::serialize ( se ); 153 153 154 result &= se.write( htonl(m_address), "Address" );155 result &= se.write( htonl(m_nb_quadlets), "Length (quadlets)" );156 157 for (unsigned int i=0; i < m_nb_quadlets; i++) { 158 result &= se.write( htonl(m_data[i]), "Data");154 result &= se.write(CondSwap32(m_address), "Address" ); 155 result &= se.write(CondSwap32(m_nb_quadlets), "Length (quadlets)" ); 156 157 for (unsigned int i=0; i < m_nb_quadlets; i++) { 158 result &= se.write(CondSwap32(m_data[i]), "Data"); 159 159 } 160 160 return result; … … 200 200 201 201 result &= EfcCmd::serialize ( se ); 202 result &= se.write( htonl(m_lock), "Locked" );202 result &= se.write(CondSwap32(m_lock), "Locked" ); 203 203 204 204 return result; trunk/libffado/src/fireworks/efc/efc_cmds_hardware.cpp
r1134 r1135 24 24 #include "efc_cmds_hardware.h" 25 25 26 #include <netinet/in.h>26 #include "libutil/ByteSwap.h" 27 27 #include <iostream> 28 28 trunk/libffado/src/fireworks/efc/efc_cmds_hardware_ctrl.cpp
r1134 r1135 25 25 #include "efc_cmds_hardware_ctrl.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 98 98 result &= EfcCmd::serialize ( se ); 99 99 100 result &= se.write( htonl(m_clock), "Clock" );101 result &= se.write( htonl(m_samplerate), "Samplerate" );102 result &= se.write( htonl(m_index), "Index" );100 result &= se.write(CondSwap32(m_clock), "Clock" ); 101 result &= se.write(CondSwap32(m_samplerate), "Samplerate" ); 102 result &= se.write(CondSwap32(m_index), "Index" ); 103 103 104 104 return result; trunk/libffado/src/fireworks/efc/efc_cmds_ioconfig.cpp
r1134 r1135 25 25 #include "efc_cmds_ioconfig.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 60 60 result &= EfcCmd::serialize ( se ); 61 61 62 result &= se.write( htonl(m_value), "Value" );62 result &= se.write(CondSwap32(m_value), "Value" ); 63 63 } 64 64 return result; trunk/libffado/src/fireworks/efc/efc_cmds_mixer.cpp
r1134 r1135 25 25 #include "efc_cmds_mixer.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 73 73 result &= EfcCmd::serialize ( se ); 74 74 75 result &= se.write( htonl(m_channel), "Channel" );75 result &= se.write(CondSwap32(m_channel), "Channel" ); 76 76 77 77 } else { … … 82 82 result &= EfcCmd::serialize ( se ); 83 83 84 result &= se.write( htonl(m_channel), "Channel" );85 result &= se.write( htonl(m_value), "Value" );84 result &= se.write(CondSwap32(m_channel), "Channel" ); 85 result &= se.write(CondSwap32(m_value), "Value" ); 86 86 } 87 87 trunk/libffado/src/fireworks/efc/efc_cmds_monitor.cpp
r1134 r1135 25 25 #include "efc_cmds_monitor.h" 26 26 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 #include <iostream> 29 29 … … 106 106 result &= EfcCmd::serialize ( se ); 107 107 108 result &= se.write( htonl(m_input), "Input" );109 result &= se.write( htonl(m_output), "Output" );108 result &= se.write(CondSwap32(m_input), "Input" ); 109 result &= se.write(CondSwap32(m_output), "Output" ); 110 110 111 111 } else { … … 116 116 result &= EfcCmd::serialize ( se ); 117 117 118 result &= se.write( htonl(m_input), "Input" );119 result &= se.write( htonl(m_output), "Output" );120 result &= se.write( htonl(m_value), "Value" );118 result &= se.write(CondSwap32(m_input), "Input" ); 119 result &= se.write(CondSwap32(m_output), "Output" ); 120 result &= se.write(CondSwap32(m_value), "Value" ); 121 121 } 122 122 return result; trunk/libffado/src/genericavc/avc_avdevice.cpp
r1134 r1135 39 39 #include <stdint.h> 40 40 #include <assert.h> 41 #include <netinet/in.h>41 #include "libutil/ByteSwap.h" 42 42 #include <iostream> 43 43 #include <sstream> trunk/libffado/src/libavc/ccm/avc_signal_source.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/descriptors/avc_descriptor_cmd.cpp
r1134 r1135 28 28 #include "libieee1394/ieee1394service.h" 29 29 30 #include <netinet/in.h>30 #include "libutil/ByteSwap.h" 31 31 #include <iostream> 32 32 trunk/libffado/src/libavc/general/avc_connect.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_extended_plug_info.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_extended_subunit_info.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 30 30 #define NR_OF_PAGE_DATA 5 trunk/libffado/src/libavc/general/avc_generic.cpp
r1134 r1135 30 30 #include "libutil/Time.h" 31 31 32 #include <netinet/in.h>32 #include "libutil/ByteSwap.h" 33 33 34 34 #define DEBUG_EXTRA_VERBOSE 5 trunk/libffado/src/libavc/general/avc_plug_info.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_signal_format.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_subunit_info.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_unit_info.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/general/avc_vendor_dependent_cmd.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 #include <iostream> 30 30 trunk/libffado/src/libavc/musicsubunit/avc_descriptor_music.cpp
r1134 r1135 33 33 #include "../general/avc_unit.h" 34 34 35 #include <netinet/in.h>35 #include "libutil/ByteSwap.h" 36 36 37 37 // info block implementations … … 53 53 result &= AVCInfoBlock::serialize(se); 54 54 55 quadlet_t tmp= htonl(m_current_latency_capability);55 quadlet_t tmp=CondSwap32(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= ntohl(m_current_latency_capability);77 m_current_latency_capability=CondSwap32(m_current_latency_capability); 78 78 79 79 return result; trunk/libffado/src/libavc/streamformat/avc_extended_stream_format.cpp
r1134 r1135 26 26 #include "libieee1394/ieee1394service.h" 27 27 28 #include <netinet/in.h>28 #include "libutil/ByteSwap.h" 29 29 30 30 namespace AVC { trunk/libffado/src/libieee1394/ieee1394service.cpp
r1134 r1135 39 39 40 40 #include <errno.h> 41 #include <netinet/in.h>41 #include "libutil/ByteSwap.h" 42 42 43 43 #include <string.h> … … 388 388 CSR_REGISTER_BASE | CSR_CYCLE_TIME, 389 389 sizeof(uint32_t), cycle_timer ) == 0 ) { 390 *cycle_timer = ntohl(*cycle_timer);390 *cycle_timer = CondSwap32(*cycle_timer); 391 391 return true; 392 392 } else { … … 488 488 fb_quadlet_t in_hi = (value >> 32) & 0xFFFFFFFF; 489 489 fb_quadlet_t in_lo = value & 0xFFFFFFFF; 490 in_hi = htonl(in_hi);491 in_lo = htonl(in_lo);490 in_hi = CondSwap32(in_hi); 491 in_lo = CondSwap32(in_lo); 492 492 fb_octlet_t value_new = in_lo; 493 493 value_new <<= 32; … … 557 557 m_handle_lock->Lock(); 558 558 for (int i = 0; i < len; ++i) { 559 buf[i] = ntohl( buf[i] );559 buf[i] = CondSwap32( buf[i] ); 560 560 } 561 561 … … 569 569 570 570 for ( unsigned int i = 0; i < *resp_len; ++i ) { 571 result[i] = htonl( result[i] );571 result[i] = CondSwap32( result[i] ); 572 572 } 573 573 … … 1114 1114 if (result < 0) 1115 1115 return -1; 1116 return ntohl(buffer);1116 return CondSwap32(buffer); 1117 1117 } 1118 1118 trunk/libffado/src/libieee1394/IsoHandler.cpp
r1134 r1135 34 34 35 35 #include <errno.h> 36 #include <netinet/in.h>36 #include "libutil/ByteSwap.h" 37 37 #include <assert.h> 38 38 #include <unistd.h> trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.cpp
r1134 r1135 32 32 #include "libieee1394/cycletimer.h" 33 33 34 #include <netinet/in.h>34 #include "libutil/ByteSwap.h" 35 35 #include <assert.h> 36 36 … … 102 102 (length >= 2*sizeof(quadlet_t)); 103 103 if(ok) { 104 m_last_timestamp = sytRecvToFullTicks2((uint32_t) ntohs(packet->syt), pkt_ctr);104 m_last_timestamp = sytRecvToFullTicks2((uint32_t)CondSwap16(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) ntohs(packet->syt),110 uint64_t old_last_timestamp = sytRecvToFullTicks((uint32_t)CondSwap16(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)=( ntohl((*target_event) ) & 0x00FFFFFF);226 *(buffer)=(CondSwap32((*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 = ntohl(*target_event) & 0x00FFFFFF;260 unsigned int v = CondSwap32(*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)=( ntohl((*target_event) ) & 0x00FFFFFF);297 *(buffer)=(CondSwap32((*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 = ntohl(*target_event) & 0x00FFFFFF;331 unsigned int v = CondSwap32(*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= ntohl(*target_event);367 sample_int=CondSwap32(*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
r1134 r1135 35 35 #include "libieee1394/cycletimer.h" 36 36 37 #include <netinet/in.h>37 #include "libutil/ByteSwap.h" 38 38 #include <assert.h> 39 39 … … 353 353 // convert the timestamp to SYT format 354 354 uint16_t timestamp_SYT = TICKS_TO_SYT ( ts ); 355 packet->syt = htons( timestamp_SYT );355 packet->syt = CondSwap16 ( 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 = htonl((quadlet_t)tmp);685 *target_event = CondSwap32((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 = htonl((quadlet_t)((in & 0x00FFFFFF) | 0x40000000));841 *target_event = CondSwap32((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 = htonl((quadlet_t)((in & 0x00FFFFFF) | 0x40000000));886 *target_event = CondSwap32((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 = htonl((quadlet_t)tmp);935 *target_event = CondSwap32((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 = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));970 *target_event = CondSwap32(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 = htonl(tmpval);1003 *target_event = CondSwap32(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 = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));1013 *target_event = CondSwap32(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 = htonl(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA));1021 *target_event = CondSwap32(IEC61883_AM824_SET_LABEL(0, IEC61883_AM824_LABEL_MIDI_NO_DATA)); 1022 1022 } 1023 1023 } trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r1134 r1135 36 36 37 37 #include <math.h> 38 #include <netinet/in.h>38 #include "libutil/ByteSwap.h" 39 39 #include <assert.h> 40 40 … … 131 131 // for 2x rates, 32 for 4x rates). 132 132 quadlet_t *quadlet = (quadlet_t *)data; 133 unsigned int dbs = get_bits( ntohl(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size134 unsigned int fdf_size = get_bits( ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits133 unsigned int dbs = get_bits(CondSwap32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size 134 unsigned int fdf_size = get_bits(CondSwap32(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 = ntohl(*(quadlet_t *)(data+8+(n_events-1)*event_length));152 uint32_t last_sph = CondSwap32(*(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( ntohl(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size177 unsigned int fdf_size = get_bits( ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits176 unsigned int dbs = get_bits(CondSwap32(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size 177 unsigned int fdf_size = get_bits(CondSwap32(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
r1134 r1135 35 35 #include "libieee1394/cycletimer.h" 36 36 37 #include <netinet/in.h>37 #include "libutil/ByteSwap.h" 38 38 #include <assert.h> 39 39 … … 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 = htonl(lrintf(0x7fffff*sin((1000.0*2.0*M_PI/24576000.0)*a_cx)));295 signed int val = CondSwap32(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 = htonl(fullTicksToSph(ts_frame));311 *quadlet = CondSwap32(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 = htonl(fullTicksToSph(ts_frame));407 *quadlet = CondSwap32(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 = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));430 *quadlet = CondSwap32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 431 431 quadlet++; 432 *quadlet = htonl(0x8222ffff);432 *quadlet = CondSwap32(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 = htonl(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16));447 *quadlet = CondSwap32(0x00000400 | ((m_Parent.get1394Service().getLocalNodeId()&0x3f)<<24) | m_tx_dbc | (dbs<<16)); 448 448 quadlet++; 449 *quadlet = htonl(0x8222ffff);449 *quadlet = CondSwap32(0x8222ffff); 450 450 quadlet++; 451 451 *length = 8; trunk/libffado/src/libutil/ByteSwap.h
r1134 r1135 25 25 #define __FFADO_BYTESWAP__ 26 26 27 #include <netinet/in.h> 27 #include <byteswap.h> 28 #include <inttypes.h> 28 29 #include <endian.h> 29 30 #include <assert.h> … … 37 38 38 39 // no-op for big endian machines 40 41 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) 55 { 56 return d; 57 } 58 39 59 static inline void 40 60 byteSwapToBus(quadlet_t *data, unsigned int nb_elements) … … 50 70 51 71 #else 72 73 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); 89 } 52 90 53 91 #ifdef __SSE2__ … … 61 99 // Work input until data reaches 16 byte alignment 62 100 while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 63 *data = htonl(*data);101 *data = CondSwap32(*data); 64 102 data++; 65 103 nb_elements--; … … 98 136 // and do the remaining ones 99 137 while (nb_elements > 0) { 100 *data = htonl(*data);138 *data = CondSwap32(*data); 101 139 data++; 102 140 nb_elements--; … … 110 148 // Work input until data reaches 16 byte alignment 111 149 while ((((unsigned long)data) & 0xF) && nb_elements > 0) { 112 *data = htonl(*data);150 *data = CondSwap32(*data); 113 151 data++; 114 152 nb_elements--; … … 144 182 // and do the remaining ones 145 183 while (nb_elements > 0) { 146 *data = htonl(*data);184 *data = CondSwap32(*data); 147 185 data++; 148 186 nb_elements--; … … 157 195 unsigned int i=0; 158 196 for(; i<nb_elements; i++) { 159 *data = htonl(*data);197 *data = CondSwap32(*data); 160 198 data++; 161 199 } … … 167 205 unsigned int i=0; 168 206 for(; i<nb_elements; i++) { 169 *data = ntohl(*data);207 *data = CondSwap32(*data); 170 208 data++; 171 209 } trunk/libffado/src/libutil/cmd_serialize.cpp
r1134 r1135 27 27 #include <iomanip> 28 28 29 #include <netinet/in.h>29 #include "libutil/ByteSwap.h" 30 30 31 31 trunk/libffado/src/metrichalo/mh_avdevice.cpp
r1134 r1135 36 36 #include <stdint.h> 37 37 #include <assert.h> 38 #include <netinet/in.h>38 #include "libutil/ByteSwap.h" 39 39 #include <iostream> 40 40 #include <sstream> trunk/libffado/src/motu/motu_avdevice.cpp
r1134 r1135 44 44 #include <stdint.h> 45 45 #include <assert.h> 46 #include <netinet/in.h>46 #include "libutil/ByteSwap.h" 47 47 #include <iostream> 48 48 #include <sstream> … … 1389 1389 } 1390 1390 1391 return ntohl(quadlet);1391 return CondSwap32(quadlet); 1392 1392 } 1393 1393 … … 1398 1398 1399 1399 unsigned int err = 0; 1400 data = htonl(data);1400 data = CondSwap32(data); 1401 1401 1402 1402 // Note: 1394Service::write() expects a physical ID, not the node id trunk/libffado/src/rme/rme_avdevice.cpp
r1134 r1135 35 35 #include <stdint.h> 36 36 #include <assert.h> 37 #include <netinet/in.h>37 #include "libutil/ByteSwap.h" 38 38 39 39 #include <iostream> … … 252 252 debugError("Error doing RME read from register 0x%06x\n",reg); 253 253 } 254 return ntohl(quadlet);254 return CondSwap32(quadlet); 255 255 } 256 256 … … 259 259 260 260 unsigned int err = 0; 261 data = htonl(data);261 data = CondSwap32(data); 262 262 if (get1394Service().write(0xffc0 | getNodeId(), reg, 1, &data) <= 0) { 263 263 err = 1; trunk/libffado/tests/dumpiso_mod.cpp
r1134 r1135 21 21 #include "src/debugmodule/debugmodule.h" 22 22 #include "src/libstreaming/util/cip.h" 23 #include <netinet/in.h>23 #include "libutil/ByteSwap.h" 24 24 25 25 #define BUFFER 1000 … … 210 210 (length >= 2*sizeof(quadlet_t)); 211 211 if(ok) { 212 timestamp = sytRecvToFullTicks((uint32_t) ntohs(packet->syt),212 timestamp = sytRecvToFullTicks((uint32_t)CondSwap16(packet->syt), 213 213 cycle, cycle_timer); 214 214 } trunk/libffado/tests/scan-devreg.cpp
r1134 r1135 25 25 26 26 #include <libraw1394/raw1394.h> 27 #include <netinet/in.h>27 #include "libutil/ByteSwap.h" 28 28 29 29 #include "debugmodule/debugmodule.h" … … 284 284 continue; 285 285 } else { 286 quadlet = ntohl(quadlet);286 quadlet = CondSwap32(quadlet); 287 287 } 288 288 trunk/libffado/tests/streaming/test-isohandling.cpp
r1134 r1135 33 33 #include "src/debugmodule/debugmodule.h" 34 34 35 #include <netinet/in.h>35 #include "libutil/ByteSwap.h" 36 36 37 37 #include "src/libutil/PosixThread.h" trunk/libffado/tests/test-bufferops.cpp
r1134 r1135 65 65 66 66 for (i=0; i<nb_quadlets; i++) { 67 buffer_ref[i] = htonl(buffer_1[i]);67 buffer_ref[i] = CondSwap32(buffer_1[i]); 68 68 } 69 69 trunk/libffado/tests/test-ieee1394service.cpp
r1134 r1135 36 36 #include "src/debugmodule/debugmodule.h" 37 37 38 #include <netinet/in.h>38 #include "libutil/ByteSwap.h" 39 39 40 40 #include "src/libieee1394/cycletimer.h" trunk/libffado/tests/test-timestampedbuffer.cpp
r1134 r1135 35 35 #include "src/debugmodule/debugmodule.h" 36 36 37 #include <netinet/in.h>37 #include "libutil/ByteSwap.h" 38 38 39 39 #include "src/libieee1394/cycletimer.h"