Changeset 1586
- Timestamp:
- 06/26/09 05:43:09 (14 years ago)
- Files:
-
- trunk/libffado/src/rme/fireface_def.h (modified) (3 diffs)
- trunk/libffado/src/rme/fireface_hw.cpp (modified) (7 diffs)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/rme/fireface_def.h
r1585 r1586 427 427 #define FF_TCO1_WORD_CLOCK_INPUT_2x FF_TCO1_WORD_CLOCK_INPUT_RATE0 428 428 #define FF_TCO1_WORD_CLOCK_INPUT_4x FF_TCO1_WORD_CLOCK_INPUT_RATE1 429 #define FF_TCO1_WORD_CLOCK_INPUT_MASK (FF_TCO1_WORD_CLOCK_INPUT_RATE0|FF_TCO1_WORD_CLOCK_INPUT_RATE1) 430 #define FF_TCO1_VIDEO_INPUT_MASK (FF_TCO1_VIDEO_INPUT_NTSC|FF_TCO1_VIDEO_INPUT_PAL) 429 431 #define FF_TC01_LTC_FORMAT_24fps 0 430 432 #define FF_TCO1_LTC_FORMAT_25fps FF_TCO1_LTC_FORMAT0 … … 433 435 #define FF_TCO1_LTC_FORMAT_30fps (FF_TCO1_LTC_FORMAT0|FF_TCO1_LTC_FORMAT1) 434 436 #define FF_TCO1_LTC_FORMAT_30dfps (FF_TCO1_LTC_FORMAT0|FF_TCO1_LTC_FORMAT1|FF_TCO1_SET_DROPFRAME) 437 #define FF_TCO1_LTC_FORMAT_MASK (FF_TCO1_LTC_FORMAT0|FF_TCO1_LTC_FORMAT1) 435 438 436 439 // TCO quadlet 2 … … 489 492 #define FF_TCOPARAM_TERMINATION_ON 1 490 493 494 // The state of the TCO 495 typedef struct { 496 unsigned int locked, ltc_valid; 497 unsigned int hours, minutes, seconds, frames; 498 unsigned int frame_rate; 499 unsigned int drop_frame; 500 unsigned int video_input; 501 unsigned int word_clock_state; 502 float sample_rate; 503 } FF_TCO_state_t; 504 505 // TCO state field defines 506 #define FF_TCOSTATE_FRAMERATE_24fps 1 507 #define FF_TCOSTATE_FRAMERATE_25fps 2 508 #define FF_TCOSTATE_FRAMERATE_29_97fps 3 509 #define FF_TCOSTATE_FRAMERATE_30fps 4 510 #define FF_TCOSTATE_VIDEO_NONE 0 511 #define FF_TCOSTATE_VIDEO_PAL 1 512 #define FF_TCOSTATE_VIDEO_NTSC 2 513 #define FF_TCOSTATE_WORDCLOCK_NONE 0 514 #define FF_TCOSTATE_WORDCLOCK_1x 1 515 #define FF_TCOSTATE_WORDCLOCK_2x 2 516 #define FF_TCOSTATE_WORDCLOCK_4x 3 517 491 518 #endif trunk/libffado/src/rme/fireface_hw.cpp
r1585 r1586 258 258 } 259 259 260 signed int Device::write_tco_settings(FF_TCO_settings_t tco_settings) 260 signed int Device::read_tco_state(FF_TCO_state_t *tco_state) 261 { 262 // Reads the current TCO state into the supplied state structure 263 264 quadlet_t tc[4]; 265 unsigned int PLL_phase; 266 267 if (read_tco(tc, 4) != 0) 268 return -1; 269 270 // The timecode is stored in BCD (binary coded decimal) in register 0. 271 tco_state->frames = (tc[0] & 0xf) + ((tc[0] & 0x30) >> 4)*10; 272 tco_state->seconds = ((tc[0] & 0xf00) >> 8) + ((tc[0] & 0x7000) >> 12)*10; 273 tco_state->minutes = ((tc[0] & 0xf0000) >> 16) + ((tc[0] & 0x700000) >> 20)*10; 274 tco_state->hours = ((tc[0] & 0xf000000) >> 24) + ((tc[0] & 0x30000000) >> 28)*10; 275 276 tco_state->locked = (tc[1] & FF_TCO1_TCO_lock) != 0; 277 tco_state->ltc_valid = (tc[1] & FF_TCO1_LTC_INPUT_VALID) != 0; 278 279 switch (tc[1] & FF_TCO1_LTC_FORMAT_MASK) { 280 case FF_TC01_LTC_FORMAT_24fps: 281 tco_state->frame_rate = FF_TCOSTATE_FRAMERATE_24fps; break; 282 case FF_TCO1_LTC_FORMAT_25fps: 283 tco_state->frame_rate = FF_TCOSTATE_FRAMERATE_25fps; break; 284 case FF_TC01_LTC_FORMAT_29_97fps: 285 tco_state->frame_rate = FF_TCOSTATE_FRAMERATE_29_97fps; break; 286 case FF_TCO1_LTC_FORMAT_30fps: 287 tco_state->frame_rate = FF_TCOSTATE_FRAMERATE_30fps; break; 288 } 289 290 tco_state->drop_frame = (tc[1] & FF_TCO1_SET_DROPFRAME) != 0; 291 292 switch (tc[1] & FF_TCO1_VIDEO_INPUT_MASK) { 293 case FF_TCO1_VIDEO_INPUT_NTSC: 294 tco_state->video_input = FF_TCOSTATE_VIDEO_NTSC; break; 295 case FF_TCO1_VIDEO_INPUT_PAL: 296 tco_state->video_input = FF_TCOSTATE_VIDEO_PAL; break; 297 default: 298 tco_state->video_input = FF_TCOSTATE_VIDEO_NONE; 299 } 300 301 if ((tc[1] & FF_TCO1_WORD_CLOCK_INPUT_VALID) == 0) { 302 tco_state->word_clock_state = FF_TCOSTATE_WORDCLOCK_NONE; 303 } else { 304 switch (tc[1] & FF_TCO1_WORD_CLOCK_INPUT_MASK) { 305 case FF_TCO1_WORD_CLOCK_INPUT_1x: 306 tco_state->word_clock_state = FF_TCOSTATE_WORDCLOCK_1x; break; 307 case FF_TCO1_WORD_CLOCK_INPUT_2x: 308 tco_state->word_clock_state = FF_TCOSTATE_WORDCLOCK_2x; break; 309 case FF_TCO1_WORD_CLOCK_INPUT_4x: 310 tco_state->word_clock_state = FF_TCOSTATE_WORDCLOCK_4x; break; 311 } 312 } 313 314 PLL_phase = (tc[2] & 0x7f) + ((tc[2] & 0x7f00) >> 1); 315 tco_state->sample_rate = (25000000.0 * 16.0)/PLL_phase; 316 317 return 0; 318 } 319 320 signed int Device::write_tco_settings(FF_TCO_settings_t *tco_settings) 261 321 { 262 322 // Writes the supplied application-level settings to the device's TCO … … 270 330 } 271 331 272 if (tco_settings .MTC)332 if (tco_settings->MTC) 273 333 tc[0] |= FF_TCO0_MTC; 274 334 275 switch (tco_settings .input) {335 switch (tco_settings->input) { 276 336 case FF_TCOPARAM_INPUT_LTC: 277 337 tc[2] |= FF_TCO2_INPUT_LTC; break; … … 282 342 } 283 343 284 switch (tco_settings .frame_rate) {344 switch (tco_settings->frame_rate) { 285 345 case FF_TCOPARAM_FRAMERATE_24fps: 286 346 tc[1] |= FF_TC01_LTC_FORMAT_24fps; break; … … 297 357 } 298 358 299 switch (tco_settings .word_clock) {359 switch (tco_settings->word_clock) { 300 360 case FF_TCOPARAM_WORD_CLOCK_CONV_1_1: 301 361 tc[2] |= FF_TCO2_WORD_CLOCK_CONV_1_1; break; … … 306 366 } 307 367 308 switch (tco_settings .sample_rate) {368 switch (tco_settings->sample_rate) { 309 369 case FF_TCOPARAM_SRATE_44_1: 310 370 tc[2] |= FF_TCO2_SRATE_44_1; break; … … 315 375 } 316 376 317 switch (tco_settings .pull) {377 switch (tco_settings->pull) { 318 378 case FF_TCPPARAM_PULL_NONE: 319 379 tc[2] |= FF_TCO2_PULL_0; break; … … 328 388 } 329 389 330 if (tco_settings .termination == FF_TCOPARAM_TERMINATION_ON)390 if (tco_settings->termination == FF_TCOPARAM_TERMINATION_ON) 331 391 tc[2] |= FF_TCO2_SET_TERMINATION; 332 392 trunk/libffado/src/rme/rme_avdevice.h
r1584 r1586 120 120 signed int write_tco(quadlet_t *tco_data, signed int size); 121 121 122 signed int write_tco_settings(FF_TCO_settings_t tco_settings); 122 signed int read_tco_state(FF_TCO_state_t *tco_state); 123 signed int write_tco_settings(FF_TCO_settings_t *tco_settings); 123 124 124 125 };