1 diff --git a/.gitignore b/.gitignore
2 index ccfb515..a6f8d11 100644
5 @@ -16,3 +16,4 @@ install-sh
10 diff --git a/main.c b/main.c
11 index 190ff5f..c611913 100644
14 @@ -38,6 +38,7 @@ Feel free to use the code for your own projects. See LICENSE file for details.
16 #include <sys/types.h>
22 @@ -101,10 +102,24 @@ static void combine(unsigned char *output,
23 const unsigned char *video, const unsigned char *osd,
24 unsigned int xres, unsigned int yres);
28 +enum {UNKNOWN,PALLAS,VULCAN,XILLEON,BRCM7401,BRCM7400,BRCM7405,BRCM7335,BRCM7325,BRCM7346,BRCM7425};
29 +char *stb_name[]={"unknown","Pallas","Vulcan","Xilleon","Brcm7401","Brcm7400","Brcm7405","Brcm7335","Brcm7325","Brcm7346","Brcm7425"};
31 enum {UNKNOWN,PALLAS,VULCAN,XILLEON,BRCM7401,BRCM7400,BRCM7405};
32 static const char *stb_name[]={"unknown","Pallas","Vulcan","Xilleon","Brcm7401","Brcm7400","Brcm7405"};
34 static int stb_type=UNKNOWN;
36 +char* upcase(char* mixedstr)
39 + for (j=0; j< strlen(mixedstr); ++j)
40 + mixedstr[j]=toupper(mixedstr[j]);
44 static const char *file_getline(const char *filename)
46 static char *line = NULL;
47 @@ -184,7 +199,6 @@ static int file_scanf_lines(const char *filename, const char *fmt, ...)
52 int main(int argc, char **argv) {
54 printf("AiO Dreambox Screengrabber " PACKAGE_VERSION "\n\n");
55 @@ -205,11 +219,29 @@ int main(int argc, char **argv) {
56 char filename[256] = { "/tmp/screenshot.bmp" };
59 - const char *line = file_getline("/proc/fb");
60 + char *line = (char*)file_getline("/proc/fb");
64 if (strstr(line, "bcmfb")) {
66 + if((line=(char*)file_getline("/proc/stb/info/chipset")) == NULL)
68 + if (strstr(upcase(line),"7335"))
70 + else if (strstr(upcase(line),"7325"))
72 + else if (strstr(upcase(line),"7405"))
74 + else if (strstr(upcase(line),"7356"))
76 + else if (strstr(upcase(line),"7346"))
78 + else if (strstr(upcase(line),"7424"))
80 + else if (strstr(upcase(line),"7425"))
83 line = file_getline("/proc/stb/info/model");
86 @@ -221,6 +253,7 @@ int main(int argc, char **argv) {
87 !strcmp(line, "dm800se") ||
88 !strcmp(line, "dm7020hd"))
91 } else if (strstr(line, "xilleonfb")) {
93 } else if (strstr(line, "Pallas FB")) {
94 @@ -563,16 +596,34 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
100 + if (stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405 || stb_type == BRCM7335 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425)
102 if (stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405)
105 // grab brcm7401 pic from decoder memory
107 + off_t offset_addr = 0x10600000;
113 + case BRCM7325: offset_addr = 0x10100000; break;
115 + unsigned char *memory = mmap(0, 100, PROT_READ, MAP_SHARED, mem_fd, offset_addr);
116 + if (memory == MAP_FAILED) {
121 unsigned char *memory = mmap(0, 100, PROT_READ, MAP_SHARED, mem_fd, 0x10100000);
122 if (memory == MAP_FAILED) {
128 unsigned char data[100];
130 unsigned int adr,adr2,ofs,ofs2,offset/*,vert_start,vert_end*/;
131 @@ -582,12 +633,30 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
132 memcpy(data,memory,100);
133 //vert_start=data[0x1B]<<8|data[0x1A];
134 //vert_end=data[0x19]<<8|data[0x18];
136 + if(stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405 || stb_type == BRCM7335 || stb_type == BRCM7325) {
137 + stride=data[0x15]<<8|data[0x14];
138 + ofs=(data[0x28]<<8|data[0x27])>>4;
139 + ofs2=(data[0x2c]<<8|data[0x2b])>>4;
140 + adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
141 + adr2=(data[0x23]<<24|data[0x22]<<16|data[0x21]<<8|data[0x20])&0xFFFFFF00;
144 + stride=data[0x15]<<8|data[0x14];
145 + ofs=(data[0x3c]<<8|data[0x3b])>>4;
146 + ofs2=(data[0x40]<<8|data[0x3f])>>4;
147 + adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
148 + adr2=(data[0x37]<<24|data[0x36]<<16|data[0x35]<<8|data[0x34])&0xFFFFFF00;
152 stride=data[0x15]<<8|data[0x14];
153 ofs=(data[0x28]<<8|data[0x27])>>4;
154 ofs2=(data[0x2c]<<8|data[0x2b])>>4;
155 adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
156 adr2=(data[0x23]<<24|data[0x22]<<16|data[0x21]<<8|data[0x20])&0xFFFFFF00;
162 @@ -609,7 +678,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
165 // grabbing luma & chroma plane from the decoder memory
167 + if (stb_type == BRCM7401 || stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425) {
169 if (stb_type == BRCM7401 || stb_type == BRCM7405) {
171 // on dm800/dm500hd we have direct access to the decoder memory
172 memory = mmap(0, offset + stride*(ofs2+64), PROT_READ, MAP_SHARED, mem_fd, adr);
173 if (memory == MAP_FAILED) {
174 @@ -620,7 +693,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
175 usleep(50000); // we try to get a full picture, its not possible to get a sync from the decoder so we use a delay
176 // and hope we get a good timing. dont ask me why, but every DM800 i tested so far produced a good
177 // result with a 50ms delay
179 + } else if (stb_type == BRCM7400 || stb_type == BRCM7335) {
181 } else if (stb_type == BRCM7400) {
183 // on dm8000 we have to use dma, so dont change anything here until you really know what you are doing !
186 @@ -639,7 +716,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
189 volatile unsigned long *mem_dma;
191 + mem_dma = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, (stb_type==BRCM7400)?0x10c02000:0x10c01000);
193 mem_dma = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0x10c02000);
195 if (mem_dma == MAP_FAILED) {
198 @@ -675,8 +756,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
199 unsigned int t = 0, t2 = 0, dat1 = 0;
200 unsigned int chr_luma_stride = 0x40;
204 + if (stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425)
206 if (stb_type == BRCM7405)
208 chr_luma_stride *= 2;
210 xsub=chr_luma_stride;
211 @@ -710,10 +794,17 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
217 + if (stb_type == BRCM7401 || stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425) {
219 if (stb_type == BRCM7401 || stb_type == BRCM7405)
221 munmap(memory, offset + stride * (ofs2 + 64));
223 + } else if (stb_type == BRCM7400 || stb_type == BRCM7335) {
225 else if (stb_type == BRCM7400) {
228 munmap(memory, DMA_BLOCKSIZE + 0x1000);