root/trunk/libffado/tests/test-echo.cpp

Revision 554, 7.7 kB (checked in by ppalmers, 17 years ago)

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Line 
1 /*
2  * Copyright (C) 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  * FFADO 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) any later version.
14  * FFADO 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
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with FFADO; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA.
23  *
24  */
25
26 #include <libraw1394/raw1394.h>
27 #include <libiec61883/iec61883.h>
28 #include <libavc1394/avc1394.h>
29
30 #include <argp.h>
31 #include <stdlib.h>
32 #include <iostream>
33
34 using namespace std;
35
36 ////////////////////////////////////////////////
37 // arg parsing
38 ////////////////////////////////////////////////
39 const char *argp_program_version = "test-echo 0.1";
40 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>";
41 static char doc[] = "test-echo -- test program for the ECHO AUDIOFIRE devices";
42 static char args_doc[] = "NODE_ID";
43 static struct argp_option options[] = {
44     {"verbose",   'v', 0,           0,  "Produce verbose output" },
45     {"port",      'p', "PORT",      0,  "Set port" },
46    { 0 }
47 };
48
49 struct arguments
50 {
51     arguments()
52         : verbose( false )
53         , test( false )
54         , port( 0 )
55         {
56             args[0] = 0;
57         }
58
59     char* args[1];
60     bool  verbose;
61     bool  test;
62     int   port;
63 } arguments;
64
65 // Parse a single option.
66 static error_t
67 parse_opt( int key, char* arg, struct argp_state* state )
68 {
69     // Get the input argument from `argp_parse', which we
70     // know is a pointer to our arguments structure.
71     struct arguments* arguments = ( struct arguments* ) state->input;
72
73     char* tail;
74     switch (key) {
75     case 'v':
76         arguments->verbose = true;
77         break;
78     case 't':
79         arguments->test = true;
80         break;
81     case 'p':
82         errno = 0;
83         arguments->port = strtol(arg, &tail, 0);
84         if (errno) {
85             perror("argument parsing failed:");
86             return errno;
87         }
88         break;
89     case ARGP_KEY_ARG:
90         if (state->arg_num >= 1) {
91             // Too many arguments.
92             argp_usage (state);
93         }
94         arguments->args[state->arg_num] = arg;
95         break;
96     case ARGP_KEY_END:
97         if (state->arg_num < 1) {
98             // Not enough arguments.
99             argp_usage (state);
100         }
101         break;
102     default:
103         return ARGP_ERR_UNKNOWN;
104     }
105     return 0;
106 }
107
108 static struct argp argp = { options, parse_opt, args_doc, doc };
109
110 ///////////////////////////
111 // main
112 //////////////////////////
113 int
114 main(int argc, char **argv)
115 {
116     // arg parsing
117     argp_parse (&argp, argc, argv, 0, 0, &arguments);
118
119     errno = 0;
120     char* tail;
121     int iNodeId = strtol(arguments.args[0], &tail, 0);
122     if (errno) {
123     perror("argument parsing failed:");
124     return -1;
125     }
126
127     raw1394handle_t pHandle = raw1394_new_handle_on_port( arguments.port );
128     if ( !pHandle ) {
129         if ( !errno ) {
130             cerr << "libraw1394 not compatible" << endl;
131         } else {
132             perror( "Could not get 1394 handle" );
133             cerr << "Is ieee1394 and raw1394 driver loaded?" << endl;
134         }
135         return -1;
136     }
137     quadlet_t cmd[6];
138     unsigned int response_len;
139    
140 //     cerr << "Opening descriptor" << endl;
141 //     0h 05m 21.760442s - GetDescriptorOpen:  cmd[0]= < 0x00 0x60 0x08 0x80 0x01 0xFF>
142 //     0h 05m 21.760687s - GetDescriptorOpen: resp[0]= < 0x09 0x60 0x08 0x80 0x01 0xFF > ACCEPTED
143
144
145 //     cmd[0] = 0x00600880;
146 //     cmd[1] = 0x01FF0000;
147 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
148 //     usleep(100000);
149 //     
150 //     cerr << "Reading descriptor" << endl;
151 // //     0h 05m 21.760700s - GetDescriptorRead:  cmd[0]= < 0x00 0x60 0x09 0x80 0xFF 0xFF 0x00 0x00 0x00 0x00>
152 // //     0h 05m 21.761123s - GetDescriptorRead: resp[0]= < 0x09 0x60 0x09 0x80 0x11 0xFF 0x01 0xF6 0x00 0x00 0x03 0x9E
153 //     cmd[0] = 0x00600980;
154 //     cmd[1] = 0xFFFF0000;
155 //     cmd[2] = 0x00000000;
156 //     cmd[2] = 0x00000000;
157 //     
158 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 3, &response_len, 10);
159 //     usleep(100000);
160 //     
161 //     cerr << "Closing descriptor" << endl;
162 //     cmd[0] = 0x00600880;
163 //     cmd[1] = 0x00FF0000;
164 //     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
165 //     usleep(100000);
166
167     cerr << "getting signal source" << endl;
168 //     0h 05m 21.762917s - at line 2283, fMaxAudioOutputChannels=2, fMaxAudioInputChannels=0
169 //     0h 05m 21.762919s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x00>
170 //     0h 05m 21.763149s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x60 0x60 0x00 0xFF 0x00 > IMPLEMENTED
171 //     0h 05m 21.763167s - Isoch out 0 gets its signal from sub/unit 0x60 Source Plug 0
172 //     0h 05m 21.763170s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x80>
173 //     0h 05m 21.763376s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x01 0xFF 0x80 > IMPLEMENTED
174 //     0h 05m 21.763394s - Isoch out 128 gets its signal from sub/unit 0x60 Source Plug 1
175 //     0h 05m 21.763397s - GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0xFF 0x81>
176 //     0h 05m 21.763637s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x02 0xFF 0x81 > IMPLEMENTED
177 //     0h 05m 21.763654s - Isoch out 129 gets its signal from sub/unit 0x60 Source Plug 2
178
179 //     0h 05m 21.764895s - Starting to look at subunit 1.  fNumberOfSubUnits = 2
180 //     0h 05m 21.764897s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x00>
181 //     0h 05m 21.765129s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x20 0xFF 0x00 0x60 0x00 > IMPLEMENTED
182 //     0h 05m 21.765140s - Subunit type12, addr:0x60 dest 0 gets its signal from sub/unit 0xff Source Plug 0
183 //     0h 05m 21.765142s - subunit 96 dest plug 0 is routed
184 //     0h 05m 21.765143s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x01>
185 //     0h 05m 21.765364s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x80 0x60 0x01 > IMPLEMENTED
186 //     0h 05m 21.765382s - Subunit type12, addr:0x60 dest 1 gets its signal from sub/unit 0xff Source Plug 128
187 //     0h 05m 21.765385s -      Plug being changed from 0x80 to 1 for internal bookeeping.
188 //     0h 05m 21.765389s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x02>
189 //     0h 05m 21.765632s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0xFF 0x81 0x60 0x02 > IMPLEMENTED
190 //     0h 05m 21.765651s - Subunit type12, addr:0x60 dest 2 gets its signal from sub/unit 0xff Source Plug 129
191 //     0h 05m 21.765653s -      Plug being changed from 0x81 to 2 for internal bookeeping.
192 //     0h 05m 21.765657s - Subunit 1 GetSignalSource:  cmd[0]= < 0x01 0xFF 0x1A 0xFF 0xFF 0xFE 0x60 0x03>
193 //     0h 05m 21.765874s - GetSignalSource: resp[0]= < 0x0c 0xFF 0x1A 0x00 0x60 0x03 0x60 0x03 > IMPLEMENTED
194 //     0h 05m 21.765892s - Subunit type12, addr:0x60 dest 3 gets its signal from sub/unit 0x60 Source Plug 3
195
196     cmd[0] = 0x01FF1AFF;
197     cmd[1] = 0xFFFE6000;
198     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
199 //     usleep(100000);
200    
201     cmd[0] = 0x01FF1AFF;
202     cmd[1] = 0xFFFEFF00;
203     avc1394_transaction_block2(pHandle, 0xffc0 | iNodeId, cmd, 2, &response_len, 10);
204     usleep(100000);
205
206
207
208     raw1394_destroy_handle( pHandle );
209     return 0;
210 }
Note: See TracBrowser for help on using the browser.