2 * ofbset - fbset for OMAP displays
4 * Copyright (c) 2010, GraÅžvydas Ignotas
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the organization nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/types.h>
34 #include <sys/ioctl.h>
40 #define RET_CHECK(r, msg) \
46 static void usage(void)
48 fprintf(stderr, "usage:\n"
49 " -h, --help : this help\n"
50 " -s, --show : show current settings\n"
51 " -fb <device> : framebuffer device (default /dev/fb0)\n"
52 " -mem <bytes> : memory to reserve for this FB\n"
53 " -pos <x y> : overlay position on display\n"
54 " -size <w h> : overlay size\n"
55 " -en <{1,0}> : enable/disable the overlay\n");
60 int main(int argc, char *argv[])
62 struct omapfb_plane_info pi;
63 struct omapfb_mem_info mi;
64 const char *fbname = "/dev/fb0";
65 const char *newmem = NULL;
66 const char *newx = NULL, *newy = NULL;
67 const char *neww = NULL, *newh = NULL;
68 const char *enable = NULL;
69 int old_enable, show = 0, change = 0;
75 for (i = 1; i < argc; i++) {
76 if (!strcmp(argv[i], "-s"))
78 else if (!strcmp(argv[i], "-fb") && i + 1 < argc)
80 else if (!strcmp(argv[i], "-mem") && i + 1 < argc) {
84 else if (!strcmp(argv[i], "-pos") && i + 2 < argc) {
89 else if (!strcmp(argv[i], "-size") && i + 2 < argc) {
94 else if (!strcmp(argv[i], "-en") && i + 1 < argc) {
102 fd = open(fbname, O_RDWR);
104 fprintf(stderr, "open %s", fbname);
109 ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
110 RET_CHECK(ret, "ioctl QUERY_PLANE");
112 ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);
113 RET_CHECK(ret, "ioctl QUERY_MEM");
116 printf("pos: %d %d\n", pi.pos_x, pi.pos_y);
117 printf("size: %d %d\n", pi.out_width, pi.out_height);
118 printf("mem: %d\n", mi.size);
119 printf("enabled: %s\n", pi.enabled ? "yes" : "no");
124 /* must disable when changing stuff */
125 old_enable = pi.enabled;
128 ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
129 RET_CHECK(ret, "ioctl SETUP_PLANE");
133 mi.size = strtoul(newmem, NULL, 0);
134 ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);
135 RET_CHECK(ret, "ioctl SETUP_MEM");
139 pi.pos_x = atoi(newx);
140 pi.pos_y = atoi(newy);
143 pi.out_width = atoi(neww);
144 pi.out_height = atoi(newh);
147 pi.enabled = atoi(enable);
149 pi.enabled = old_enable;
151 ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
153 perror("ioctl SETUP_PLANE");