2 * fbcon_decor.c - Functions for handling communication with the kernel
4 * Copyright (C) 2004-2007 Michal Januszewski <spock@gentoo.org>
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License v2. See the file COPYING in the main directory of this archive for
15 #include <sys/types.h>
20 #include <sys/ioctl.h>
25 #include "fbcon_decor.h"
27 #ifdef CONFIG_FBCON_DECOR
28 int fd_fbcondecor
= -1;
30 int fbcon_decor_open(bool create
)
33 c
= open(FBCON_DECOR_DEV
, O_RDWR
);
35 if (c
== -1 && create
) {
36 if (!dev_create(FBCON_DECOR_DEV
, PATH_SYS
"/class/misc/fbcondecor/dev"))
37 c
= open(FBCON_DECOR_DEV
, O_RDWR
);
41 c
= open(PATH_DEV
"/fbsplash", O_RDWR
);
42 if (c
== -1 && create
) {
43 if (!dev_create(PATH_DEV
"/fbsplash", PATH_SYS
"/class/misc/fbsplash/dev"))
44 c
= open(PATH_DEV
"/fbsplash", O_RDWR
);
51 int fbcon_decor_setstate(unsigned char origin
, int vc
, unsigned int state
)
53 struct fbcon_decor_iowrapper wrapper
= {
59 if (ioctl(fd_fbcondecor
, FBIOCONDECOR_SETSTATE
, &wrapper
)) {
60 iprint(MSG_ERROR
, "FBIOCONDECOR_SETSTATE failed, error code %d.\n", errno
);
66 int fbcon_decor_getstate(unsigned char origin
, int vc
)
70 struct fbcon_decor_iowrapper wrapper
= {
72 .origin
= FBCON_DECOR_IO_ORIG_USER
,
76 ioctl(fd_fbcondecor
, FBIOCONDECOR_GETSTATE
, &wrapper
);
80 int fbcon_decor_setpic(unsigned char origin
, int vc
, stheme_t
*theme
)
82 struct fbcon_decor_iowrapper wrapper
= {
85 .data
= &theme
->verbose_img
,
88 if (!(theme
->modes
& FBSPL_MODE_VERBOSE
))
91 invalidate_all(theme
);
92 render_objs(theme
, (u8
*)theme
->verbose_img
.data
, FBSPL_MODE_VERBOSE
, true);
94 if (ioctl(fd_fbcondecor
, FBIOCONDECOR_SETPIC
, &wrapper
)) {
95 iprint(MSG_ERROR
, "FBIOCONDECOR_SETPIC failed, error code %d.\n", errno
);
96 iprint(MSG_ERROR
, "Hint: are you calling 'setpic' for the current virtual console?\n");
102 int fbcon_decor_setcfg(unsigned char origin
, int vc
, stheme_t
*theme
)
104 struct vc_decor vc_cfg
;
105 struct fbcon_decor_iowrapper wrapper
= {
111 int err
= cfg_check_sanity(theme
, 'v');
115 vc_cfg
.tx
= theme
->tx
;
116 vc_cfg
.ty
= theme
->ty
;
117 vc_cfg
.twidth
= theme
->tw
;
118 vc_cfg
.theight
= theme
->th
;
119 vc_cfg
.bg_color
= theme
->bg_color
;
120 vc_cfg
.theme
= config
.theme
;
122 if (ioctl(fd_fbcondecor
, FBIOCONDECOR_SETCFG
, &wrapper
)) {
123 iprint(MSG_ERROR
, "FBIOCONDECOR_SETCFG failed, error code %d.\n", errno
);
129 int fbcon_decor_getcfg(int vc
)
132 struct vc_decor vc_cfg
;
133 struct fbcon_decor_iowrapper wrapper
= {
135 .origin
= FBCON_DECOR_IO_ORIG_USER
,
139 vc_cfg
.theme
= malloc(FBCON_DECOR_THEME_LEN
);
143 if (ioctl(fd_fbcondecor
, FBIOCONDECOR_GETCFG
, &wrapper
)) {
144 iprint(MSG_ERROR
, "FBIOCONDECOR_GETCFG failed, error code %d.\n", errno
);
149 if (vc_cfg
.theme
[0] == 0) {
150 strcpy(vc_cfg
.theme
, "<none>");
153 printf("Fbcon decorations config on console %d:\n", vc
);
154 printf("tx: %d\n", vc_cfg
.tx
);
155 printf("ty: %d\n", vc_cfg
.ty
);
156 printf("twidth: %d\n", vc_cfg
.twidth
);
157 printf("theight: %d\n", vc_cfg
.theight
);
158 printf("bg_color: %d\n", vc_cfg
.bg_color
);
159 printf("theme: %s\n", vc_cfg
.theme
);
166 #endif /* CONFIG_FBCON_DECOR */