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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
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
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
9 #include "common.h"
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
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
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
13 if (argc != 2) {
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
14 fprintf(stderr, "usage: fbt /dev/fbX\n");
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
15 exit(EXIT_FAILURE);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
16 }
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
17
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
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
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
45 printf("-------------\n");
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
46 fflush(stdout);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
47
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
48 jpg_buf_t jpg_buf = build_jpg_from_fb(fd, siv.xres, siv.yres);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
49
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
50 close(fd);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
51
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
52 printf("jpg %ld\n", jpg_buf.size);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
53
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
54 FILE *f = fopen("test.jpg", "wb");
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
55 if (!f) {
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
56 fprintf(stderr, "fopen failed\n");
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
57 exit(EXIT_FAILURE);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
58 }
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
59
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
60 fwrite(jpg_buf.ptr, 1, jpg_buf.size, f);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
61
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
62 fclose(f);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
63
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
64 free(jpg_buf.ptr);
e8957085fe8a working
Peter Meerwald <pmeerw@pmeerw.net>
parents: 2
diff changeset
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 }

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