root/trunk/libffado/src/libavc/general/avc_signal_format.cpp

Revision 864, 3.8 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

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 #include "avc_signal_format.h"
25 #include "libutil/cmd_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29 #include <iostream>
30
31 using namespace std;
32
33 namespace AVC {
34
35 OutputPlugSignalFormatCmd::OutputPlugSignalFormatCmd(Ieee1394Service& ieee1394service)
36     : AVCCommand( ieee1394service, AVC1394_CMD_OUTPUT_PLUG_SIGNAL_FORMAT )
37     , m_plug ( 0 )
38     , m_eoh  ( 1 )
39     , m_form ( 0 )
40     , m_fmt  ( 0 )
41 {
42     m_fdf[0]=0xFF;
43     m_fdf[1]=0xFF;
44     m_fdf[2]=0xFF;
45 }
46
47 OutputPlugSignalFormatCmd::~OutputPlugSignalFormatCmd()
48 {
49 }
50
51 bool
52 OutputPlugSignalFormatCmd::serialize( Util::Cmd::IOSSerialize& se )
53 {
54     bool result=true;
55     result &= AVCCommand::serialize( se );
56    
57     result &= se.write(m_plug,"OutputPlugSignalFormatCmd plug");
58    
59     byte_t tmp = ((m_eoh & 0x01)<<7);
60     tmp |= ((m_form & 0x01)<<6);
61     tmp |= (m_fmt & 0x3f);
62    
63     result &= se.write(tmp,"OutputPlugSignalFormatCmd eoh,form,fmt");
64    
65     result &= se.write(m_fdf[0],"OutputPlugSignalFormatCmd fdf[0]");
66     result &= se.write(m_fdf[1],"OutputPlugSignalFormatCmd fdf[1]");
67     result &= se.write(m_fdf[2],"OutputPlugSignalFormatCmd fdf[2]");
68
69     return result;
70 }
71
72 bool
73 OutputPlugSignalFormatCmd::deserialize( Util::Cmd::IISDeserialize& de )
74 {
75     bool result=true;
76     result &= AVCCommand::deserialize( de );
77     result &= de.read(&m_plug);
78    
79     byte_t tmp;
80     result &= de.read(&tmp);
81    
82     m_eoh=((tmp & 0x80)>>7);
83     m_form=((tmp & 0x40)>>6);
84     m_fmt=tmp & 0x3f;
85    
86     result &= de.read(&m_fdf[0]);
87     result &= de.read(&m_fdf[1]);
88     result &= de.read(&m_fdf[2]);
89    
90     return result;
91 }
92
93 //------------------------
94
95 InputPlugSignalFormatCmd::InputPlugSignalFormatCmd(Ieee1394Service& ieee1394service)
96     : AVCCommand( ieee1394service, AVC1394_CMD_INPUT_PLUG_SIGNAL_FORMAT )
97     , m_plug ( 0 )
98     , m_eoh  ( 1 )
99     , m_form ( 0 )
100     , m_fmt  ( 0 )
101 {
102     m_fdf[0]=0xFF;
103     m_fdf[1]=0xFF;
104     m_fdf[2]=0xFF;
105 }
106
107 InputPlugSignalFormatCmd::~InputPlugSignalFormatCmd()
108 {
109 }
110
111 bool
112 InputPlugSignalFormatCmd::serialize( Util::Cmd::IOSSerialize& se )
113 {
114     bool result=true;
115     result &= AVCCommand::serialize( se );
116    
117     result &= se.write(m_plug,"InputPlugSignalFormatCmd plug");
118    
119     byte_t tmp = ((m_eoh& 0x01)<<7);
120     tmp |= ((m_form& 0x01)<<6);
121     tmp |= (m_fmt& 0x3f);
122    
123     result &= se.write(tmp,"InputPlugSignalFormatCmd eoh,form,fmt");
124    
125     result &= se.write(m_fdf[0],"InputPlugSignalFormatCmd fdf[0]");
126     result &= se.write(m_fdf[1],"InputPlugSignalFormatCmd fdf[1]");
127     result &= se.write(m_fdf[2],"InputPlugSignalFormatCmd fdf[2]");
128
129     return result;
130 }
131
132 bool
133 InputPlugSignalFormatCmd::deserialize( Util::Cmd::IISDeserialize& de )
134 {
135     bool result=true;
136     result &= AVCCommand::deserialize( de );
137     result &= de.read(&m_plug);
138    
139     byte_t tmp;
140     result &= de.read(&tmp);
141    
142     m_eoh=((tmp & 0x80)>>7);
143     m_form=((tmp & 0x40)>>6);
144     m_fmt=tmp & 0x3f;
145    
146     result &= de.read(&m_fdf[0]);
147     result &= de.read(&m_fdf[1]);
148     result &= de.read(&m_fdf[2]);
149    
150     return result;
151 }
152 }
Note: See TracBrowser for help on using the browser.