]> git.vomp.tv Git - vompclient-marten.git/blob - mtdmvp.cc
Fix bug in demuxer widescreen signaling
[vompclient-marten.git] / mtdmvp.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "mtdmvp.h"
22
23 #include "log.h"
24
25 MtdMVP::MtdMVP()
26 {
27   if (instance) return;
28   initted = 0;
29 }
30
31 MtdMVP::~MtdMVP()
32 {
33 }
34
35 int MtdMVP::init()
36 {
37   if (initted) return 0;
38   initted = 1;
39
40   FILE* fp = fopen("/proc/mtd", "r");
41   if (!fp)
42   {
43     Log::getInstance()->log("MTD", Log::DEBUG, "Could not open /proc/mtd");
44     initted = 0;
45     return 0;
46   }
47
48   char buffer[1024];
49   char mtdNumberChar = '\0';
50
51   while(!feof(fp))
52   {
53     fgets(buffer, 1023, fp);
54     if (strstr(buffer, "HCW MediaMVP VPD"))
55     {
56       mtdNumberChar = buffer[3];
57     }
58   }
59   fclose(fp);
60
61   if (mtdNumberChar == '\0')
62   {
63     Log::getInstance()->log("MTD", Log::DEBUG, "Failed to find correct /dev/mtdX device");
64     initted = 0;
65     return 0;
66   }
67
68   strcpy(buffer, "/dev/mtd");
69   strncat(buffer, &mtdNumberChar, 1);
70   Log::getInstance()->log("MTD", Log::DEBUG, "Located MTD device: %s", buffer);
71
72
73   int fd;
74
75   if ((fd = open(buffer, O_RDONLY)) < 0)
76   {
77     Log::getInstance()->log("MTD", Log::DEBUG, "Open fail");
78     initted = 0;
79     return 0;
80   }
81
82   if (read(fd, data, 8192) < 8192)
83   {
84     Log::getInstance()->log("MTD", Log::DEBUG, "Read fail");
85     initted = 0;
86     return 0;
87   }
88
89   close(fd);
90
91   //logit();
92
93   return 1;
94 }
95
96 int MtdMVP::shutdown()
97 {
98   if (!initted) return 0;
99   initted = 0;
100   return 1;
101 }
102
103 short MtdMVP::getPALorNTSC()
104 {
105   return data[2119];
106 }
107
108 /*
109 short MtdMVP::getAspect()
110 {
111   return data[2125];
112 }
113
114 short MtdMVP::getFlicker()
115 {
116   return data[2124];
117 }
118
119 short MtdMVP::getBootLogoOutput()
120 {
121   return data[2116];
122 }
123
124 short MtdMVP::getBootLogoDisplayVideoLeft()
125 {
126   return data[2120];
127 }
128
129 short MtdMVP::getBootLogoDisplayVideoUpper()
130 {
131   return data[2121];
132 }
133
134 short MtdMVP::getBootLogoDisplayVideoWidth()
135 {
136   return data[2122];
137 }
138
139 short MtdMVP::getBootLogoDisplayVideoHeight()
140 {
141   return data[2123];
142 }
143
144 void MtdMVP::logit()
145 {
146   Log* logger = Log::getInstance();
147
148   logger->log("MTD", Log::DEBUG, "Mode: %i", getPALorNTSC());
149   logger->log("MTD", Log::DEBUG, "Aspect: %i", getAspect());
150   logger->log("MTD", Log::DEBUG, "Flicker: %i", getFlicker());
151   logger->log("MTD", Log::DEBUG, "Bootlogo output: %i", getBootLogoOutput());
152   logger->log("MTD", Log::DEBUG, "Bootlogo display video left: %i", getBootLogoDisplayVideoLeft());
153   logger->log("MTD", Log::DEBUG, "Bootlogo display video upper: %i", getBootLogoDisplayVideoUpper());
154   logger->log("MTD", Log::DEBUG, "Bootlogo display video width: %i", getBootLogoDisplayVideoWidth());
155   logger->log("MTD", Log::DEBUG, "Bootlogo display video height: %i", getBootLogoDisplayVideoHeight());
156 }
157 */