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