]> git.vomp.tv Git - vompclient.git/blob - mtd.cc
Connection failure detection
[vompclient.git] / mtd.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP 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
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "mtd.h"
22
23 Mtd* Mtd::instance = NULL;
24
25 Mtd::Mtd()
26 {
27   if (instance) return;
28   instance = this;
29   initted = 0;
30 }
31
32 Mtd::~Mtd()
33 {
34   instance = NULL;
35 }
36
37 Mtd* Mtd::getInstance()
38 {
39   return instance;
40 }
41
42 int Mtd::init(char* device)
43 {
44   if (initted) return 0;
45   initted = 1;
46
47   int fd;
48
49   if ((fd = open(device, O_RDONLY)) < 0)
50   {
51     initted = 0;
52     return 0;
53   }
54
55   if (read(fd, data, 8192) < 8192)
56   {
57     initted = 0;
58     return 0;
59   }
60
61   close(fd);
62
63   logit();
64
65   return 1;
66 }
67
68 int Mtd::shutdown()
69 {
70   if (!initted) return 0;
71   initted = 0;
72   return 1;
73 }
74
75 short Mtd::getPALorNTSC()
76 {
77   return data[2119];
78 }
79
80 short Mtd::getAspect()
81 {
82   return data[2125];
83 }
84
85 short Mtd::getFlicker()
86 {
87   return data[2124];
88 }
89
90 short Mtd::getBootLogoOutput()
91 {
92   return data[2116];
93 }
94
95 short Mtd::getBootLogoDisplayVideoLeft()
96 {
97   return data[2120];
98 }
99
100 short Mtd::getBootLogoDisplayVideoUpper()
101 {
102   return data[2121];
103 }
104
105 short Mtd::getBootLogoDisplayVideoWidth()
106 {
107   return data[2122];
108 }
109
110 short Mtd::getBootLogoDisplayVideoHeight()
111 {
112   return data[2123];
113 }
114
115 void Mtd::logit()
116 {
117   Log* logger = Log::getInstance();
118
119   logger->log("MTD", Log::DEBUG, "Mode: %i", getPALorNTSC());
120   logger->log("MTD", Log::DEBUG, "Aspect: %i", getAspect());
121   logger->log("MTD", Log::DEBUG, "Flicker: %i", getFlicker());
122   logger->log("MTD", Log::DEBUG, "Bootlogo output: %i", getBootLogoOutput());
123   logger->log("MTD", Log::DEBUG, "Bootlogo display video left: %i", getBootLogoDisplayVideoLeft());
124   logger->log("MTD", Log::DEBUG, "Bootlogo display video upper: %i", getBootLogoDisplayVideoUpper());
125   logger->log("MTD", Log::DEBUG, "Bootlogo display video width: %i", getBootLogoDisplayVideoWidth());
126   logger->log("MTD", Log::DEBUG, "Bootlogo display video height: %i", getBootLogoDisplayVideoHeight());
127 }