|
72 | 72 | }; |
73 | 73 |
|
74 | 74 | #define MAX(x, y) (((x) > (y)) ? (x) : (y)) |
| 75 | +#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof(_a[0])) |
| 76 | + |
75 | 77 | #define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy) |
76 | 78 |
|
77 | 79 | #ifdef DEBUG |
@@ -354,25 +356,28 @@ static bool find_logs(uint32_t *logs_start, uint32_t *logs_size) |
354 | 356 |
|
355 | 357 | static bool prepare_vc_mapping(uint32_t vc_start, uint32_t vc_size) |
356 | 358 | { |
357 | | - const char *fb_filename = "/dev/fb0"; |
| 359 | + const char *dma_filenames[] = { "/dev/vc-mem", "/dev/fb0" }; |
358 | 360 | const char *mem_filename = "/dev/mem"; |
| 361 | + struct fb_dmacopy ioparam; |
359 | 362 | uint32_t id; |
360 | | - int fd; |
| 363 | + int err, fd, i; |
| 364 | + |
| 365 | + ioparam.dst = &id; |
| 366 | + ioparam.src = vc_start; |
| 367 | + ioparam.length = sizeof(id); |
361 | 368 |
|
362 | | - if ((fd = open(fb_filename, O_RDWR | O_SYNC)) >= 0) |
| 369 | + for (i = 0; i < (int)ARRAY_SIZE(dma_filenames); i++) |
363 | 370 | { |
364 | | - struct fb_dmacopy ioparam; |
365 | | - int err; |
366 | | - ioparam.dst = &id; |
367 | | - ioparam.src = vc_start; |
368 | | - ioparam.length = sizeof(id); |
369 | | - err = ioctl(fd, FBIODMACOPY, &ioparam); |
370 | | - if (err == 0 && id == LOG_ID) |
| 371 | + if ((fd = open(dma_filenames[i], O_RDWR | O_SYNC)) >= 0) |
371 | 372 | { |
372 | | - dma_fd = fd; |
373 | | - goto success; |
| 373 | + err = ioctl(fd, FBIODMACOPY, &ioparam); |
| 374 | + if (err == 0 && id == LOG_ID) |
| 375 | + { |
| 376 | + dma_fd = fd; |
| 377 | + goto success; |
| 378 | + } |
| 379 | + close(fd); |
374 | 380 | } |
375 | | - close(fd); |
376 | 381 | } |
377 | 382 |
|
378 | 383 | if ((fd = open(mem_filename, O_RDONLY)) >= 0) |
|
0 commit comments