Index: /branches/libfreebob-motu/tests/test-freebob.c =================================================================== --- /branches/libfreebob-motu/tests/test-freebob.c (revision 185) +++ /branches/libfreebob-motu/tests/test-freebob.c (revision 197) @@ -22,4 +22,5 @@ #include "libfreebob/freebob.h" +#include "libfreebob/freebob_bounce.h" #include Index: /branches/libfreebob-motu/tests/freebob-server.c =================================================================== --- /branches/libfreebob-motu/tests/freebob-server.c (revision 185) +++ /branches/libfreebob-motu/tests/freebob-server.c (revision 197) @@ -37,4 +37,7 @@ #include +#include "../libfreebob/freebob.h" +#include "../libfreebob/freebob_bounce.h" + const char not_compatible[] = "\n" "This libraw1394 does not work with your version of Linux. You need a different\n" @@ -47,8 +50,4 @@ -unsigned char g_signal_mode = 0x05; // SD 525-60, TODO: get from media -unsigned char g_transport_mode = AVC1394_VCR_CMD_WIND; -unsigned char g_transport_state = AVC1394_VCR_OPERAND_WIND_STOP; - static int g_done = 0; @@ -64,78 +63,26 @@ switch ( cr->opcode ) { - case AVC1394_VCR_CMD_PLAY: - switch ( cr->operand[0] ) - { - case AVC1394_VCR_OPERAND_PLAY_FORWARD: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = AVC1394_VCR_OPERAND_PLAY_FORWARD; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY FORWARD\n"); - break; + default: + fprintf( stderr, "subunit control command 0x%02x non supported\n", cr->opcode ); + return 0; + } + return 1; +} + +int subunit_status( avc1394_cmd_rsp *cr ) +{ + + fprintf( stderr, "subunit STATUS\n"); + char *buffer; + switch ( cr->opcode ) + { + case (AVC1394_CMD_INPUT_PLUG_SIGNAL_FORMAT): + + cr->status = AVC1394_RESP_STABLE; + buffer=(char*)&cr->operand[1]; + fprintf( stderr, "subunit AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT\n"); - case AVC1394_VCR_OPERAND_PLAY_FASTEST_FORWARD: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = AVC1394_VCR_OPERAND_PLAY_FASTEST_FORWARD; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY FASTEST FORWARD\n"); - break; - - case AVC1394_VCR_OPERAND_PLAY_REVERSE_PAUSE: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = cr->operand[0]; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PAUSE PLAY\n"); - break; - - case AVC1394_VCR_OPERAND_PLAY_REVERSE: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = AVC1394_VCR_OPERAND_PLAY_REVERSE; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY REVERSE\n"); - break; - - case AVC1394_VCR_OPERAND_PLAY_FASTEST_REVERSE: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = AVC1394_VCR_OPERAND_PLAY_FASTEST_REVERSE; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY FASTEST REVERSE\n"); - break; - - case AVC1394_VCR_OPERAND_PLAY_NEXT_FRAME: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = cr->operand[0]; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY NEXT FRAME\n"); - break; - - case AVC1394_VCR_OPERAND_PLAY_PREVIOUS_FRAME: - g_transport_mode = AVC1394_GET_OPCODE( AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY ); - g_transport_state = cr->operand[0]; - cr->status = AVC1394_RESP_ACCEPTED; - printf("PLAY PREVIOUS FRAME\n"); - break; - - default: - fprintf( stderr, "play mode 0x%02x non supported\n", cr->operand[0] ); - return 0; - } + strncpy(buffer,"TEST123",sizeof(byte_t)*9); break; - - default: - fprintf( stderr, "subunit control command 0x%02x non supported\n", cr->opcode ); - return 0; - } - return 1; -} - - -int subunit_status( avc1394_cmd_rsp *cr ) -{ - switch ( cr->opcode ) - { - case AVC1394_VCR_CMD_OUTPUT_SIGNAL_MODE: - cr->status = AVC1394_RESP_STABLE; - cr->operand[0] = g_signal_mode; - break; default: fprintf( stderr, "subunit status command 0x%02x not supported\n", cr->opcode ); @@ -150,14 +97,4 @@ switch ( cr->opcode ) { - case AVC1394_VCR_CMD_PLAY: - case AVC1394_VCR_CMD_RECORD: - case AVC1394_VCR_CMD_WIND: - case AVC1394_VCR_CMD_OUTPUT_SIGNAL_MODE: - case AVC1394_VCR_CMD_INPUT_SIGNAL_MODE: - case AVC1394_VCR_CMD_TRANSPORT_STATE: - case AVC1394_VCR_CMD_TIME_CODE: - case AVC1394_VCR_CMD_MEDIUM_INFO: - cr->status = AVC1394_RESP_IMPLEMENTED; - return 1; default: fprintf( stderr, "subunit inquiry command 0x%02x not supported\n", cr->opcode ); @@ -183,8 +120,8 @@ int unit_status( avc1394_cmd_rsp *cr ) { - cr->operand[1] = 0xff; - cr->operand[2] = 0xff; - cr->operand[3] = 0xff; - cr->operand[4] = 0xff; + cr->operand[1] = 0x00; + cr->operand[2] = 0x00; + cr->operand[3] = 0x00; + cr->operand[4] = 0x00; switch ( cr->opcode ) { @@ -192,5 +129,5 @@ cr->status = AVC1394_RESP_STABLE; cr->operand[0] = AVC1394_OPERAND_UNIT_INFO_EXTENSION_CODE; - cr->operand[1] = AVC1394_SUBUNIT_TYPE_TAPE_RECORDER >> 19; + cr->operand[1] = AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER >> 19; break; case AVC1394_CMD_SUBUNIT_INFO: @@ -201,5 +138,5 @@ cr->status = AVC1394_RESP_STABLE; cr->operand[0] = (page << 4) | AVC1394_OPERAND_UNIT_INFO_EXTENSION_CODE; - cr->operand[1] = AVC1394_SUBUNIT_TYPE_TAPE_RECORDER >> 19 << 3; + cr->operand[1] = AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER >> 19 << 3; } @@ -239,5 +176,5 @@ switch ( cr->subunit_type ) { - case AVC1394_SUBUNIT_TAPE_RECORDER: + case AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER: if ( cr->subunit_id != 0 ) { @@ -353,5 +290,5 @@ /* change the vendor description for kicks */ i = strlen(dir.textual_leafs[0]); - strncpy(dir.textual_leafs[0], "FreeBob Server ", i); + strncpy(dir.textual_leafs[0], FREEBOB_BOUNCE_SERVER_VENDORNAME " ", i); retval = rom1394_set_directory(rom, &dir); printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size); @@ -369,5 +306,5 @@ dir.unit_spec_id = 0x0000a02d; dir.unit_sw_version = 0x00010001; - leaf = "freebob-server"; + leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; dir.nr_textual_leafs = 1; dir.textual_leafs = &leaf; Index: /branches/libfreebob-motu/src/devicemanager.h =================================================================== --- /branches/libfreebob-motu/src/devicemanager.h (revision 185) +++ /branches/libfreebob-motu/src/devicemanager.h (revision 197) @@ -59,4 +59,5 @@ static IAvDevice* probeBeBoB(Ieee1394Service& service, int id, int level); static IAvDevice* probeBounce(Ieee1394Service& service, int id, int level); + static IAvDevice* probeMotu(Ieee1394Service& service, int id, int level); protected: Index: /branches/libfreebob-motu/src/motu/motu_avdevice.h =================================================================== --- /branches/libfreebob-motu/src/motu/motu_avdevice.h (revision 197) +++ /branches/libfreebob-motu/src/motu/motu_avdevice.h (revision 197) @@ -0,0 +1,157 @@ +/* motu_avdevice.h + * Copyright (C) 2006 by Pieter Palmers + * + * This file is part of FreeBob. + * + * FreeBob is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * FreeBob is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FreeBob; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA. + */ + +#ifndef MOTUDEVICE_H +#define MOTUDEVICE_H + +#include "iavdevice.h" + +#include "debugmodule/debugmodule.h" +#include "libfreebobavc/avc_definitions.h" +#include "libfreebob/xmlparser.h" + +#define MOTU_BASE_ADDR 0xfffff0000000ULL +#define MOTU_BASE_RATE_44100 (0<<4) +#define MOTU_BASE_RATE_48000 (1<<4) +#define MOTU_RATE_MULTIPLIER_1X (0<<5) +#define MOTU_RATE_MULTIPLIER_2X (1<<5) +#define MOTU_RATE_MULTIPLIER_4X (2<<5) +#define MOTU_RATE_MASK (0x00000007) + + +class ConfigRom; +class Ieee1394Service; + +namespace Motu { + +class MotuDevice : public IAvDevice { +public: + MotuDevice( Ieee1394Service& ieee1394Service, + int nodeId, + int verboseLevel ); + virtual ~MotuDevice(); + + virtual bool discover(); + virtual ConfigRom& getConfigRom() const; + virtual bool addXmlDescription( xmlNodePtr deviceNode ); + virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); + virtual void showDevice() const; + +protected: + Ieee1394Service* m_1394Service; + ConfigRom* m_configRom; + int m_nodeId; + int m_verboseLevel; + +private: + unsigned int ReadRegister(unsigned int reg); + signed int WriteRegister(unsigned int reg, quadlet_t data); + + /* ======================================================================= */ + /* MOTU-related defines, definitions, enumerations etc */ + + /* IEEE1394 Vendor IDs. One would expect only MOTU, but you never know if a + * clone might appear some day. + */ + enum EVendorId { + VENDOR_MOTU = 0x000001f2, + VENDOR_MOTU_TEST = 0x0000030D, + }; + + /* IEEE1394 Model IDs for different MOTU hardware */ + enum EModelId { + MOTU_828mkII = 0x00101800, + MOTU_TRAVELER = 0x00104800, + MOTU_TEST = 0x00000000, + }; + + /* Input/Output channels. Channels are included here even if they are + * uni-directional (eg: phones - which is output only). It is up to + * individual functions taking a motufw_io_channel_t argument to ensure + * that operations are appropriate for the channel supplied. + */ + enum EIoChannel { + MOTUFW_IO_ANALOG1, MOTUFW_IO_ANALOG2, MOTUFW_IO_ANALOG3, + MOTUFW_IO_ANALOG4, MOTUFW_IO_ANALOG5, MOTUFW_IO_ANALOG6, + MOTUFW_IO_ANALOG7, MOTUFW_IO_ANALOG8, + MOTUFW_IO_AESEBU_L, MOTUFW_IO_AESEBU_R, /* Traveler only */ + MOTUFW_IO_MAIN_L, MOTUFW_IO_MAIN_R, /* 828MkII only */ + MOTUFW_IO_SPDIF_L, MOTUFW_IO_SPDIF_R, + MOTUFW_IO_ADAT1, MOTUFW_IO_ADAT2, MOTUFW_IO_ADAT3, + MOTUFW_IO_ADAT4, MOTUFW_IO_ADAT5, MOTUFW_IO_ADAT6, + MOTUFW_IO_ADAT7, MOTUFW_IO_ADAT8, + }; + + /* Stereo output buses */ + enum EOutputBus { + MOTUFW_OUTPUT_DISABLED , + MOTUFW_OUTPUT_PHONES, + MOTUFW_OUTPUT_ANALOG1_2, MOTUFW_OUTPUT_ANALOG3_4, + MOTUFW_OUTPUT_ANALOG5_6, MOTUFW_OUTPUT_ANALOG7_8, + MOTUFW_OUTPUT_AESEBU, MOTUFW_OUTPUT_MAINPOUT, + MOTUFW_OUTPUT_SPDIF, + MOTUFW_OUTPUT_ADAT1_2, MOTUFW_OUTPUT_ADAT3_4, + MOTUFW_OUTPUT_ADAT5_6, MOTUFW_OUTPUT_ADAT7_8, + }; + + /* Cuemix mixers available */ + enum ECuemixMixer { + MOTUFW_CUEMIX_MIX1, + MOTUFW_CUEMIX_MIX2, + MOTUFW_CUEMIX_MIX3, + MOTUFW_CUEMIX_MIX4, + }; + + /* MOTU configuration details */ + enum ESampleRate { + MOTUFW_SAMPLERATE_44k1, MOTUFW_SAMPLERATE_48k, + MOTUFW_SAMPLERATE_88k2, MOTUFW_SAMPLERATE_96k, + MOTUFW_SAMPLERATE_176k4, MOTUFW_SAMPLERATE_192k, + }; + + enum EClockSource { + MOTUFW_CLOCKSOURCE_INT, + MOTUFW_CLOCKSOURCE_SMPTE, + MOTUFW_CLOCKSOURCE_AESEBU, + MOTUFW_CLOCKSOURCE_SPDIF, + MOTUFW_CLOCKSOURCE_TOSLINK, + MOTUFW_CLOCKSOURCE_WORDCLOCK, + MOTUFW_CLOCKSOURCE_ADAT_9PIN, + MOTUFW_CLOCKSOURCE_ADAT_OPTICAL, + }; + + enum ERefLevel{ + MOTUFW_REFLEVEL_PLUS4_DBU, MOTUFW_REFLEVEL_MINUS10_DBU, + }; + + enum EOpticalMode { + MOTUFW_OPTICAL_MODE_OFF, + MOTUFW_OPTICAL_MODE_ADAT, + MOTUFW_OPTICAL_MODE_TOSLINK, + }; + + + // debug support + DECLARE_DEBUG_MODULE; +}; + +} + +#endif Index: /branches/libfreebob-motu/src/motu/motu_avdevice.cpp =================================================================== --- /branches/libfreebob-motu/src/motu/motu_avdevice.cpp (revision 197) +++ /branches/libfreebob-motu/src/motu/motu_avdevice.cpp (revision 197) @@ -0,0 +1,227 @@ +/* motu_avdevice.cpp + * Copyright (C) 2006 by Pieter Palmers + * + * This file is part of FreeBob. + * + * FreeBob is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * FreeBob is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FreeBob; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA. + */ + +#include "motu/motu_avdevice.h" +#include "configrom.h" + +#include "libfreebobavc/ieee1394service.h" +#include "libfreebobavc/avc_definitions.h" + +#include "debugmodule/debugmodule.h" + +#include +#include +#include +#include + +namespace Motu { + +IMPL_DEBUG_MODULE( MotuDevice, MotuDevice, DEBUG_LEVEL_NORMAL ); + +MotuDevice::MotuDevice( Ieee1394Service& ieee1394service, + int nodeId, + int verboseLevel ) + : m_1394Service( &ieee1394service ) + , m_nodeId( nodeId ) + , m_verboseLevel( verboseLevel ) +{ + if ( m_verboseLevel ) { + setDebugLevel( DEBUG_LEVEL_VERBOSE ); + } + debugOutput( DEBUG_LEVEL_VERBOSE, "Created Motu::MotuDevice (NodeID %d)\n", + nodeId ); + m_configRom = new ConfigRom( m_1394Service, m_nodeId ); + m_configRom->initialize(); + +} + +MotuDevice::~MotuDevice() +{ + delete m_configRom; +} + +ConfigRom& +MotuDevice::getConfigRom() const +{ + return *m_configRom; +} + +bool +MotuDevice::discover() +{ + signed int i, is_motu_fw_audio; + + /* A list of all IEEE1394 Vendor IDs used by MOTU. One would expect this to + * include only one, but stranger things have happened in this world. The + * list is terminated with a 0xffffffff value. + */ + const unsigned int motu_vendor_ids[] = { + VENDOR_MOTU, + VENDOR_MOTU_TEST, + 0xffffffff, + }; + + /* A list of all valid IEEE1394 model IDs for MOTU firewire audio devices, + * terminated by 0xffffffff. + */ + const unsigned int motu_fw_audio_model_ids[] = { + MOTU_828mkII, MOTU_TRAVELER, MOTU_TEST, + 0xffffffff, + }; + + /* Find out if this device is one we know about */ + is_motu_fw_audio = i = 0; + + while ((motu_vendor_ids[i]!=0xffffffff) + && (m_configRom->getVendorId() != motu_vendor_ids[i])) + i++; + + if (motu_vendor_ids[i] != 0xffffffff) { + /* Device is made by MOTU. See if the model is one we know about */ + i = 0; + + while ((motu_fw_audio_model_ids[i]!=0xffffffff) + && (m_configRom->getModelId() != motu_fw_audio_model_ids[i])) + i++; + + if (motu_fw_audio_model_ids[i]!=0xffffffff) + is_motu_fw_audio = 1; + } + + if (is_motu_fw_audio) { + debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", + m_configRom->getVendorName(), m_configRom->getModelName()); + return true; + } + + return false; +} + + + +bool +MotuDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) +{ + quadlet_t new_rate=0; + int supported=true; + + switch ( samplingFrequency ) { + case eSF_22050Hz: + supported=false; + break; + case eSF_24000Hz: + supported=false; + break; + case eSF_32000Hz: + supported=false; + break; + case eSF_44100Hz: + new_rate = MOTU_BASE_RATE_44100 | MOTU_RATE_MULTIPLIER_1X; + break; + case eSF_48000Hz: + new_rate = MOTU_BASE_RATE_48000 | MOTU_RATE_MULTIPLIER_1X; + break; + case eSF_88200Hz: + new_rate = MOTU_BASE_RATE_44100 | MOTU_RATE_MULTIPLIER_2X; + break; + case eSF_96000Hz: + new_rate = MOTU_BASE_RATE_48000 | MOTU_RATE_MULTIPLIER_2X; + break; + case eSF_176400Hz: + new_rate = MOTU_BASE_RATE_44100 | MOTU_RATE_MULTIPLIER_4X; + break; + case eSF_192000Hz: + new_rate = MOTU_BASE_RATE_48000 | MOTU_RATE_MULTIPLIER_4X; + break; + default: + supported=false; + } + + // update the register + if(supported) { + quadlet_t value=ReadRegister(0x0B14); + value &= ~(MOTU_RATE_MASK); + value |= new_rate; + + if(WriteRegister(0x0B14,value) == 0) { + supported=true; + } else { + supported=false; + } + } + + return supported; +} + +void +MotuDevice::showDevice() const +{ + printf( "%s %s at node %d\n", + m_configRom->getVendorName(), + m_configRom->getModelName(), + m_nodeId ); + +} + +bool +MotuDevice::addXmlDescription( xmlNodePtr deviceNode ) +{ + return true; +} + +/* ======================================================================== */ + +unsigned int MotuDevice::ReadRegister(unsigned int reg) { +/* + * Attempts to read the requested register from the MOTU. + */ + + quadlet_t quadlet; + assert(m_1394Service); + + quadlet = 0; + if (m_1394Service->read(m_nodeId, MOTU_BASE_ADDR+reg, 4, &quadlet) < 0) { + debugError("Error doing motu read from register 0x%06x\n",reg); + } + + + return ntohl(quadlet); +} + +signed int MotuDevice::WriteRegister(unsigned int reg, quadlet_t data) { +/* + * Attempts to write the given data to the requested MOTU register. + */ + + unsigned int err = 0; + + data = htonl(data); + + if (m_1394Service->write(m_nodeId, MOTU_BASE_ADDR+reg, 4, &data) < 0) { + err = 1; + debugError("Error doing motu write to register 0x%06x\n",reg); + } + + usleep(100); + + return (err==0)?0:-1; +} + +} Index: /branches/libfreebob-motu/src/freebob.cpp =================================================================== --- /branches/libfreebob-motu/src/freebob.cpp (revision 186) +++ /branches/libfreebob-motu/src/freebob.cpp (revision 197) @@ -1,3 +1,3 @@ -/* freebob.h +/* freebob.cpp * Copyright (C) 2005 Pieter Palmers, Daniel Wagner * Index: /branches/libfreebob-motu/src/configrom.cpp =================================================================== --- /branches/libfreebob-motu/src/configrom.cpp (revision 185) +++ /branches/libfreebob-motu/src/configrom.cpp (revision 197) @@ -354,2 +354,14 @@ return m_vendorName; } + +const unsigned int +ConfigRom::getModelId() const +{ + return m_modelId; +} + +const unsigned int +ConfigRom::getVendorId() const +{ + return m_vendorId; +} Index: /branches/libfreebob-motu/src/configrom.h =================================================================== --- /branches/libfreebob-motu/src/configrom.h (revision 185) +++ /branches/libfreebob-motu/src/configrom.h (revision 197) @@ -44,5 +44,6 @@ const std::string getModelName() const; const std::string getVendorName() const; - + const unsigned int getModelId() const; + const unsigned int getVendorId() const; protected: Index: /branches/libfreebob-motu/src/Makefile.am =================================================================== --- /branches/libfreebob-motu/src/Makefile.am (revision 188) +++ /branches/libfreebob-motu/src/Makefile.am (revision 197) @@ -52,5 +52,7 @@ bebob_light/bebob_light_avplug.cpp \ bounce/bounce_avdevice.h \ - bounce/bounce_avdevice.cpp + bounce/bounce_avdevice.cpp \ + motu/motu_avdevice.h \ + motu/motu_avdevice.cpp libfreebob_la_LDFLAGS = -version-info $(LT_VERSION) -lpthread $(LIBSIGC_LIBS) \ Index: /branches/libfreebob-motu/src/devicemanager.cpp =================================================================== --- /branches/libfreebob-motu/src/devicemanager.cpp (revision 188) +++ /branches/libfreebob-motu/src/devicemanager.cpp (revision 197) @@ -30,4 +30,5 @@ #include "bebob_light/bebob_light_avdevice.h" #include "bounce/bounce_avdevice.h" +#include "motu/motu_avdevice.h" #include @@ -40,6 +41,7 @@ : m_1394Service( 0 ) { - m_probeList.push_back( probeBeBoB ); - m_probeList.push_back( probeBounce ); + m_probeList.push_back( probeMotu ); +// m_probeList.push_back( probeBeBoB ); + m_probeList.push_back( probeBounce ); } @@ -137,10 +139,10 @@ IAvDevice* avDevice = new BeBoB_Light::AvDevice( service, id, level ); if ( !avDevice ) { - return 0; + return NULL; } if ( !avDevice->discover() ) { delete avDevice; - return 0; + return NULL; } return avDevice; @@ -152,10 +154,25 @@ IAvDevice* avDevice = new Bounce::BounceDevice( service, id, level ); if ( !avDevice ) { - return 0; + return NULL; } if ( !avDevice->discover() ) { delete avDevice; - return 0; + return NULL; + } + return avDevice; +} + +IAvDevice* +DeviceManager::probeMotu(Ieee1394Service& service, int id, int level) +{ + IAvDevice* avDevice = new Motu::MotuDevice( service, id, level ); + if ( !avDevice ) { + return NULL; + } + + if ( !avDevice->discover() ) { + delete avDevice; + return NULL; } return avDevice; Index: /branches/libfreebob-motu/src/bounce/bounce_avdevice.cpp =================================================================== --- /branches/libfreebob-motu/src/bounce/bounce_avdevice.cpp (revision 185) +++ /branches/libfreebob-motu/src/bounce/bounce_avdevice.cpp (revision 197) @@ -30,4 +30,6 @@ #include #include +#include +#include namespace Bounce { @@ -53,5 +55,5 @@ BounceDevice::~BounceDevice() { - + delete m_configRom; } @@ -65,13 +67,33 @@ BounceDevice::discover() { - std::string vendor = std::string(FREEBOB_BOUNCE_SERVER_VENDORNAME); - std::string model = std::string(FREEBOB_BOUNCE_SERVER_MODELNAME); + unsigned int resp_len=0; + quadlet_t request[6]; + quadlet_t *resp; - if (m_configRom->getVendorName().compare(0,vendor.length(),vendor,0,vendor.length())==0) { - if(m_configRom->getModelName().compare(0,model.length(),model,0,model.length())==0) { - return true; - } - } - return false; + std::string vendor=std::string(FREEBOB_BOUNCE_SERVER_VENDORNAME); + std::string model=std::string(FREEBOB_BOUNCE_SERVER_MODELNAME); + + if (!(m_configRom->getVendorName().compare(0,vendor.length(),vendor,0,vendor.length())==0) + || !(m_configRom->getModelName().compare(0,model.length(),model,0,model.length())==0)) { + return false; + } + +// AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT + request[0] = htonl( AVC1394_CTYPE_STATUS | (AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER << 19) | (0 << 16) + | AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | 0x00); + + request[1] = 0xFFFFFFFF; + resp = m_1394Service->transactionBlock( m_nodeId, + request, + 2, + &resp_len ); +// hexDump((unsigned char *)request,6*4); + if(resp) { + char *buffer=(char *)&resp[1]; + xmlDescription=buffer; +// hexDump((unsigned char *)resp,6*4); + } + + return true; } @@ -86,7 +108,9 @@ { printf( "\nI am the bouncedevice, the bouncedevice I am...\n" ); - printf( "Vendor : %s\n", m_configRom->getVendorName().c_str()); - printf( "Model : %s\n", m_configRom->getModelName().c_str()); - printf( "GUID : 0x%016llX\n", m_configRom->getGuid()); + printf( "Vendor : %s\n", m_configRom->getVendorName().c_str()); + printf( "Model : %s\n", m_configRom->getModelName().c_str()); + printf( "Node : %d\n", m_nodeId); + printf( "GUID : 0x%016llX\n", m_configRom->getGuid()); + printf( "ACV test response : %s\n", xmlDescription.c_str()); printf( "\n" ); } @@ -95,4 +119,62 @@ BounceDevice::addXmlDescription( xmlNodePtr deviceNode ) { + + xmlDocPtr doc; + xmlNodePtr cur; + xmlNodePtr copy; + + doc = xmlParseFile("freebob_bouncedevice.xml"); + + if (doc == NULL ) { + debugError( "freebob_bouncedevice.xml not parsed successfully. \n"); + return false; + } + + cur = xmlDocGetRootElement(doc); + + if (cur == NULL) { + debugError( "empty document\n"); + xmlFreeDoc(doc); + return false; + } + + if (xmlStrcmp(cur->name, (const xmlChar *) "FreeBobBounceDevice")) { + debugError( "document of the wrong type, root node != FreeBobBounceDevice\n"); + xmlFreeDoc(doc); + return false; + } + + cur = cur->xmlChildrenNode; + while (cur != NULL) { + char *result; + + copy=xmlCopyNode(cur,1); + +// debugOutput(DEBUG_LEVEL_NORMAL,"copying %s\n",cur->name); + + + if (!copy || !xmlAddChild(deviceNode, copy)) { + debugError( "could not add child node\n"); + cur = cur->next; + continue; + } + + // add the node id +// if (xmlStrcmp(copy->name, (const xmlChar *) "ConnectionSet")) { +// asprintf( &result, "%d", m_nodeId); +// if ( !xmlNewChild( copy, 0, +// BAD_CAST "Node", BAD_CAST result ) ) { +// debugError( "Couldn't create 'Node' node\n" ); +// return false; +// free(result); +// } +// free(result); +// } + + cur = cur->next; + } + + xmlFreeDoc(doc); + return true; } Index: /branches/libfreebob-motu/src/bounce/bounce_avdevice.h =================================================================== --- /branches/libfreebob-motu/src/bounce/bounce_avdevice.h (revision 185) +++ /branches/libfreebob-motu/src/bounce/bounce_avdevice.h (revision 197) @@ -29,4 +29,5 @@ #include "libfreebobavc/avc_extended_cmd_generic.h" #include "libfreebob/xmlparser.h" +#include "libfreebob/freebob_bounce.h" class ConfigRom; @@ -54,4 +55,8 @@ int m_verboseLevel; +private: + std::string xmlDescription; + + DECLARE_DEBUG_MODULE; }; Index: /branches/libfreebob-motu/libfreebob/freebob_bounce.h =================================================================== --- /branches/libfreebob-motu/libfreebob/freebob_bounce.h (revision 197) +++ /branches/libfreebob-motu/libfreebob/freebob_bounce.h (revision 197) @@ -0,0 +1,33 @@ +/* freebob_bounce.h + * Copyright (C) 2005 Pieter Palmers + * + * This file is part of FreeBoB + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#ifndef FREEBOB_BOUNCE_H +#define FREEBOB_BOUNCE_H + +#define FREEBOB_MAX_NAME_LEN 256 + +#define FREEBOB_BOUNCE_SERVER_VENDORNAME "FreeBoB Server" +#define FREEBOB_BOUNCE_SERVER_MODELNAME "freebob-server" + +#define FREEBOB_BOUNCE_SERVER_GETXMLDESCRIPTION_CMD +#define AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER 0x0D + +#endif /* FREEBOB_BOUNCE_H */ Index: /branches/libfreebob-motu/libfreebob/freebob.h =================================================================== --- /branches/libfreebob-motu/libfreebob/freebob.h (revision 185) +++ /branches/libfreebob-motu/libfreebob/freebob.h (revision 197) @@ -28,4 +28,7 @@ #define FREEBOB_BOUNCE_SERVER_VENDORNAME "FreeBoB Server" #define FREEBOB_BOUNCE_SERVER_MODELNAME "freebob-server" + +#define FREEBOB_BOUNCE_SERVER_GETXMLDESCRIPTION_CMD +#define AVC1394_SUBUNIT_TYPE_FREEBOB_BOUNCE_SERVER 0x0D enum freebob_direction {