Skip to content

Commit b68d5cb

Browse files
committed
vclog: Also try /dev/vc-mem for DMA copy
Signed-off-by: Phil Elwell <[email protected]>
1 parent b2cc141 commit b68d5cb

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

vclog/vclog.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ enum
7272
};
7373

7474
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
75+
#define ARRAY_SIZE(_a) (sizeof(_a)/sizeof(_a[0]))
76+
7577
#define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy)
7678

7779
#ifdef DEBUG
@@ -354,25 +356,28 @@ static bool find_logs(uint32_t *logs_start, uint32_t *logs_size)
354356

355357
static bool prepare_vc_mapping(uint32_t vc_start, uint32_t vc_size)
356358
{
357-
const char *fb_filename = "/dev/fb0";
359+
const char *dma_filenames[] = { "/dev/vc-mem", "/dev/fb0" };
358360
const char *mem_filename = "/dev/mem";
361+
struct fb_dmacopy ioparam;
359362
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);
361368

362-
if ((fd = open(fb_filename, O_RDWR | O_SYNC)) >= 0)
369+
for (i = 0; i < (int)ARRAY_SIZE(dma_filenames); i++)
363370
{
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)
371372
{
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);
374380
}
375-
close(fd);
376381
}
377382

378383
if ((fd = open(mem_filename, O_RDONLY)) >= 0)

0 commit comments

Comments
 (0)