Mercurial > mplayer.hg
comparison TOOLS/TVout/matroxset/matroxset.c @ 12940:b205f8ca892a
Moved to the TOOLS directory.
author | diego |
---|---|
date | Tue, 03 Aug 2004 00:45:55 +0000 |
parents | TVout/matroxset/matroxset.c@3b5f5d1c5041 |
children |
comparison
equal
deleted
inserted
replaced
12939:9b44f32dae3f | 12940:b205f8ca892a |
---|---|
1 #include <stdio.h> | |
2 #include <sys/types.h> | |
3 #include <unistd.h> | |
4 #include <sys/ioctl.h> | |
5 #include <errno.h> | |
6 #include <string.h> | |
7 #include <stdlib.h> | |
8 #include <fcntl.h> | |
9 #include "fb.h" | |
10 #include "matroxfb.h" | |
11 | |
12 static int help(void) { | |
13 fprintf(stderr, "usage: matroxset [-f fbdev] [-o output] [-m] [value]\n" | |
14 "\n" | |
15 "where -f fbdev is fbdev device (default /dev/fb1)\n" | |
16 " -o output is output number to investigate (0=primary, 1=secondary=default)\n" | |
17 " -m says that CRTC->output mapping should be changed/retrieved\n" | |
18 " -p print information about blanking\n" | |
19 " value if present, value is set, if missing, value is retrieved\n" | |
20 "\n" | |
21 "For output mode, 128 means monitor, 1 = PAL TV, 2 = NTSC TV\n"); | |
22 return 98; | |
23 } | |
24 | |
25 int main(int argc, char* argv[]) { | |
26 char* fb = "/dev/fb1"; | |
27 int fd; | |
28 struct matroxioc_output_mode mom; | |
29 struct fb_vblank vbl; | |
30 int rtn; | |
31 int output = MATROXFB_OUTPUT_SECONDARY; | |
32 int o_present = 0; | |
33 int m_present = 0; | |
34 int p_present = 0; | |
35 int act; | |
36 u_int32_t conns; | |
37 | |
38 while ((rtn = getopt(argc, argv, "o:f:mhp")) != -1) { | |
39 switch (rtn) { | |
40 case 'o': | |
41 output = strtoul(optarg, NULL, 0); | |
42 o_present = 1; | |
43 break; | |
44 case 'm': | |
45 m_present = 1; | |
46 break; | |
47 case 'f': | |
48 fb = optarg; | |
49 break; | |
50 case 'p': | |
51 p_present = 1; | |
52 break; | |
53 case 'h': | |
54 return help(); | |
55 default: | |
56 fprintf(stderr, "Bad commandline\n"); | |
57 return 99; | |
58 } | |
59 } | |
60 act = 0; | |
61 if (p_present) { | |
62 if (m_present || o_present) { | |
63 fprintf(stderr, "You cannot use -p together with -m or -o\n"); | |
64 return 95; | |
65 } | |
66 act = 4; | |
67 } else if (optind >= argc) { | |
68 if (m_present) { | |
69 if (o_present) { | |
70 fprintf(stderr, "You cannot use -m and -o together\n"); | |
71 return 96; | |
72 } | |
73 act = 2; | |
74 } else { | |
75 mom.output = output; | |
76 mom.mode = 0; | |
77 } | |
78 } else { | |
79 if (m_present) { | |
80 conns = strtoul(argv[optind], NULL, 0); | |
81 act = 3; | |
82 } else { | |
83 mom.output = output; | |
84 mom.mode = strtoul(argv[optind], NULL, 0); | |
85 act = 1; | |
86 } | |
87 } | |
88 fd = open(fb, O_RDWR); | |
89 if (fd == -1) { | |
90 fprintf(stderr, "Cannot open %s: %s\n", fb, strerror(errno)); | |
91 return 122; | |
92 } | |
93 switch (act) { | |
94 case 0: | |
95 rtn = ioctl(fd, MATROXFB_GET_OUTPUT_MODE, &mom); | |
96 if (rtn) | |
97 break; | |
98 printf("Output mode is %u\n", mom.mode); | |
99 break; | |
100 case 1: | |
101 rtn = ioctl(fd, MATROXFB_SET_OUTPUT_MODE, &mom); | |
102 break; | |
103 case 2: | |
104 rtn = ioctl(fd, MATROXFB_GET_OUTPUT_CONNECTION, &conns); | |
105 if (rtn) | |
106 break; | |
107 printf("This framebuffer is connected to outputs %08X\n", conns); | |
108 break; | |
109 case 3: | |
110 rtn = ioctl(fd, MATROXFB_SET_OUTPUT_CONNECTION, &conns); | |
111 break; | |
112 case 4: | |
113 #if 0 | |
114 { int i; for (i = 0; i < 1000000; i++) { | |
115 rtn = ioctl(fd, FBIOGET_VBLANK, &vbl); | |
116 if (rtn) | |
117 break; | |
118 }} | |
119 #else | |
120 rtn = ioctl(fd, FBIOGET_VBLANK, &vbl); | |
121 if (rtn) | |
122 break; | |
123 #endif | |
124 printf("VBlank flags: %08X\n", vbl.flags); | |
125 printf(" Symbolic: "); | |
126 { | |
127 static const struct { u_int32_t mask; const char* msg; } *ptr, vals[] = { | |
128 { FB_VBLANK_HAVE_VBLANK, "vblank" }, | |
129 { FB_VBLANK_HAVE_HBLANK, "hblank" }, | |
130 { FB_VBLANK_HAVE_COUNT, "field no." }, | |
131 { FB_VBLANK_HAVE_VCOUNT, "line no." }, | |
132 { FB_VBLANK_HAVE_HCOUNT, "column no." }, | |
133 { FB_VBLANK_VBLANKING, "vblanking" }, | |
134 { FB_VBLANK_HBLANKING, "hblanking" }, | |
135 { 0, NULL }}; | |
136 int ap = 0; | |
137 for (ptr = vals; ptr->msg; ptr++) { | |
138 if (vbl.flags & ptr->mask) { | |
139 if (ap) printf(", "); | |
140 printf(ptr->msg); | |
141 ap = 1; | |
142 } | |
143 } | |
144 if (!ap) | |
145 printf("none"); | |
146 printf("\n"); | |
147 } | |
148 printf("Field count: %12u\n", vbl.count); | |
149 printf("Vertical line: %12u\n", vbl.vcount); | |
150 printf("Horizontal column: %12u\n", vbl.hcount); | |
151 break; | |
152 default: | |
153 rtn = -1; errno = EINVAL; | |
154 break; | |
155 } | |
156 if (rtn) { | |
157 fprintf(stderr, "ioctl failed: %s\n", strerror(errno)); | |
158 } | |
159 close(fd); | |
160 return 0; | |
161 } | |
162 |