Chroma plane: 0x6d21a000, 16 (8+8) bits per pixel, V1U1V2U2V3U3V4U4... format (1920*1080*2 == 4147200 bytes)
Luma plane: 0x6c400000, 8 bits per pixel, Y1Y2Y3Y4.. format (1920*1080 == 2073700 bytes)
Those regions are writable (i.e it's possible to draw arbitrarily on the screen in full-res mode).
Sadly, this mixed packed/planar framebuffer format is an uncommon one. Does X11 server implementation exists that will allow such an oddity ( without heavy patching etc.) ?
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/mman.h>
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
int main(int argc, char **argv) {
int fd;
off_t target;
if (argc != 4) {
fprintf(stderr, "\nUsage:\t%s address byteval count\n\n", argv[0]);
exit(1); }
target=strtoul(argv[1], 0, 0);
int writeval=strtoul(argv[2], 0, 0);
int bcount=strtoul(argv[3], 0, 0);
int map_size=bcount/4096; map_size*=4096;
if (map_size < bcount) map_size+=4096;
if (target % 4096 || bcount < 1) {
fprintf(stderr, "Address / size not valid\n");
exit(1); }
if ((fd=open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
void *map_base=mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target);
if (map_base == (void *) -1) FATAL;
printf("Memory mapped at address %p; size=%d\n", map_base, map_size);
memset(map_base, writeval, bcount);
if(munmap(map_base, map_size) == -1) FATAL;
close(fd);
return 0;
}