Mercurial > hg > minimon
annotate fbt.c @ 4:5ff6a67e1421
missing
author | Peter Meerwald <pmeerw@pmeerw.net> |
---|---|
date | Mon, 09 May 2011 23:32:51 +0200 |
parents | e8957085fe8a |
children | 66c77f9ba9b9 |
rev | line source |
---|---|
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
1 #include <stdlib.h> |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
2 #include <stdio.h> |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
3 #include <fcntl.h> |
3 | 4 #include <unistd.h> |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
5 #include <sys/ioctl.h> |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
6 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
7 #include "linux/fb.h" |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
8 |
3 | 9 #include "common.h" |
10 | |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
11 int main(int argc, char *argv[]) { |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
12 |
3 | 13 if (argc != 2) { |
14 fprintf(stderr, "usage: fbt /dev/fbX\n"); | |
15 exit(EXIT_FAILURE); | |
16 } | |
17 | |
18 int fd = open(argv[1], O_RDWR); | |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
19 if (fd < 0) { |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
20 perror(""); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
21 exit(EXIT_FAILURE); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
22 } |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
23 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
24 struct fb_fix_screeninfo sif; |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
25 if (ioctl(fd, FBIOGET_VSCREENINFO, &sif) < 0) { |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
26 perror(""); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
27 exit(EXIT_FAILURE); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
28 } |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
29 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
30 printf("id %s\n", sif.id); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
31 printf("type %d, aux %d\n", sif.type, sif.type_aux); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
32 printf("visual %d\n", sif.visual); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
33 printf("accel %d\n", sif.accel); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
34 printf("line length %d\n", sif.line_length); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
35 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
36 struct fb_var_screeninfo siv; |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
37 if (ioctl(fd, FBIOGET_VSCREENINFO, &siv) < 0) { |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
38 perror(""); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
39 exit(EXIT_FAILURE); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
40 } |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
41 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
42 printf("res x %d y %d\n", siv.xres, siv.yres); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
43 printf("bpp %d\n", siv.bits_per_pixel); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
44 |
3 | 45 printf("-------------\n"); |
46 fflush(stdout); | |
47 | |
48 jpg_buf_t jpg_buf = build_jpg_from_fb(fd, siv.xres, siv.yres); | |
49 | |
50 close(fd); | |
51 | |
52 printf("jpg %ld\n", jpg_buf.size); | |
53 | |
54 FILE *f = fopen("test.jpg", "wb"); | |
55 if (!f) { | |
56 fprintf(stderr, "fopen failed\n"); | |
57 exit(EXIT_FAILURE); | |
58 } | |
59 | |
60 fwrite(jpg_buf.ptr, 1, jpg_buf.size, f); | |
61 | |
62 fclose(f); | |
63 | |
64 free(jpg_buf.ptr); | |
65 | |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
66 exit(EXIT_SUCCESS); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
67 } |