root/trunk/libffado/tests/unmute-ozonic.cpp

Revision 1988, 3.3 kB (checked in by adi, 10 months ago)

Add utility to unmute M-Audio Ozonic

Patch provided by Mark Brand (orania). Re: #341

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
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 program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 /*
25  * "unmute-ozonic" by Mark Brand (orania), based on "test-enhanced-mixer" by Daniel Wagner
26  * This is a knee-jerk reaction to the pathetic situation of requiring a dual-boot setup
27  * for the sole and only purpose of unmuting the outputs of my M-Audio Ozonic.  Seriously!? ;)
28  *
29  * This utility requires patches to avc_function_block.cpp and bebob_function_block.cpp
30  * which might be problematic for other devices?  I've included my patch to tests/SConscript.
31  *
32  * Also had a preliminary go at the mixer, which seems to work... but is incomplete.
33  * All were originally based on revision 1957, though everything works for me under 1985.
34  */
35
36 #include "libavc/audiosubunit/avc_function_block.h"
37 #include "libutil/cmd_serialize.h"
38
39 #include "libieee1394/ieee1394service.h"
40 #include <cstdlib>
41 #include <cstring>
42
43 using namespace AVC;
44
45 bool
46 doApp( Ieee1394Service& ieee1394service, int node_id, int fb_id, int inputChannel, int outputChannel, int value )
47 {
48     AVC::FunctionBlockCmd fbCmd( ieee1394service,
49                                  FunctionBlockCmd::eFBT_Processing,
50                                  fb_id,
51                                  FunctionBlockCmd::eCA_Current);
52     fbCmd.setNodeId( node_id );
53     fbCmd.setSubunitId( 0x00 );
54     fbCmd.setCommandType( AVCCommand::eCT_Control );
55
56     // Daniel says: "Ok, this enhanced mixer setting here is just a hack, we need
57     // a sane way to set processing features (read pointer management)"
58     delete fbCmd.m_pFBProcessing->m_pMixer;
59     fbCmd.m_pFBProcessing->m_pMixer = 0;
60     AVC::FunctionBlockProcessingEnhancedMixer em;
61     fbCmd.m_pFBProcessing->m_pEnhancedMixer = em.clone();
62
63     fbCmd.m_pFBProcessing->m_inputAudioChannelNumber = inputChannel;
64     fbCmd.m_pFBProcessing->m_outputAudioChannelNumber = outputChannel;
65     fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_statusSelector = FunctionBlockProcessingEnhancedMixer::eSS_Level;
66
67     fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_LevelData.clear();
68     fbCmd.m_pFBProcessing->m_pEnhancedMixer->m_LevelData.push_back((mixer_level_t) value);
69
70     if ( !fbCmd.fire() ) {
71         printf( "cmd failed\n" );
72         return false;
73     }
74
75     return true;
76 }
77
78 ///////////////////////////
79 // main
80 //////////////////////////
81 int
82 main(int argc, char **argv)
83 {
84     Ieee1394Service ieee1394service;
85     if ( !ieee1394service.initialize( 0 ) ) {
86         fprintf( stderr, "could not set port on ieee1394service\n" );
87         return -1;
88     }
89
90     /* MB: various values work below, these chosen *almost* arbitrarily */
91     doApp( ieee1394service, 0, 1, 1, 1, 0 );
92     return 0;
93 }
Note: See TracBrowser for help on using the browser.