view fbt.c @ 4:5ff6a67e1421

missing
author Peter Meerwald <pmeerw@pmeerw.net>
date Mon, 09 May 2011 23:32:51 +0200
parents e8957085fe8a
children 66c77f9ba9b9
line wrap: on
line source

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>

#include "linux/fb.h"

#include "common.h"

int main(int argc, char *argv[]) {

  if (argc != 2) {
    fprintf(stderr, "usage: fbt /dev/fbX\n");
    exit(EXIT_FAILURE);
  }

  int fd = open(argv[1], O_RDWR);
  if (fd < 0) {
    perror("");
    exit(EXIT_FAILURE);
  }
  
  struct fb_fix_screeninfo sif;
  if (ioctl(fd, FBIOGET_VSCREENINFO, &sif) < 0) {
    perror("");
    exit(EXIT_FAILURE);
  }

  printf("id %s\n", sif.id);
  printf("type %d, aux %d\n", sif.type, sif.type_aux);
  printf("visual %d\n", sif.visual);
  printf("accel %d\n", sif.accel);
  printf("line length %d\n", sif.line_length);

  struct fb_var_screeninfo siv;
  if (ioctl(fd, FBIOGET_VSCREENINFO, &siv) < 0) {
    perror("");
    exit(EXIT_FAILURE);
  }

  printf("res x %d y %d\n", siv.xres, siv.yres);
  printf("bpp %d\n", siv.bits_per_pixel);

  printf("-------------\n");
  fflush(stdout);

  jpg_buf_t jpg_buf = build_jpg_from_fb(fd, siv.xres, siv.yres);

  close(fd);

  printf("jpg %ld\n", jpg_buf.size);

  FILE *f = fopen("test.jpg", "wb");
  if (!f) {
	fprintf(stderr, "fopen failed\n");
    exit(EXIT_FAILURE);
  }

  fwrite(jpg_buf.ptr, 1, jpg_buf.size, f);

  fclose(f);

  free(jpg_buf.ptr);

  exit(EXIT_SUCCESS);
}

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.