Changeset 445 for trunk/libffado/src/libieee1394
- Timestamp:
- 04/02/07 12:35:17 (17 years ago)
- Files:
-
- trunk/libffado/src/libieee1394/ARMHandler.cpp (modified) (5 diffs)
- trunk/libffado/src/libieee1394/ARMHandler.h (modified) (6 diffs)
- trunk/libffado/src/libieee1394/configrom.cpp (modified) (10 diffs)
- trunk/libffado/src/libieee1394/configrom.h (modified) (4 diffs)
- trunk/libffado/src/libieee1394/IEC61883.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/IEC61883.h (modified) (5 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (32 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libieee1394/ARMHandler.cpp
r414 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License version 2.1, as published by the Free Software Foundation; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 * MA 02110-1301 USA 27 22 */ 28 23 … … 35 30 * @param initial_value pointer to buffer containing (if necessary) initial value 36 31 * NULL means undefined 37 * @param access_rights access-rights for registered addressrange handled 38 * by kernel-part. Value is one or more binary or of the 32 * @param access_rights access-rights for registered addressrange handled 33 * by kernel-part. Value is one or more binary or of the 39 34 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 40 35 * @param notification_options identifies for which type of request you want 41 * to be notified. Value is one or more binary or of the 36 * to be notified. Value is one or more binary or of the 42 37 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 43 38 * @param client_transactions identifies for which type of request you want … … 45 40 * for those requests no response will be generated, but 46 41 * has to be generated by the application. 47 * Value is one or more binary or of the 42 * Value is one or more binary or of the 48 43 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 49 44 * For each bit set here, notification_options and … … 101 96 // byte_t *buffer; 102 97 // } *raw1394_arm_request_t; 103 // 98 // 104 99 // typedef struct raw1394_arm_response { 105 100 // int response_code; … … 107 102 // byte_t *buffer; 108 103 // } *raw1394_arm_response_t; 109 // 104 // 110 105 // typedef struct raw1394_arm_request_response { 111 106 // struct raw1394_arm_request *request; trunk/libffado/src/libieee1394/ARMHandler.h
r414 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 * 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 7 * 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 23 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_ARMHANDLER__ 29 #define __FREEBOB_ARMHANDLER__ 25 #ifndef __FFADO_ARMHANDLER__ 26 #define __FFADO_ARMHANDLER__ 30 27 31 28 #include "../debugmodule/debugmodule.h" … … 37 34 /** 38 35 * @brief Class to handle AddressRangeMappings 39 * 40 * This class is intended to help with implementing 36 * 37 * This class is intended to help with implementing 41 38 * address range mapping, i.e. implementing handlers 42 39 * that react to reads/writes of certain addresses 43 40 * in 1394 memory space 44 * 41 * 45 42 * see the _arm_ functions in raw1394.h for more insight 46 * 43 * 47 44 */ 48 45 49 46 class ARMHandler { 50 47 friend class Ieee1394Service; … … 57 54 unsigned int client_transactions 58 55 ); 59 56 60 57 virtual ~ARMHandler(); 61 58 … … 65 62 66 63 struct raw1394_arm_response *getResponse() {return &m_response;}; 67 64 68 65 nodeaddr_t getStart() {return m_start;}; 69 66 nodeaddr_t getLength() {return m_length;}; … … 71 68 unsigned int getNotificationOptions() {return m_notification_options;}; 72 69 unsigned int getClientTransactions() {return m_client_transactions;}; 73 70 74 71 byte_t *getBuffer() {return m_buffer;}; 75 72 76 73 private: 77 74 nodeaddr_t m_start; … … 82 79 83 80 byte_t *m_buffer; 84 81 85 82 struct raw1394_arm_response m_response; 86 83 87 84 void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 88 85 void printRequest(struct raw1394_arm_request *arm_req); 89 86 90 87 protected: 91 88 92 89 93 90 DECLARE_DEBUG_MODULE; 94 91 95 92 }; 96 93 97 #endif /* __F REEBOB_ARMHANDLER__ */94 #endif /* __FFADO_ARMHANDLER__ */ 98 95 99 96 trunk/libffado/src/libieee1394/configrom.cpp
r435 r445 1 /* configrom.cpp 2 * Copyright (C) 2005 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 * Copyright (C) 2005-2007 by Pieter Palmers 3 5 * 4 * This file is part of FreeBoB. 6 * This file is part of FFADO 7 * FFADO = Free Firewire (pro-)audio drivers for linux 5 8 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 9 * FFADO is based upon FreeBoB 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License version 2.1, as published by the Free Software Foundation; 14 * 15 * This library is distributed in the hope that it will be useful, 11 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 14 19 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 * MA 02110-1301 USA 19 24 */ 20 25 … … 159 164 len ); 160 165 161 166 while ((buf + len - 1) == '\0') { 162 167 len--; 163 168 } 164 169 // \todo XXX seems a bit strage to do this but the nodemgr.c code does 165 170 // it. try to figure out why this is needed (or not) 166 167 171 buf[len++] = ' '; 172 buf[len] = '\0'; 168 173 169 174 … … 178 183 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ), 179 184 len ); 180 185 while ((buf + len - 1) == '\0') { 181 186 len--; 182 187 } 183 188 // \todo XXX for edirol fa-66 it seems somehow broken. see above 184 189 // todo as well. 185 186 190 buf[len++] = ' '; 191 buf[len] = '\0'; 187 192 188 193 debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf); … … 217 222 { 218 223 struct config_csr_info* csr_info = (struct config_csr_info*) private_data; 219 224 220 225 if ( !csr_info->service->read( csr_info->nodeId, 221 226 addr, … … 249 254 debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" ); 250 255 csr1212_for_each_dir_entry(csr, kv, ud_kv, dentry) { 251 252 253 256 switch (kv->key.id) { 257 case CSR1212_KV_ID_VENDOR: 258 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 254 259 debugOutput( DEBUG_LEVEL_VERBOSE, 255 260 "\tvendor_id = 0x%08x\n", 256 261 kv->value.immediate); 257 262 m_vendorId = kv->value.immediate; 258 259 260 261 263 } 264 break; 265 266 case CSR1212_KV_ID_MODEL: 262 267 debugOutput( DEBUG_LEVEL_VERBOSE, 263 268 "\tmodel_id = 0x%08x\n", 264 269 kv->value.immediate); 265 270 m_modelId = kv->value.immediate; 266 267 268 271 break; 272 273 case CSR1212_KV_ID_SPECIFIER_ID: 269 274 debugOutput( DEBUG_LEVEL_VERBOSE, 270 275 "\tspecifier_id = 0x%08x\n", 271 276 kv->value.immediate); 272 277 m_unit_specifier_id = kv->value.immediate; 273 274 275 278 break; 279 280 case CSR1212_KV_ID_VERSION: 276 281 debugOutput( DEBUG_LEVEL_VERBOSE, 277 282 "\tversion = 0x%08x\n", … … 284 289 } 285 290 } 286 287 288 289 290 291 292 293 294 295 296 297 298 291 break; 292 293 case CSR1212_KV_ID_DESCRIPTOR: 294 if (kv->key.type == CSR1212_KV_TYPE_LEAF && 295 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 && 296 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 && 297 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && 298 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && 299 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) 300 { 301 switch (last_key_id) { 302 case CSR1212_KV_ID_VENDOR: 303 csr1212_keep_keyval(kv); 299 304 m_vendorNameKv = kv; 300 301 302 305 break; 306 307 case CSR1212_KV_ID_MODEL: 303 308 m_modelNameKv = kv; 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 309 csr1212_keep_keyval(kv); 310 break; 311 312 } 313 } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */ 314 break; 315 316 case CSR1212_KV_ID_DEPENDENT_INFO: 317 if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) { 318 /* This should really be done in SBP2 as this is 319 * doing SBP2 specific parsing. */ 320 processUnitDirectory(csr, kv, id); 321 } 322 323 break; 324 325 default: 326 break; 327 } 328 last_key_id = kv->key.id; 324 329 } 325 330 } … … 334 339 335 340 csr1212_for_each_dir_entry(csr, kv, csr->root_kv, dentry) { 336 337 341 switch (kv->key.id) { 342 case CSR1212_KV_ID_VENDOR: 338 343 debugOutput( DEBUG_LEVEL_VERBOSE, 339 344 "vendor id = 0x%08x\n", kv->value.immediate); 340 341 342 345 break; 346 347 case CSR1212_KV_ID_NODE_CAPABILITIES: 343 348 debugOutput( DEBUG_LEVEL_VERBOSE, 344 349 "capabilities = 0x%08x\n", kv->value.immediate); 345 346 347 348 349 350 351 352 353 354 355 356 357 358 350 break; 351 352 case CSR1212_KV_ID_UNIT: 353 processUnitDirectory(csr, kv, &ud_id); 354 break; 355 356 case CSR1212_KV_ID_DESCRIPTOR: 357 if (last_key_id == CSR1212_KV_ID_VENDOR) { 358 if (kv->key.type == CSR1212_KV_TYPE_LEAF && 359 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 && 360 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 && 361 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && 362 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && 363 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) 359 364 { 360 365 m_vendorNameKv = kv; 361 362 363 364 365 366 366 csr1212_keep_keyval(kv); 367 } 368 } 369 break; 370 } 371 last_key_id = kv->key.id; 367 372 } 368 373 … … 578 583 ConfigRom::processOscMessage(OSC::OscMessage *m) { 579 584 OSC::OscResponse r=OSC::OscResponse(OSC::OscResponse::eUnhandled); 580 585 581 586 unsigned int nbArgs=m->nbArguments(); 582 587 if (nbArgs>=1) { … … 584 589 if(arg0.isString()) { // commands 585 590 string cmd=arg0.getString(); 586 591 587 592 debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) CMD? %s\n", this, cmd.c_str()); 588 593 if(cmd == "params") { … … 623 628 } 624 629 } 625 630 626 631 return r; 627 632 trunk/libffado/src/libieee1394/configrom.h
r435 r445 1 /* configrom.h 2 * Copyright (C) 2005,06 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 * Copyright (C) 2005-2007 by Pieter Palmers 3 5 * 4 * This file is part of FreeBoB. 6 * This file is part of FFADO 7 * FFADO = Free Firewire (pro-)audio drivers for linux 5 8 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 9 * FFADO is based upon FreeBoB 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License version 2.1, as published by the Free Software Foundation; 14 * 15 * This library is distributed in the hope that it will be useful, 11 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 14 19 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 * MA 02110-1301 USA 19 24 */ 20 25 … … 56 61 57 62 bool isIsoResourseManager() const 58 63 { return m_isIsoResourceManager; } 59 64 bool isCycleMasterCapable() const 60 65 { return m_isCycleMasterCapable; } … … 70 75 71 76 fb_quadlet_t getNodeVendorId() const 72 77 { return m_nodeVendorId; } 73 78 74 79 bool updatedNodeId(); … … 78 83 79 84 bool serialize( Glib::ustring path, Util::IOSerialize& ser ); 80 static ConfigRom* deserialize( Glib::ustring path, 81 82 85 static ConfigRom* deserialize( Glib::ustring path, 86 Util::IODeserialize& deser, 87 Ieee1394Service& ieee1394Service ); 83 88 84 89 protected: trunk/libffado/src/libieee1394/IEC61883.cpp
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License version 2.1, as published by the Free Software Foundation; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 * MA 02110-1301 USA 26 22 */ 27 23 trunk/libffado/src/libieee1394/IEC61883.h
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_IEC61883__ 29 #define __FREEBOB_IEC61883__ 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 6 * 7 * FFADO is based upon FreeBoB 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License version 2.1, as published by the Free Software Foundation; 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 * MA 02110-1301 USA 22 */ 23 24 #ifndef __FFADO_IEC61883__ 25 #define __FFADO_IEC61883__ 30 26 31 27 #include "../debugmodule/debugmodule.h" 32 28 33 29 /* 34 * This is shamelessly stolen from iec61883-private, 30 * This is shamelessly stolen from iec61883-private, 35 31 * but I need these functions! 36 32 * FIXME: this will only work until somebody decides to change … … 45 41 **/ 46 42 47 /* maximum number of PCRs allowed within the standard 43 /* maximum number of PCRs allowed within the standard 48 44 * MPR/PCR addresses defined in IEC-61883. 49 45 * This refers to the number of output or input PCRs-- … … 147 143 * @a: The CSR offset address (relative to base) of the register to read. 148 144 * @value: A pointer to a quadlet where the plug register's value will be stored. 149 * 150 * This function handles bus to host endian conversion. It returns 0 for 145 * 146 * This function handles bus to host endian conversion. It returns 0 for 151 147 * suceess or -1 for error (errno available). 152 148 **/ … … 155 151 156 152 157 /** 153 /** 158 154 * iec61883_plug_set - Write a node's plug register. 159 155 * @h: A raw1394 handle. … … 204 200 }; 205 201 206 #endif /* __F REEBOB_IEC61883__ */207 208 202 #endif /* __FFADO_IEC61883__ */ 203 204 trunk/libffado/src/libieee1394/ieee1394service.cpp
r436 r445 1 /* ieee1394service.cpp 2 * Copyright (C) 2005,07 by Daniel Wagner 3 * Copyright (C) 2007 by Pieter Palmers 4 * 5 * This file is part of FreeBoB. 6 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 4 * 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 7 * 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library is distributed in the hope that it will be useful, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 20 23 */ 24 21 25 #include "ieee1394service.h" 22 26 #include "ARMHandler.h" … … 42 46 { 43 47 pthread_mutex_init( &m_mutex, 0 ); 44 48 45 49 for (unsigned int i=0; i<64; i++) { 46 50 m_channels[i].channel=-1; … … 73 77 raw1394_destroy_handle( m_handle ); 74 78 } 75 79 76 80 if ( m_resetHandle ) { 77 81 raw1394_destroy_handle( m_resetHandle ); … … 117 121 m_default_arm_handler = raw1394_set_arm_tag_handler( m_resetHandle, 118 122 this->armHandlerLowLevel ); 119 123 120 124 startRHThread(); 121 125 … … 230 234 } 231 235 232 bool 236 bool 233 237 Ieee1394Service::lockCompareSwap64( fb_nodeid_t nodeId, 234 238 fb_nodeaddr_t addr, … … 244 248 fb_octlet_t buffer; 245 249 if(!read_octlet( nodeId, addr,&buffer )) { 246 debug Output(DEBUG_LEVEL_VERBOSE,"Could not read ownerregister\n");250 debugWarning("Could not read register\n"); 247 251 } else { 248 debugOutput(DEBUG_LEVEL_VERBOSE,"Owner register before = 0x%016llX\n", buffer); 249 } 250 251 buffer=0x123456789ABCDEF0LL; 252 debugOutput(DEBUG_LEVEL_VERBOSE,"before byteswap = 0x%016llX\n", buffer); 253 buffer=byteSwap_octlet(buffer); 254 debugOutput(DEBUG_LEVEL_VERBOSE,"after byteswap = 0x%016llX\n", buffer); 255 256 252 debugOutput(DEBUG_LEVEL_VERBOSE,"before = 0x%016llX\n", buffer); 253 } 254 257 255 #endif 258 256 259 257 // do endiannes swapping 260 258 compare_value=byteSwap_octlet(compare_value); 261 259 swap_value=byteSwap_octlet(swap_value); 262 260 263 261 int retval=raw1394_lock64(m_handle, nodeId, addr, RAW1394_EXTCODE_COMPARE_SWAP, 264 262 swap_value, compare_value, result); 265 263 266 264 #ifdef DEBUG 267 265 if(!read_octlet( nodeId, addr,&buffer )) { 268 debug Output(DEBUG_LEVEL_VERBOSE,"Could not read ownerregister\n");266 debugWarning("Could not read register\n"); 269 267 } else { 270 debugOutput(DEBUG_LEVEL_VERBOSE," Owner registerafter = 0x%016llX\n", buffer);268 debugOutput(DEBUG_LEVEL_VERBOSE,"after = 0x%016llX\n", buffer); 271 269 } 272 270 #endif 273 271 274 272 *result=byteSwap_octlet(*result); 275 273 276 274 return (retval == 0); 277 275 } … … 286 284 buf[i] = ntohl( buf[i] ); 287 285 } 288 289 #ifdef DEBUG290 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " pre avc1394_transaction_block2\n" );291 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf );292 #endif293 286 294 287 fb_quadlet_t* result = … … 300 293 10 ); 301 294 302 #ifdef DEBUG303 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " post avc1394_transaction_block2\n" );304 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result );305 #endif306 307 295 for ( unsigned int i = 0; i < *resp_len; ++i ) { 308 296 result[i] = htonl( result[i] ); … … 389 377 h, h->getStart(), h->getLength()); 390 378 391 int err=raw1394_arm_register(m_resetHandle, h->getStart(), 379 int err=raw1394_arm_register(m_resetHandle, h->getStart(), 392 380 h->getLength(), h->getBuffer(), (octlet_t)h, 393 381 h->getAccessRights(), … … 399 387 return false; 400 388 } 401 389 402 390 m_armHandlers.push_back( h ); 403 391 … … 406 394 407 395 bool Ieee1394Service::unregisterARMHandler( ARMHandler *h ) { 408 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", 396 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", 409 397 h, h->getStart()); 410 398 411 399 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 412 400 it != m_armHandlers.end(); … … 439 427 debugOutput(DEBUG_LEVEL_VERBOSE, "Finding free ARM block of %d bytes, from 0x%016llX in steps of %d bytes\n", 440 428 length, start, step); 441 429 442 430 int cnt=0; 443 431 const int maxcnt=10; … … 446 434 // try to register 447 435 err=raw1394_arm_register(m_resetHandle, start, length, 0, 0, 0, 0, 0); 448 436 449 437 if (err) { 450 438 debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016llX\n", start); … … 466 454 } 467 455 468 int 469 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, 456 int 457 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, 470 458 unsigned long arm_tag, 471 459 byte_t request_type, unsigned int requested_length, … … 493 481 raw1394_arm_request_t arm_req=arm_req_resp->request; 494 482 raw1394_arm_response_t arm_resp=arm_req_resp->response; 495 483 496 484 debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", 497 485 (*it)->getStart()); 498 486 debugOutput(DEBUG_LEVEL_VERBOSE," request type : 0x%02X\n",request_type); 499 487 debugOutput(DEBUG_LEVEL_VERBOSE," request length : %04d\n",requested_length); 500 488 501 489 switch(request_type) { 502 490 case RAW1394_ARM_READ: … … 583 571 { 584 572 debugOutput(DEBUG_LEVEL_VERBOSE, "Removing busreset handler (%p)\n", functor); 585 573 586 574 for ( reset_handler_vec_t::iterator it = m_busResetHandlers.begin(); 587 575 it != m_busResetHandlers.end(); … … 603 591 * or an allocated channel number. 604 592 * 605 * Does not perform anything other than registering the channel and the 593 * Does not perform anything other than registering the channel and the 606 594 * bandwidth at the IRM 607 595 * 608 596 * Also allocates the necessary bandwidth (in ISO allocation units). 609 * 597 * 610 598 * FIXME: As in libiec61883, channel 63 is not requested; this is either a 611 599 * bug or it's omitted since that's the channel preferred by video devices. … … 616 604 signed int Ieee1394Service::allocateIsoChannelGeneric(unsigned int bandwidth) { 617 605 debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using generic method...\n" ); 618 606 619 607 struct ChannelInfo cinfo; 620 608 … … 627 615 if (raw1394_bandwidth_modify(m_handle, bandwidth, RAW1394_MODIFY_ALLOC) < 0) { 628 616 debugFatal("Could not allocate bandwidth of %d\n", bandwidth); 629 617 630 618 raw1394_channel_modify (m_handle, c, RAW1394_MODIFY_FREE); 631 619 return -1; … … 634 622 cinfo.bandwidth=bandwidth; 635 623 cinfo.alloctype=AllocGeneric; 636 624 625 cinfo.xmit_node=-1; 626 cinfo.xmit_plug=-1; 627 cinfo.recv_node=-1; 628 cinfo.recv_plug=-1; 629 637 630 if (registerIsoChannel(c, cinfo)) { 638 631 return c; … … 667 660 668 661 signed int Ieee1394Service::allocateIsoChannelCMP( 669 nodeid_t xmit_node, int xmit_plug, 662 nodeid_t xmit_node, int xmit_plug, 670 663 nodeid_t recv_node, int recv_plug 671 664 ) { 672 665 673 666 debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using IEC61883 CMP...\n" ); 674 667 675 668 struct ChannelInfo cinfo; 676 669 677 670 int c = -1; 678 671 int bandwidth=1; 679 672 680 673 // do connection management: make connection 681 674 c = iec61883_cmp_connect( … … 697 690 cinfo.bandwidth=bandwidth; 698 691 cinfo.alloctype=AllocCMP; 699 692 700 693 cinfo.xmit_node=xmit_node; 701 694 cinfo.xmit_plug=xmit_plug; 702 695 cinfo.recv_node=recv_node; 703 696 cinfo.recv_plug=recv_plug; 704 697 705 698 if (registerIsoChannel(c, cinfo)) { 706 699 return c; … … 711 704 712 705 /** 713 * Deallocates an iso channel. Silently ignores a request to deallocate 706 * Deallocates an iso channel. Silently ignores a request to deallocate 714 707 * a negative channel number. 715 708 * … … 717 710 * and uses the appropriate method to deallocate. Also frees the bandwidth 718 711 * that was reserved along with this channel. 719 * 712 * 720 713 * @param c channel number 721 714 * @return true if successful … … 723 716 bool Ieee1394Service::freeIsoChannel(signed int c) { 724 717 debugOutput(DEBUG_LEVEL_VERBOSE, "Freeing ISO channel %d...\n", c ); 725 718 726 719 if (c < 0 || c > 63) { 727 720 debugWarning("Invalid channel number: %d\n", c); 728 721 return false; 729 722 } 730 723 731 724 switch (m_channels[c].alloctype) { 732 725 default: 733 726 debugError(" BUG: invalid allocation type!\n"); 734 727 return false; 735 736 case AllocFree: 728 729 case AllocFree: 737 730 debugWarning(" Channel %d not registered\n", c); 738 731 return false; 739 732 740 733 case AllocGeneric: 741 734 debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using generic routine...\n" ); … … 751 744 return false; 752 745 return true; 753 746 754 747 case AllocCMP: 755 748 debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using IEC61883 CMP...\n" ); 756 749 debugOutput(DEBUG_LEVEL_VERBOSE, " performing IEC61883 CMP disconnect...\n" ); 757 750 if(iec61883_cmp_disconnect( 758 m_handle, 751 m_handle, 759 752 m_channels[c].xmit_node | 0xffc0, 760 753 m_channels[c].xmit_plug, … … 769 762 return true; 770 763 } 771 764 772 765 // unreachable 773 766 debugError("BUG: unreachable code reached!\n"); 774 767 775 768 return false; 776 769 } … … 788 781 m_channels[c].channel, m_channels[c].bandwidth); 789 782 } 790 783 791 784 memcpy(&m_channels[c], &cinfo, sizeof(struct ChannelInfo)); 792 785 793 786 } else return false; 794 787 return true; … … 806 799 return false; 807 800 } 808 801 809 802 m_channels[c].channel=-1; 810 803 m_channels[c].bandwidth=-1; … … 814 807 m_channels[c].recv_node=0xFFFF; 815 808 m_channels[c].recv_plug=-1; 816 809 817 810 } else return false; 818 811 return true; … … 822 815 * Returns the current value of the `bandwidth available' register on 823 816 * the IRM, or -1 on error. 824 * @return 817 * @return 825 818 */ 826 819 signed int Ieee1394Service::getAvailableBandwidth() { … … 836 829 837 830 void 838 Ieee1394Service::setVerboseLevel(int l) 831 Ieee1394Service::setVerboseLevel(int l) 839 832 { 840 833 setDebugLevel(l); trunk/libffado/src/libieee1394/ieee1394service.h
r436 r445 1 /* Ieee1394Service.cpp 2 * Copyright (C) 2005,06 by Daniel Wagner 3 * Copyright (C) 2007 by Pieter Palmers 4 * 5 * This file is part of FreeBoB. 6 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 4 * 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 7 * 8 * FFADO is based upon FreeBoB 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License version 2.1, as published by the Free Software Foundation; 13 * 14 * This library is distributed in the hope that it will be useful, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1301 USA 20 23 */ 21 24 22 #ifndef F REEBOBIEEE1394SERVICE_H23 #define F REEBOBIEEE1394SERVICE_H25 #ifndef FFADO_IEEE1394SERVICE_H 26 #define FFADO_IEEE1394SERVICE_H 24 27 25 28 #include "fbtypes.h" … … 45 48 46 49 int getPort() 47 50 { return m_port; } 48 51 /** 49 52 * @brief get number of nodes on the bus … … 57 60 */ 58 61 int getNodeCount(); 59 62 60 63 /** 61 64 * @brief get the node id of the local node … … 67 70 */ 68 71 nodeid_t getLocalNodeId(); 69 72 70 73 /** 71 74 * @brief send async read request to a node and wait for response. … … 77 80 * @param length amount of data to read in quadlets 78 81 * @param buffer pointer to buffer where data will be saved 79 82 80 83 * @return true on success or false on failure (sets errno) 81 84 */ 82 85 bool read( fb_nodeid_t nodeId, 83 84 85 86 fb_nodeaddr_t addr, 87 size_t length, 88 fb_quadlet_t* buffer ); 86 89 87 90 bool read_quadlet( fb_nodeid_t nodeId, … … 106 109 */ 107 110 bool write( fb_nodeid_t nodeId, 108 109 110 111 fb_nodeaddr_t addr, 112 size_t length, 113 fb_quadlet_t* data ); 111 114 112 115 bool write_quadlet( fb_nodeid_t nodeId, … … 143 146 fb_quadlet_t* buf, 144 147 int len, 145 148 unsigned int* resp_len ); 146 149 147 150 bool transactionBlockClose(); … … 153 156 bool addBusResetHandler( Functor* functor ); 154 157 bool remBusResetHandler( Functor* functor ); 155 158 156 159 /** 157 160 * @brief register an AddressRangeMapping Handler … … 169 172 */ 170 173 bool unregisterARMHandler( ARMHandler *h ); 171 174 172 175 nodeaddr_t findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ); 173 176 … … 176 179 signed int getAvailableBandwidth(); 177 180 signed int allocateIsoChannelGeneric(unsigned int bandwidth); 178 signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 181 signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 179 182 nodeid_t recv_node, int recv_plug); 180 183 bool freeIsoChannel(signed int channel); 181 184 182 185 private: 183 186 enum EAllocType { … … 196 199 int recv_plug; 197 200 }; 198 201 199 202 // the info for the channels we manage 200 203 struct ChannelInfo m_channels[64]; 201 204 202 205 bool unregisterIsoChannel(unsigned int c); 203 206 bool registerIsoChannel(unsigned int c, struct ChannelInfo cinfo); … … 211 214 void printBuffer( unsigned int level, size_t length, fb_quadlet_t* buffer ) const; 212 215 void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 213 216 214 217 static int resetHandlerLowLevel( raw1394handle_t handle, 215 218 unsigned int generation ); 216 219 bool resetHandler( unsigned int generation ); 217 220 218 221 static int armHandlerLowLevel(raw1394handle_t handle, unsigned long arm_tag, 219 222 byte_t request_type, unsigned int requested_length, 220 void *data); 223 void *data); 221 224 bool armHandler( unsigned long arm_tag, 222 225 byte_t request_type, unsigned int requested_length, … … 234 237 typedef std::vector< Functor* > reset_handler_vec_t; 235 238 reset_handler_vec_t m_busResetHandlers; 236 239 237 240 // ARM stuff 238 241 arm_tag_handler_t m_default_arm_handler; 239 242 240 243 typedef std::vector< ARMHandler * > arm_handler_vec_t; 241 244 arm_handler_vec_t m_armHandlers; 242 245 243 246 fb_octlet_t byteSwap_octlet(fb_octlet_t value); 244 247 245 248 public: 246 249 void setVerboseLevel(int l); … … 249 252 }; 250 253 251 #endif 254 #endif // FFADO_IEEE1394SERVICE_H