Changeset 981
- Timestamp:
- 03/24/08 16:00:49 (16 years ago)
- Files:
-
- trunk/libffado/config.h.in (modified) (3 diffs)
- trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.h (modified) (3 diffs)
- trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp (modified) (1 diff)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (7 diffs)
- trunk/libffado/src/motu/motu_avdevice.h (modified) (1 diff)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (4 diffs)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/config.h.in
r956 r981 138 138 // then used to stamp the packet and determine the transmission 139 139 // time instant. 140 #define MOTU_TRANSMIT_TRANSFER_DELAY (11776U) 140 //#define MOTU_TRANSMIT_TRANSFER_DELAY (11776U) 141 //#define MOTU_TRANSMIT_TRANSFER_DELAY (3072U) 142 #define MOTU_TRANSMIT_TRANSFER_DELAY (0U) 141 143 142 144 // the absolute minimum number of cycles we want to transmit … … 146 148 // are too late for that, this constant defines how late we can 147 149 // be. 148 #define MOTU_MIN_CYCLES_BEFORE_PRESENTATION 1150 #define MOTU_MIN_CYCLES_BEFORE_PRESENTATION 0 149 151 150 152 // the absolute maximum number of cycles we want to transmit … … 153 155 // given by MOTU_TRANSMIT_TRANSFER_DELAY (in ticks), but we can send 154 156 // packets early if we want to. 155 #define MOTU_MAX_CYCLES_TO_TRANSMIT_EARLY 6 157 //#define MOTU_MAX_CYCLES_TO_TRANSMIT_EARLY 6 158 #define MOTU_MAX_CYCLES_TO_TRANSMIT_EARLY 2 156 159 157 160 // ensure that the MOTU tx SP clips all float values to [-1.0..1.0] trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.cpp
r928 r981 73 73 : StreamProcessor(parent, ePT_Receive) 74 74 , m_event_size( event_size ) 75 {} 75 { 76 memset(&m_devctrls, 0, sizeof(m_devctrls)); 77 } 76 78 77 79 unsigned int … … 204 206 { 205 207 bool no_problem=true; 208 209 /* Scan incoming block for device control events */ 210 decodeMotuCtrlEvents(data, nevents); 211 206 212 for ( PortVectorIterator it = m_Ports.begin(); 207 213 it != m_Ports.end(); … … 338 344 } 339 345 346 int 347 MotuReceiveStreamProcessor::decodeMotuCtrlEvents( 348 char *data, unsigned int nevents) 349 { 350 unsigned int j = 0; 351 unsigned char *src = NULL; 352 unsigned char *arg = NULL; 353 354 // Get control bytes if present in any frames within the packet. The 355 // device control messages start at (zero-based) byte 0x04 in the data 356 // stream. 357 src = (unsigned char *)data + 0x04; 358 arg = src+1; 359 while (j < nevents) { 360 361 if (m_devctrls.status == MOTU_DEVCTRL_INVALID) { 362 // Start acquiring on reception of a key which we know occurs 363 // only once per cycle. The only potential problem with this is if 364 // this key can interrupt a sequence of other keys. Time will tell 365 // whether the assumption that it doesn't is valid. 366 if (*src == MOTU_KEY_MAINOUT_VOL) { 367 debugOutput(DEBUG_LEVEL_VERBOSE, "acquiring device control status events\n"); 368 m_devctrls.status = MOTU_DEVCTRL_ACQUIRING; 369 } 370 } else 371 if (m_devctrls.status == MOTU_DEVCTRL_ACQUIRING) { 372 // If our "once per cycle" key occurs in the acquiring state we 373 // know we've been right through the control event cycle, making 374 // our picture of the device status complete. See note above 375 // for the caveats with this logic. 376 if (*src == MOTU_KEY_MAINOUT_VOL) { 377 debugOutput(DEBUG_LEVEL_VERBOSE, "device control status collection valid\n"); 378 m_devctrls.status = MOTU_DEVCTRL_VALID; 379 } 380 } 381 382 if (m_devctrls.status != MOTU_DEVCTRL_INVALID) { 383 switch (*src) { 384 case MOTU_KEY_CHANNEL_GAIN: 385 case MOTU_KEY_CHANNEL_PAN: 386 case MOTU_KEY_CHANNEL_CTRL: 387 case MOTU_KEY_MIXBUS_GAIN: 388 case MOTU_KEY_MIXBUS_DEST: 389 case MOTU_KEY_MAINOUT_VOL: 390 case MOTU_KEY_PHONES_VOL: 391 case MOTU_KEY_PHONES_DEST: 392 case MOTU_KEY_INPUT_6dB_BOOST: 393 case MOTU_KEY_INPUT_REF_LEVEL: 394 break; 395 case MOTU_KEY_MIDI: 396 // MIDI is dealt with elsewhere, so just pass it over 397 break; 398 default: 399 // Ignore any unknown keys or those we don't care about, at 400 // least for now. 401 break; 402 } 403 } 404 j++; 405 src += m_event_size; 406 arg += m_event_size; 407 } 408 409 return 0; 410 } 411 340 412 } // end of namespace Streaming trunk/libffado/src/libstreaming/motu/MotuReceiveStreamProcessor.h
r873 r981 36 36 37 37 namespace Streaming { 38 39 #define MOTUFW_MAX_MIXBUSES 4 40 #define MOTUFW_MAX_MIXBUS_CHANNELS 20 41 42 #define MOTU_CHANNEL_NORMAL 0x00 43 #define MOTU_CHANNEL_MUTE 0x01 44 #define MOTU_CHANNEL_SOLO 0x02 45 #define MOTU_CHANNEL_PAIRED 0x08 46 47 #define MOTU_CHANNEL_PAN_LEFT 0x00 48 #define MOTU_CHANNEL_PAN_RIGHT 0x80 49 #define MOTU_CHANNEL_PAN_CENTRE 0x40 50 51 #define MOTU_DEST_DISABLED 0x00 52 #define MOTU_DEST_HEADPHONE 0x01 53 #define MOTU_DEST_ANALOG1_2 0x02 54 #define MOTU_DEST_ANALOG3_4 0x03 55 #define MOTU_DEST_ANALOG5_6 0x04 56 #define MOTU_DEST_ANALOG7_8 0x05 57 #define MOTU_DEST_AESEBU 0x06 58 #define MOTU_DEST_SPDIF 0x07 59 #define MOTU_DEST_ADAT1_1_2 0x08 60 #define MOTU_DEST_ADAT1_3_4 0x09 61 #define MOTU_DEST_ADAT1_5_6 0x0a 62 #define MOTU_DEST_ADAT1_7_8 0x0b 63 #define MOTU_DEST_MUTE 0x10 64 65 enum EMotuDevCtrlStatus { 66 MOTU_DEVCTRL_INVALID = 0x00, 67 MOTU_DEVCTRL_ACQUIRING = 0x01, 68 MOTU_DEVCTRL_VALID = 0x02, 69 }; 70 71 struct MotuDevControls { 72 unsigned int status, lastkey; 73 unsigned int input_6dB_boost; 74 unsigned int input_ref_level; 75 unsigned int input_20dB_pad; 76 unsigned int input_gaintrim[MOTUFW_MAX_MIXBUS_CHANNELS]; 77 unsigned char input_gaintrim_index; 78 struct MixBus { 79 unsigned char channel_gain[MOTUFW_MAX_MIXBUS_CHANNELS]; 80 unsigned char channel_gain_index; 81 unsigned char channel_pan[MOTUFW_MAX_MIXBUS_CHANNELS]; 82 unsigned char channel_pan_index; 83 unsigned char channel_control[MOTUFW_MAX_MIXBUS_CHANNELS]; 84 unsigned char channel_control_index; 85 unsigned char bus_gain; 86 unsigned char bus_dest; 87 } mixbus[MOTUFW_MAX_MIXBUSES]; 88 unsigned char mixbus_index; 89 unsigned char main_out_volume; 90 unsigned char phones_volume; 91 unsigned char phones_assign; 92 }; 93 94 enum EMotuCtrlKeys { 95 MOTU_KEY_MIDI = 0x01, 96 MOTU_KEY_CHANNEL_GAIN = 0x14, 97 MOTU_KEY_CHANNEL_PAN = 0x1c, 98 MOTU_KEY_CHANNEL_CTRL = 0x24, 99 MOTU_KEY_MIXBUS_GAIN = 0x2c, 100 MOTU_KEY_MIXBUS_DEST = 0x34, 101 MOTU_KEY_MAINOUT_VOL = 0x3c, 102 MOTU_KEY_PHONES_VOL = 0x44, 103 MOTU_KEY_PHONES_DEST = 0x4c, 104 MOTU_KEY_INPUT_6dB_BOOST = 0x6c, 105 MOTU_KEY_INPUT_REF_LEVEL = 0x74, 106 }; 38 107 39 108 class MotuAudioPort; … … 85 154 int decodeMotuEventsToPort(MotuAudioPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 86 155 int decodeMotuMidiEventsToPort(MotuMidiPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 156 int decodeMotuCtrlEvents(char *data, unsigned int nevents); 87 157 88 158 /* … … 91 161 */ 92 162 unsigned int m_event_size; 163 164 struct MotuDevControls m_devctrls; 165 93 166 }; 94 167 trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.cpp
r952 r981 298 298 #endif 299 299 300 //fprintf(stderr,"tx: %d/%d\n", 301 // TICKS_TO_CYCLES(fullTicksToSph(m_last_timestamp)), 302 // TICKS_TO_OFFSET(fullTicksToSph(m_last_timestamp))); 300 303 // Set up each frames's SPH. 304 //fprintf(stderr,"tpf=%f\n", ticks_per_frame); 301 305 for (int i=0; i < n_events; i++, quadlet += dbs) { 302 306 int64_t ts_frame = addTicks(m_last_timestamp, (unsigned int)lrintf(i * ticks_per_frame)); 303 307 *quadlet = htonl(fullTicksToSph(ts_frame)); 308 //fprintf(stderr,"tx: %d/%d\n", 309 // CYCLE_TIMER_GET_CYCLES(fullTicksToSph(ts_frame)), 310 // CYCLE_TIMER_GET_OFFSET(fullTicksToSph(ts_frame))); 304 311 } 305 312 trunk/libffado/src/motu/motu_avdevice.cpp
r950 r981 149 149 {"Phones-L", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 10}, 150 150 {"Phones-R", MOTUFW_DIR_OUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 13}, 151 {"Analog1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 16}, 152 {"Analog2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 19}, 153 {"Analog3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 22}, 154 {"Analog4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 25}, 155 {"Analog5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 28}, 156 {"Analog6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 31}, 157 {"Analog7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 34}, 158 {"Analog8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_ANY|MOTUFW_PA_OPTICAL_ANY, 37}, 151 {"Analog1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 16}, 152 {"Analog1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 10}, 153 {"Analog2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 19}, 154 {"Analog2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 13}, 155 {"Analog3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 22}, 156 {"Analog3", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 16}, 157 {"Analog4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 25}, 158 {"Analog4", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 19}, 159 {"Analog5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 28}, 160 {"Analog5", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 22}, 161 {"Analog6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 31}, 162 {"Analog6", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 25}, 163 {"Analog7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 34}, 164 {"Analog7", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 28}, 165 {"Analog8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 37}, 166 {"Analog8", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_4x|MOTUFW_PA_OPTICAL_ANY, 31}, 159 167 {"AES/EBU1", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 40}, 160 168 {"AES/EBU2", MOTUFW_DIR_INOUT, MOTUFW_PA_RATE_1x2x|MOTUFW_PA_OPTICAL_ANY, 43}, … … 255 263 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Motu::MotuDevice (NodeID %d)\n", 256 264 getConfigRom().getNodeId() ); 257 258 265 } 259 266 … … 276 283 { 277 284 unsigned int vendorId = configRom.getNodeVendorId(); 278 // unsigned int modelId = configRom.getModelId();279 285 unsigned int unitVersion = configRom.getUnitVersion(); 280 286 unsigned int unitSpecifierId = configRom.getUnitSpecifierId(); … … 285 291 { 286 292 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 287 // && ( supportedDeviceList[i].model_id == modelId )288 293 && ( supportedDeviceList[i].unit_version == unitVersion ) 289 294 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) … … 307 312 { 308 313 unsigned int vendorId = getConfigRom().getNodeVendorId(); 309 // unsigned int modelId = getConfigRom().getModelId();310 314 unsigned int unitVersion = getConfigRom().getUnitVersion(); 311 315 unsigned int unitSpecifierId = getConfigRom().getUnitSpecifierId(); … … 316 320 { 317 321 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 318 // && ( supportedDeviceList[i].model_id == modelId )319 322 && ( supportedDeviceList[i].unit_version == unitVersion ) 320 323 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) … … 817 820 unsigned int opt_ctrl = 0x0000002; 818 821 822 /* THe 896HD doesn't have an SPDIF/TOSLINK optical mode, so don't try to 823 * set it 824 */ 825 if (m_motu_model==MOTUFW_MODEL_896HD && mode==MOTUFW_OPTICAL_MODE_TOSLINK) 826 return -1; 827 819 828 // Set up the optical control register value according to the current 820 829 // optical port modes. At this stage it's not completely understood trunk/libffado/src/motu/motu_avdevice.h
r962 r981 91 91 92 92 enum EMotuModel { 93 94 95 96 97 98 99 93 MOTUFW_MODEL_NONE = 0x0000, 94 MOTUFW_MODEL_828mkII = 0x0001, 95 MOTUFW_MODEL_TRAVELER = 0x0002, 96 MOTUFW_MODEL_ULTRALITE= 0x0003, 97 MOTUFW_MODEL_8PRE = 0x0004, 98 MOTUFW_MODEL_828MkI = 0x0005, 99 MOTUFW_MODEL_896HD = 0x0006, 100 100 }; 101 101 trunk/libffado/src/rme/rme_avdevice.cpp
r929 r981 56 56 , m_model( NULL ) 57 57 , m_rme_model( RME_MODEL_NONE ) 58 , m_ddsFreq( -1 ) 58 59 { 59 60 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Rme::RmeDevice (NodeID %d)\n", … … 124 125 RmeDevice::getSamplingFrequency( ) { 125 126 /* 126 * Retrieve the current sample rate from the RME device. 127 * Retrieve the current sample rate from the RME device. At this stage it 128 * seems that the "current rate" can't be retrieved from the device. Other 129 * drivers don't read the DDS control register and there isn't anywhere else 130 * where the frequency is sent back to the PC. Unless we test the DDS 131 * control register for readabilty and find it can be read we'll assume it 132 * can't and instead cache the DDS frequency. 133 * 134 * If the device frequency has not been set this function will return -1 135 * (the default value of m_ddsFreq). 127 136 */ 128 return 48000;137 return m_ddsFreq; 129 138 } 130 139 … … 139 148 { 140 149 /* 141 * Set the RME device's samplerate. 150 * Set the RME device's samplerate. The RME can do sampling frequencies of 151 * 32k, 44.1k and 48k along with the corresponding 2x and 4x rates. 152 * However, it can also do +/- 4% from any of these "base" frequencies. 153 * This makes it a little long-winded to work out whether a given frequency 154 * is supported or not. 142 155 */ 143 if (samplingFrequency == 48000) 144 return true; 145 return false; 156 157 /* Work out whether the requested rate is supported */ 158 if (!((samplingFrequency >= 32000*0.96 && samplingFrequency <= 32000*1.04) || 159 (samplingFrequency >= 44100*0.96 && samplingFrequency <= 44100*1.04) || 160 (samplingFrequency >= 48000*0.96 && samplingFrequency <= 48000*1.04) || 161 (samplingFrequency >= 64000*0.96 && samplingFrequency <= 64000*1.04) || 162 (samplingFrequency >= 88200*0.96 && samplingFrequency <= 88200*1.04) || 163 (samplingFrequency >= 96000*0.96 && samplingFrequency <= 96000*1.04) || 164 (samplingFrequency >= 128000*0.96 && samplingFrequency <= 128000*1.04) || 165 (samplingFrequency >= 176000*0.96 && samplingFrequency <= 176000*1.04) || 166 (samplingFrequency >= 192000*0.96 && samplingFrequency <= 192000*1.04))) { 167 return false; 168 } 169 170 /* Send the desired frequency to the RME */ 171 if (writeRegister(RME_REG_DDS_CONTROL, samplingFrequency) != 0) 172 return false; 173 174 m_ddsFreq = samplingFrequency; 175 return true; 146 176 } 147 177 … … 213 243 } 214 244 215 } 245 unsigned int 246 RmeDevice::readRegister(unsigned int reg) { 247 248 quadlet_t quadlet; 249 250 quadlet = 0; 251 if (get1394Service().read(0xffc0 | getNodeId(), reg, 1, &quadlet) < 0) { 252 debugError("Error doing RME read from register 0x%06x\n",reg); 253 } 254 return ntohl(quadlet); 255 } 256 257 signed int 258 RmeDevice::writeRegister(unsigned int reg, quadlet_t data) { 259 260 unsigned int err = 0; 261 data = htonl(data); 262 if (get1394Service().write(0xffc0 | getNodeId(), reg, 1, &data) < 0) { 263 err = 1; 264 debugError("Error doing RME write to register 0x%06x\n",reg); 265 } 266 // SleepRelativeUsec(100); 267 return (err==0)?0:-1; 268 } 269 270 } trunk/libffado/src/rme/rme_avdevice.h
r929 r981 32 32 33 33 // #include "libstreaming/rme/RmeStreamProcessor.h" 34 35 /* RME Fireface register definitions */ 36 #define RME_REG_DDS_CONTROL 0xfc88f000 34 37 35 38 class ConfigRom; … … 88 91 virtual bool stopStreamByIndex(int i); 89 92 93 unsigned int readRegister(unsigned int reg); 94 signed int writeRegister(unsigned int reg, quadlet_t data); 95 90 96 protected: 91 97 struct VendorModelEntry *m_model; 92 98 enum ERmeModel m_rme_model; 99 100 signed int m_ddsFreq; 93 101 }; 94 102