root/trunk/freebob/src/avdevicesubunit.cpp

Revision 35, 4.3 kB (checked in by pieterpalmers, 19 years ago)

- code merge
- some more experiments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avdevicesubunit.cpp
2  * Copyright (C) 2004 by Pieter Palmers
3  *
4  * This file is part of FreeBob.
5  *
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,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20 #include <errno.h>
21 #include <libavc1394/avc1394.h>
22 #include <libavc1394/avc1394_vcr.h>
23 #include "debugmodule.h"
24 #include "avdevice.h"
25 #include "avdevicesubunit.h"
26
27
28 void AvDeviceSubunit::test() {
29
30 }
31
32 void AvDeviceSubunit::printOutputPlugConnections() {
33         unsigned char byte;
34         quadlet_t request[6];
35         quadlet_t *response;
36        
37         unsigned char opcr=0;
38        
39         debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus iso output plug connections:\n");
40         for(opcr=0;opcr<0x1E;opcr++) { 
41                 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16)
42                                                 | (0x1A << 8) | 0xFF;
43                 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F;
44                 request[1]=0xFFFEFF00 | opcr;
45                 response = cParent->avcExecuteTransaction(request, 2, 4);
46                 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) {
47                         unsigned char output_status=(response[0]&0xE0) >> 5;
48                         unsigned char conv=(response[0]&0x10) >> 4;
49                         unsigned char signal_status=(response[0]&0x0F);
50                        
51                         unsigned int signal_source=((response[1]>>16)&0xFFFF);
52                         unsigned int signal_destination=((response[1])&0xFFFF);
53                         debugPrint(DEBUG_LEVEL_SUBUNIT,"  oPCR %d: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination);
54                 }
55         }
56         debugPrint(DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: Serial bus external output plug connections:\n");
57         for(opcr=0x80;opcr<0x9E;opcr++) {       
58                 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16)
59                                                 | (0x1A << 8) | 0xFF;
60                 //request[1] = ((iTarget & 0x1F) << 27) | ((iId & 0x07) << 24) | 0x00FF7F;
61                 request[1]=0xFFFEFF00 | opcr;
62                 response = cParent->avcExecuteTransaction(request, 2, 4);
63                 if ((response != NULL) && ((response[0]&0xFF000000)==0x0C000000)) {
64                         unsigned char output_status=(response[0]&0xE0) >> 5;
65                         unsigned char conv=(response[0]&0x10) >> 4;
66                         unsigned char signal_status=(response[0]&0x0F);
67                        
68                         unsigned int signal_source=((response[1]>>16)&0xFFFF);
69                         unsigned int signal_destination=((response[1])&0xFFFF);
70                         debugPrint(DEBUG_LEVEL_SUBUNIT,"  oPCR %02X: output_status=%d,conv=%d,signal_status=%d,signal_source=0x%04X,signal_destination=0x%04X\n",opcr,output_status,conv,signal_status,signal_source,signal_destination);
71                 }
72         }
73
74 }
75
76 AvDeviceSubunit::AvDeviceSubunit(AvDevice *parent, unsigned char target, unsigned char  id)
77 {
78         unsigned char byte;
79         quadlet_t request[6];
80         quadlet_t *response;
81
82         cParent=parent;
83         iTarget=target;
84         iId=id;
85         iNbDestinationPlugs=0;
86         iNbSourcePlugs=0;
87
88         debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit target=%02X id=%02X created\n",target,id);
89
90         if (!cParent) {
91                 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n");
92                 bValid=false;
93                 return;
94         }
95
96         bValid=true;
97
98         // check the number of I/O plugs
99
100         request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16)
101                                         | AVC1394_COMMAND_PLUG_INFO | 0x00;
102         request[1] = 0xFFFFFFFF;
103         response = cParent->avcExecuteTransaction(request, 2, 2);
104         if (response != NULL) {
105                 iNbDestinationPlugs= (unsigned char) ((response[1]>>24) & 0xff);
106                 iNbSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff);
107         }
108         debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: %d source plugs, %d destination plugs\n",iNbSourcePlugs,iNbDestinationPlugs);
109
110
111 }
112
113 AvDeviceSubunit::~AvDeviceSubunit()
114 {
115
116 }
117
118 bool AvDeviceSubunit::isValid()
119 {
120         return bValid;
121 }
122
123 unsigned char AvDeviceSubunit::getNbDestinationPlugs() {
124         return iNbDestinationPlugs;
125 }
126
127 unsigned char AvDeviceSubunit::getNbSourcePlugs() {
128         return iNbSourcePlugs;
129 }
Note: See TracBrowser for help on using the browser.