掌機 - Miyoo A30 - C/C++ - Volume



main.c

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <time.h>
  
int main(int argc, char* argv[])
{
    int fd = -1;
    uint8_t *mem = NULL;
    volatile uint32_t *p = NULL;
     
    fd = open("/dev/mem", O_RDWR);
    mem = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1c22000);

    uint32_t l = 140;
    uint32_t r = 140;

    p = (uint32_t *)(&mem[0xc00 + 0x258]);
    printf("Vol %d,%d\n", (*p & 0xff), ((*p >> 8) & 0xff));
    *p = (l << 8) | r;
 
    munmap(mem, 4096);
    close(fd);
    return 0;
}