#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include "Enumerate.h"
#include "rgb133vdif.h"
Functions | |
int | readCtrlSystemInfo (int fd, sVWSystemInfo *pSysInfo) |
int | readDeviceInfo (int fd, sVWDeviceInfo *pDeviceInfo) |
int | readDeviceParms (int fd, sVWDevice *pDevice) |
const char * | GetSignalState (unsigned long flags) |
int | main (int argc, char **argv) |
Variables | |
const char * | controlDevice = "/dev/video63" |
const char* GetSignalState | ( | unsigned long | flags | ) |
Implementation of GetSignalState
00091 { 00092 00093 if(flags & RGB133_VDIF_FLAG_DVI) 00094 { 00095 if(flags & RGB133_VDIF_FLAG_INTERLACED) 00096 return "Interlaced DVI"; 00097 else 00098 return "DVI"; 00099 00100 } 00101 else if(flags & RGB133_VDIF_FLAG_VIDEO) 00102 { 00103 if(flags & RGB133_VDIF_FLAG_INTERLACED) 00104 return "Interlaced VideoInput"; 00105 else 00106 return "VideoInput"; 00107 } 00108 else if(flags & RGB133_VDIF_FLAG_SDI) 00109 { 00110 if(flags & RGB133_VDIF_FLAG_INTERLACED) 00111 return "Interlaced SDI"; 00112 else 00113 return "SDI"; 00114 } 00115 else if(flags & RGB133_VDIF_FLAG_DVI_DUAL_LINK) 00116 { 00117 return "DVI-DL"; 00118 } 00119 else if(flags != RGB133_VDIF_FLAG_NOSIGNAL && 00120 flags != RGB133_VDIF_FLAG_OUTOFRANGE && 00121 flags != RGB133_VDIF_FLAG_UNRECOGNISABLE) 00122 { 00123 if(flags & RGB133_VDIF_FLAG_INTERLACED) 00124 return "Interlaced Analogue"; 00125 else 00126 return "Analogue"; 00127 } 00128 00129 return "Unknown Video Input"; 00130 }
int main | ( | int | argc, | |
char ** | argv | |||
) |
00133 { 00134 int fd = 0; 00135 int i = 0, j = 0; 00136 00137 sVWSystemInfo sysInfo; 00138 sVWDeviceInfo devInfo; 00139 sVWDevice device; 00140 00141 /* Initialise structures */ 00142 memset(&sysInfo, 0, sizeof(sysInfo)); 00143 memset(&devInfo, 0, sizeof(devInfo)); 00144 memset(&device, 0, sizeof(device)); 00145 00146 /* Open Vision Control device */ 00147 fd = open(controlDevice, O_RDWR); 00148 if(fd == 0) 00149 { 00150 printf("Failed to open \"%s\"...\n", controlDevice); 00151 return -1; 00152 } 00153 00154 /* Open Vision Control device */ 00155 if(readCtrlSystemInfo(fd, &sysInfo)) 00156 { 00157 printf("Failed to read Vision system info...\n"); 00158 close(fd); 00159 return -2; 00160 } 00161 00162 printf("System has %d Vision devices with a total of %d inputs...\n\n", 00163 sysInfo.devices, sysInfo.inputs); 00164 00165 /* Open Vision Control device */ 00166 for(i=0; i<sysInfo.devices; i++) 00167 { 00168 /* Set the device to be queried */ 00169 devInfo.device = i; 00170 device.device = i; 00171 if(readDeviceInfo(fd, &devInfo)) 00172 printf("Failed to read Vision device[%d] info...\n", i); 00173 else 00174 { 00175 /* Get inputs for device[i] */ 00176 for(j=0; j<devInfo.channels; j++) 00177 { 00178 /* Set the device's input to be queried */ 00179 device.input = j; 00180 00181 printf("Vision Device[%.2d] Input[%.2d]: Name(%s)\n", i, j, devInfo.name); 00182 printf(" Node(%s)\n", devInfo.node); 00183 00184 /* Read data from selected device and input */ 00185 if(readDeviceParms(fd, &device)) 00186 printf("Failed to read Vision device[%d] parms...\n", i); 00187 else 00188 { 00189 printf(" Input(%s)\n", GetSignalState(device.inputs[j].curDeviceParms.flags)); 00190 printf(" Width(%lu)\n", device.inputs[j].curDeviceParms.VideoTimings.HorAddrTime); 00191 printf(" Height(%lu)\n", device.inputs[j].curDeviceParms.VideoTimings.VerAddrTime); 00192 printf(" Refresh(%lu)\n", device.inputs[j].curDeviceParms.VideoTimings.VerFrequency); 00193 printf(" Brightness(%ld)\n", device.inputs[j].curDeviceParms.Brightness); 00194 printf(" Contrast(%ld)\n", device.inputs[j].curDeviceParms.Contrast); 00195 } 00196 } 00197 } 00198 } 00199 00200 close(fd); 00201 00202 return 0; 00203 }
int readCtrlSystemInfo | ( | int | fd, | |
sVWSystemInfo * | pSysInfo | |||
) |
Implementation of readCtrlSystemInfo
00030 { 00031 int bytes_read = 0; 00032 00033 memset(pSysInfo, 0, sizeof(sVWSystemInfo)); 00034 pSysInfo->magic = VW_MAGIC_SYSTEM_INFO; 00035 00036 bytes_read = read(fd, pSysInfo, sizeof(sVWSystemInfo)); 00037 if (bytes_read <= 0) 00038 { 00039 printf("readCtrlSystemInfo: Failed to read %d bytes of control info into buffer(%p)\n", 00040 sizeof(sVWSystemInfo), pSysInfo); 00041 return -1; 00042 } 00043 00044 return 0; 00045 }
int readDeviceInfo | ( | int | fd, | |
sVWDeviceInfo * | pDeviceInfo | |||
) |
Implementation of readDeviceInfo
00051 { 00052 int bytes_read = 0; 00053 00054 pDeviceInfo->magic = VW_MAGIC_DEVICE_INFO; 00055 00056 bytes_read = read(fd, pDeviceInfo, sizeof(sVWDeviceInfo)); 00057 if (bytes_read <= 0) 00058 { 00059 printf("readDeviceInfo: Failed to read %d bytes of device[%d] info into buffer(%p)\n", 00060 sizeof(sVWDeviceInfo), pDeviceInfo->device, pDeviceInfo); 00061 return -1; 00062 } 00063 00064 return 0; 00065 }
int readDeviceParms | ( | int | fd, | |
sVWDevice * | pDevice | |||
) |
Implementation of readDeviceParms
00071 { 00072 int bytes_read = 0; 00073 00074 pDevice->magic = VW_MAGIC_DEVICE; 00075 00076 bytes_read = read(fd, pDevice, sizeof(sVWDevice)); 00077 if (bytes_read <= 0) 00078 { 00079 printf("readDeviceParms: Failed to read %d bytes of device[%d] info into buffer(%p)\n", 00080 sizeof(sVWDevice), pDevice->device, pDevice); 00081 return -1; 00082 } 00083 00084 return 0; 00085 }
const char* controlDevice = "/dev/video63" |