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..a4df66f 100644
16 -AiO Dreambox Screengrabber v0.83a
17 +AiO Screengrabber v0.83a
19 written 2006 - 2009 by Seddi
20 Contact: seddi@ihad.tv / http://www.ihad.tv
21 @@ -38,6 +38,7 @@ Feel free to use the code for your own projects. See LICENSE file for details.
23 #include <sys/types.h>
29 @@ -80,6 +81,8 @@ static const int yuv2rgbtable_bv[256] = {
32 static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yres);
33 +static bool getvideo2(unsigned char *video, unsigned int *xres, unsigned int *yres);
35 static bool getosd(unsigned char *osd, unsigned int *xres, unsigned int *yres);
37 static void smooth_resize(const unsigned char *source, unsigned char *dest,
38 @@ -101,10 +104,24 @@ static void combine(unsigned char *output,
39 const unsigned char *video, const unsigned char *osd,
40 unsigned int xres, unsigned int yres);
44 +enum {UNKNOWN,PALLAS,VULCAN,XILLEON,BRCM7401,BRCM7400,BRCM7405,BRCM7335,BRCM7325,BRCM7346,BRCM7425,BRCM7362,BRCM_ARM};
45 +char *stb_name[]={"unknown","Pallas","Vulcan","Xilleon","Brcm7401","Brcm7400","Brcm7405","Brcm7335","Brcm7325","Brcm7346","Brcm7425\/7241","Brcm7362", "Brcm_ARM"};
47 enum {UNKNOWN,PALLAS,VULCAN,XILLEON,BRCM7401,BRCM7400,BRCM7405};
48 static const char *stb_name[]={"unknown","Pallas","Vulcan","Xilleon","Brcm7401","Brcm7400","Brcm7405"};
50 static int stb_type=UNKNOWN;
52 +char* upcase(char* mixedstr)
55 + for (j=0; j< strlen(mixedstr); ++j)
56 + mixedstr[j]=toupper(mixedstr[j]);
60 static const char *file_getline(const char *filename)
62 static char *line = NULL;
63 @@ -184,10 +201,9 @@ static int file_scanf_lines(const char *filename, const char *fmt, ...)
68 int main(int argc, char **argv) {
70 - printf("AiO Dreambox Screengrabber " PACKAGE_VERSION "\n\n");
71 + printf("AiO Screengrabber " PACKAGE_VERSION "\n\n");
73 unsigned int xres_v = 0,yres_v = 0,xres_o,yres_o,xres,yres,aspect,width;
74 int c,osd_only,video_only,use_osd_res,use_png,use_jpg,jpg_quality,no_aspect,use_letterbox;
75 @@ -205,11 +221,41 @@ int main(int argc, char **argv) {
76 char filename[256] = { "/tmp/screenshot.bmp" };
79 - const char *line = file_getline("/proc/fb");
80 + char *line = (char*)file_getline("/proc/fb");
84 if (strstr(line, "bcmfb")) {
86 + if((line=(char*)file_getline("/proc/stb/info/chipset")) == NULL)
88 + if (strstr(upcase(line),"7335"))
90 + else if (strstr(upcase(line),"7325"))
92 + else if (strstr(upcase(line),"7405"))
94 + else if (strstr(upcase(line),"7356"))
96 + else if (strstr(upcase(line),"7346"))
98 + else if (strstr(upcase(line),"7424"))
100 + else if (strstr(upcase(line),"7425"))
102 + else if (strstr(upcase(line),"7241"))
104 + else if (strstr(upcase(line),"7362"))
106 + else if (strstr(upcase(line),"7366"))
108 + else if (strstr(upcase(line),"7376"))
110 + else if (strstr(upcase(line),"7444"))
112 + else if (strstr(upcase(line),"7252"))
115 line = file_getline("/proc/stb/info/model");
118 @@ -221,6 +267,7 @@ int main(int argc, char **argv) {
119 !strcmp(line, "dm800se") ||
120 !strcmp(line, "dm7020hd"))
123 } else if (strstr(line, "xilleonfb")) {
125 } else if (strstr(line, "Pallas FB")) {
126 @@ -325,9 +372,18 @@ int main(int argc, char **argv) {
127 if (!video_only && !getosd(osd, &xres_o, &yres_o))
131 - if (!osd_only && !getvideo(video, &xres_v, &yres_v))
133 + if (stb_type == BRCM_ARM)
135 + if (!osd_only && !getvideo2(video, &xres_v, &yres_v))
140 + if (!osd_only && !getvideo(video, &xres_v, &yres_v))
147 if (stb_type == VULCAN || stb_type == PALLAS)
148 @@ -549,6 +605,22 @@ int main(int argc, char **argv) {
151 // grabing the video picture
152 +static bool getvideo2(unsigned char *video, unsigned int *xres, unsigned int *yres)
154 + int fd_video = open("/dev/dvb/adapter0/video0", O_RDONLY);
155 + if (fd_video < 0) {
156 + perror("/dev/dvb/adapter0/video0");
160 + ssize_t r = read(fd_video, video, 1920 * 1080 * 3);
169 static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yres)
171 @@ -563,16 +635,34 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
177 + if (stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405 || stb_type == BRCM7335 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425 || stb_type == BRCM7362)
179 if (stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405)
182 // grab brcm7401 pic from decoder memory
184 + off_t offset_addr = 0x10600000;
190 + case BRCM7325: offset_addr = 0x10100000; break;
192 + unsigned char *memory = mmap(0, 100, PROT_READ, MAP_SHARED, mem_fd, offset_addr);
193 + if (memory == MAP_FAILED) {
198 unsigned char *memory = mmap(0, 100, PROT_READ, MAP_SHARED, mem_fd, 0x10100000);
199 if (memory == MAP_FAILED) {
205 unsigned char data[100];
207 unsigned int adr,adr2,ofs,ofs2,offset/*,vert_start,vert_end*/;
208 @@ -582,12 +672,30 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
209 memcpy(data,memory,100);
210 //vert_start=data[0x1B]<<8|data[0x1A];
211 //vert_end=data[0x19]<<8|data[0x18];
213 + if(stb_type == BRCM7401 || stb_type == BRCM7400 || stb_type == BRCM7405 || stb_type == BRCM7335 || stb_type == BRCM7325) {
214 + stride=data[0x15]<<8|data[0x14];
215 + ofs=(data[0x28]<<8|data[0x27])>>4;
216 + ofs2=(data[0x2c]<<8|data[0x2b])>>4;
217 + adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
218 + adr2=(data[0x23]<<24|data[0x22]<<16|data[0x21]<<8|data[0x20])&0xFFFFFF00;
221 + stride=data[0x15]<<8|data[0x14];
222 + ofs=(data[0x3c]<<8|data[0x3b])>>4;
223 + ofs2=(data[0x40]<<8|data[0x3f])>>4;
224 + adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
225 + adr2=(data[0x37]<<24|data[0x36]<<16|data[0x35]<<8|data[0x34])&0xFFFFFF00;
229 stride=data[0x15]<<8|data[0x14];
230 ofs=(data[0x28]<<8|data[0x27])>>4;
231 ofs2=(data[0x2c]<<8|data[0x2b])>>4;
232 adr=(data[0x1f]<<24|data[0x1e]<<16|data[0x1d]<<8|data[0x1c])&0xFFFFFF00;
233 adr2=(data[0x23]<<24|data[0x22]<<16|data[0x21]<<8|data[0x20])&0xFFFFFF00;
239 @@ -609,7 +717,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
242 // grabbing luma & chroma plane from the decoder memory
244 + if (stb_type == BRCM7401 || stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425 || stb_type == BRCM7362 ) {
246 if (stb_type == BRCM7401 || stb_type == BRCM7405) {
248 // on dm800/dm500hd we have direct access to the decoder memory
249 memory = mmap(0, offset + stride*(ofs2+64), PROT_READ, MAP_SHARED, mem_fd, adr);
250 if (memory == MAP_FAILED) {
251 @@ -620,7 +732,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
252 usleep(50000); // we try to get a full picture, its not possible to get a sync from the decoder so we use a delay
253 // and hope we get a good timing. dont ask me why, but every DM800 i tested so far produced a good
254 // result with a 50ms delay
256 + } else if (stb_type == BRCM7400 || stb_type == BRCM7335) {
258 } else if (stb_type == BRCM7400) {
260 // on dm8000 we have to use dma, so dont change anything here until you really know what you are doing !
263 @@ -639,7 +755,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
266 volatile unsigned long *mem_dma;
268 + mem_dma = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, (stb_type==BRCM7400)?0x10c02000:0x10c01000);
270 mem_dma = mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0x10c02000);
272 if (mem_dma == MAP_FAILED) {
275 @@ -675,8 +795,11 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
276 unsigned int t = 0, t2 = 0, dat1 = 0;
277 unsigned int chr_luma_stride = 0x40;
281 + if (stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425)
283 if (stb_type == BRCM7405)
285 chr_luma_stride *= 2;
287 xsub=chr_luma_stride;
288 @@ -692,6 +815,7 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
289 for (ytmp = 0; ytmp < ofs; ytmp++)
291 memcpy(luma + dat1, memory + t, xsub); // luma
293 t += chr_luma_stride;
295 switch (ofs2-ytmp) // the two switch commands are much faster than one if statement
296 @@ -710,10 +834,17 @@ static bool getvideo(unsigned char *video, unsigned int *xres, unsigned int *yre
302 + if (stb_type == BRCM7401 || stb_type == BRCM7405 || stb_type == BRCM7325 || stb_type == BRCM7346 || stb_type == BRCM7425 || stb_type == BRCM7362) {
304 if (stb_type == BRCM7401 || stb_type == BRCM7405)
306 munmap(memory, offset + stride * (ofs2 + 64));
308 + } else if (stb_type == BRCM7400 || stb_type == BRCM7335) {
310 else if (stb_type == BRCM7400) {
313 munmap(memory, DMA_BLOCKSIZE + 0x1000);