2 * Copyright (C) 2005-2008 by Daniel Wagner
3 * Copyright (C) 2005-2008 by Pieter Palmers
5 * This file is part of FFADO
6 * FFADO = Free Firewire (pro-)audio drivers for linux
8 * FFADO is based upon FreeBoB
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) version 3 of the License.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <libraw1394/raw1394.h>
26 #include <libiec61883/iec61883.h>
35 ////////////////////////////////////////////////
37 ////////////////////////////////////////////////
38 const char *argp_program_version
= "test-streamdump 0.1";
39 const char *argp_program_bug_address
= "<ffado-devel@lists.sf.net>";
40 static char doc
[] = "test-streamdump -- test program to get a BeBoB device to stream and to save the streams";
41 static char args_doc
[] = "NODE_ID";
42 static struct argp_option options
[] = {
43 {"verbose", 'v', 0, 0, "Produce verbose output" },
44 {"port", 'p', "PORT", 0, "Set port" },
64 // Parse a single option.
66 parse_opt( int key
, char* arg
, struct argp_state
* state
)
68 // Get the input argument from `argp_parse', which we
69 // know is a pointer to our arguments structure.
70 struct arguments
* arguments
= ( struct arguments
* ) state
->input
;
76 arguments
->verbose
= true;
79 arguments
->test
= true;
82 arguments
->port
= strtol(arg
, &tail
, 0);
84 perror("argument parsing failed:");
89 if (state
->arg_num
>= 1) {
90 // Too many arguments.
93 arguments
->args
[state
->arg_num
] = arg
;
96 if (state
->arg_num
< 1) {
97 // Not enough arguments.
102 return ARGP_ERR_UNKNOWN
;
107 static struct argp argp
= { options
, parse_opt
, args_doc
, doc
};
109 ///////////////////////////
111 //////////////////////////
113 main(int argc
, char **argv
)
116 argp_parse (&argp
, argc
, argv
, 0, 0, &arguments
);
120 int iNodeId
= strtol(arguments
.args
[0], &tail
, 0);
122 perror("argument parsing failed:");
126 raw1394handle_t pHandle
= raw1394_new_handle_on_port( arguments
.port
);
129 cerr
<< "libraw1394 not compatible" << endl
;
131 perror( "Could not get 1394 handle" );
132 cerr
<< "Is ieee1394 and raw1394 driver loaded?" << endl
;
147 int iLocalId
= raw1394_get_local_id( pHandle
);
148 int iRemoteId
= iNodeId
| 0xffc0;
149 Connection cons
[] = {
150 // output, oplug, input, iplug, bandwith, iso channel
151 { iRemoteId
, 0, iLocalId
, -1, 0x148, -1 }, // oPCR[0]
152 // { iRemoteId, 1, iLocalId, -1, 0x148, -1 }, // oPCR[1]
153 // { iRemoteId, 2, iLocalId, -1, 0, -1 }, // oPCR[2]: cmp not supported
154 // { iLocalId, -1, iRemoteId, 0, 0x148, -1 }, // iPCR[0]
155 // { iLocalId, -1, iRemoteId, 1, 0x148, -1 }, // iPCR[1]
156 // { iLocalId, -1, iRemoteId, 2, 0, -1 }, // iPCR[2]: cmp not supported
159 printf( "local node id %d\n", iLocalId
& ~0xffc0);
160 printf( "remote node id %d\n", iRemoteId
& ~0xffc0);
162 for ( unsigned int i
= 0; i
< sizeof( cons
) / sizeof( cons
[0] ); ++i
) {
163 Connection
* pCons
= &cons
[i
];
165 // the bandwith calculation fails, so its better to use
166 // some default values.
167 pCons
->m_iBandwith
= iec61883_cmp_calc_bandwidth ( pHandle
,
170 IEC61883_DATARATE_400
);
172 pCons
->m_iIsoChannel
= iec61883_cmp_connect( pHandle
,
177 &pCons
->m_iBandwith
);
178 printf( "%2d -> %2d %cPCR[%2d]: bw = %4d, ch = %2d\n",
179 pCons
->m_output
& ~0xffc0,
180 pCons
->m_input
& ~0xffc0,
181 pCons
->m_oplug
== -1? 'i' : 'o',
182 pCons
->m_oplug
== -1? pCons
->m_iplug
: pCons
->m_oplug
,
184 pCons
->m_iIsoChannel
);
190 for ( unsigned int i
= 0; i
< sizeof( cons
) / sizeof( cons
[0] ); ++i
) {
191 Connection
* pCons
= &cons
[i
];
193 if ( pCons
->m_iIsoChannel
!= -1 ) {
194 printf( "disconnect\n");
195 iec61883_cmp_disconnect( pHandle
,
200 pCons
->m_iIsoChannel
,
201 pCons
->m_iBandwith
);
208 raw1394_destroy_handle( pHandle
);