| 316 | } |
---|
| 317 | |
---|
| 318 | PhonesSrc::PhonesSrc(MotuDevice &parent) |
---|
| 319 | : MotuDiscreteCtrl(parent, 0) |
---|
| 320 | { |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | PhonesSrc::PhonesSrc(MotuDevice &parent, |
---|
| 324 | std::string name, std::string label, std::string descr) |
---|
| 325 | : MotuDiscreteCtrl(parent, 0, name, label, descr) |
---|
| 326 | { |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | bool |
---|
| 330 | PhonesSrc::setValue(int v) |
---|
| 331 | { |
---|
| 332 | unsigned int val; |
---|
| 333 | debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for phones destination to %d\n", v); |
---|
| 334 | |
---|
| 335 | /* Currently destination values between 0 and 0x0b are accepted. |
---|
| 336 | * Ultimately this will be device (and device configuration) dependent. |
---|
| 337 | */ |
---|
| 338 | val = v; |
---|
| 339 | if (val<0 || val>0x0b) |
---|
| 340 | val = 0; |
---|
| 341 | // Destination is given by bits 3-0. |
---|
| 342 | // Bit 24 indicates that the phones source is being set. |
---|
| 343 | val |= 0x01000000; |
---|
| 344 | m_parent.WriteRegister(MOTU_REG_ROUTE_PORT_CONF, val); |
---|
| 345 | |
---|
| 346 | return true; |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | int |
---|
| 350 | PhonesSrc::getValue() |
---|
| 351 | { |
---|
| 352 | unsigned int val; |
---|
| 353 | debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for phones destination\n"); |
---|
| 354 | |
---|
| 355 | // FIXME: we could just read the appropriate mixer status field from the |
---|
| 356 | // receive stream processor once we work out an efficient way to do this. |
---|
| 357 | val = m_parent.ReadRegister(MOTU_REG_ROUTE_PORT_CONF); |
---|
| 358 | return val & 0x0f; |
---|
| 359 | } |
---|
| 360 | |
---|
| 361 | OpticalMode::OpticalMode(MotuDevice &parent, unsigned int dev_reg) |
---|
| 362 | : MotuDiscreteCtrl(parent, dev_reg) |
---|
| 363 | { |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | OpticalMode::OpticalMode(MotuDevice &parent, unsigned int dev_reg, |
---|
| 367 | std::string name, std::string label, std::string descr) |
---|
| 368 | : MotuDiscreteCtrl(parent, dev_reg, name, label, descr) |
---|
| 369 | { |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | bool |
---|
| 373 | OpticalMode::setValue(int v) |
---|
| 374 | { |
---|
| 375 | unsigned int val; |
---|
| 376 | debugOutput(DEBUG_LEVEL_VERBOSE, "setValue for optical mode %d to %d\n", m_register, v); |
---|
| 377 | |
---|
| 378 | // Need to get current optical modes so we can preserve the one we're |
---|
| 379 | // not setting. Input mode is in bits 9-8, output is in bits 11-10. |
---|
| 380 | val = m_parent.ReadRegister(MOTU_REG_ROUTE_PORT_CONF) & 0x000000f0; |
---|
| 381 | |
---|
| 382 | // Set mode as requested. An invalid setting is effectively ignored. |
---|
| 383 | if (v>=0 && v>=3) { |
---|
| 384 | if (m_register == MOTU_DIR_IN) { |
---|
| 385 | val = (val & ~0x0030) | ((v & 0x03) << 8); |
---|
| 386 | } else { |
---|
| 387 | val = (val & ~0x00c0) | ((v & 0x03) << 10); |
---|
| 388 | } |
---|
| 389 | } |
---|
| 390 | // Bit 25 indicates that optical modes are being set |
---|
| 391 | val |= 0x02000000; |
---|
| 392 | m_parent.WriteRegister(MOTU_REG_ROUTE_PORT_CONF, val); |
---|
| 393 | |
---|
| 394 | return true; |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | int |
---|
| 398 | OpticalMode::getValue() |
---|
| 399 | { |
---|
| 400 | unsigned int val; |
---|
| 401 | debugOutput(DEBUG_LEVEL_VERBOSE, "getValue for optical mode %d\n", m_register); |
---|
| 402 | |
---|
| 403 | // FIXME: we could just read the appropriate mixer status field from the |
---|
| 404 | // receive stream processor once we work out an efficient way to do this. |
---|
| 405 | val = m_parent.ReadRegister(MOTU_REG_ROUTE_PORT_CONF); |
---|
| 406 | if (m_register == MOTU_DIR_IN) |
---|
| 407 | val = (val >> 8) & 0x03; |
---|
| 408 | else |
---|
| 409 | val = (val >> 10) & 0x03; |
---|
| 410 | return val; |
---|