aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fbi.c12
-rw-r--r--fbtools.c33
-rw-r--r--gfx.h1
-rw-r--r--vt.c33
-rw-r--r--vt.h4
5 files changed, 39 insertions, 44 deletions
diff --git a/fbi.c b/fbi.c
index dd73858..54aec30 100644
--- a/fbi.c
+++ b/fbi.c
@@ -574,22 +574,22 @@ tty_raw(void)
{
struct termios tattr;
- fcntl(0,F_GETFL,&saved_fl);
+ fcntl(STDIN_FILENO, F_GETFL, &saved_fl);
tcgetattr (0, &saved_attributes);
- fcntl(0,F_SETFL,O_NONBLOCK);
+ fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
memcpy(&tattr,&saved_attributes,sizeof(struct termios));
tattr.c_lflag &= ~(ICANON|ECHO);
tattr.c_cc[VMIN] = 1;
tattr.c_cc[VTIME] = 0;
- tcsetattr (0, TCSAFLUSH, &tattr);
+ tcsetattr(STDIN_FILENO, TCSAFLUSH, &tattr);
}
static void
tty_restore(void)
{
- fcntl(0,F_SETFL,saved_fl);
- tcsetattr (0, TCSANOW, &saved_attributes);
+ fcntl(STDIN_FILENO, F_SETFL, saved_fl);
+ tcsetattr(STDIN_FILENO, TCSANOW, &saved_attributes);
}
/* testing: find key codes */
@@ -1512,7 +1512,7 @@ int main(int argc, char *argv[])
cfg_get_str(O_VIDEO_MODE),
GET_VT());
exit_signals_init();
- console_switch_init(gfx->tty_fd, console_switch_redraw);
+ console_switch_init(console_switch_redraw);
shadow_init(gfx);
signal(SIGTSTP,SIG_IGN);
diff --git a/fbtools.c b/fbtools.c
index 06fb31f..c0920cb 100644
--- a/fbtools.c
+++ b/fbtools.c
@@ -40,7 +40,7 @@ static struct fb_var_screeninfo fb_var;
static unsigned char *fb_mem;
static int fb_mem_offset = 0;
-static int fb,tty;
+static int fb;
static int kd_mode;
static struct vt_mode vt_omode;
@@ -212,24 +212,23 @@ static void fb_restore_display(void)
static void fb_cleanup_display(void)
{
/* restore console */
- if (-1 == ioctl(tty,KDSETMODE, kd_mode))
+ if (-1 == ioctl(STDIN_FILENO, KDSETMODE, kd_mode))
perror("ioctl KDSETMODE");
- if (-1 == ioctl(fb,FBIOPUT_VSCREENINFO,&fb_ovar))
+ if (-1 == ioctl(fb, FBIOPUT_VSCREENINFO, &fb_ovar))
perror("ioctl FBIOPUT_VSCREENINFO");
- if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix))
+ if (-1 == ioctl(fb, FBIOGET_FSCREENINFO, &fb_fix))
perror("ioctl FBIOGET_FSCREENINFO");
if (fb_ovar.bits_per_pixel == 8 ||
fb_fix.visual == FB_VISUAL_DIRECTCOLOR) {
- if (-1 == ioctl(fb,FBIOPUTCMAP,&ocmap))
+ if (-1 == ioctl(fb, FBIOPUTCMAP, &ocmap))
perror("ioctl FBIOPUTCMAP");
}
close(fb);
- if (-1 == ioctl(tty,VT_SETMODE, &vt_omode))
+ if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_omode))
perror("ioctl VT_SETMODE");
console_restore_vt();
- tcsetattr(tty, TCSANOW, &term);
- close(tty);
+ tcsetattr(STDIN_FILENO, TCSANOW, &term);
}
/* -------------------------------------------------------------------- */
@@ -241,11 +240,10 @@ gfxstate* fb_init(char *device, char *mode, int vt)
unsigned long page_mask;
gfxstate *gfx;
- tty = 0;
if (vt != 0)
console_set_vt(vt);
- if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_GETSTATE, &vts)) {
fprintf(stderr,"ioctl VT_GETSTATE: %s (not a linux console?)\n",
strerror(errno));
exit(1);
@@ -293,19 +291,19 @@ gfxstate* fb_init(char *device, char *mode, int vt)
exit(1);
}
}
- if (-1 == ioctl(tty,KDGETMODE, &kd_mode)) {
+ if (-1 == ioctl(STDIN_FILENO, KDGETMODE, &kd_mode)) {
perror("ioctl KDGETMODE");
exit(1);
}
- if (-1 == ioctl(tty,VT_GETMODE, &vt_omode)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_GETMODE, &vt_omode)) {
perror("ioctl VT_GETMODE");
exit(1);
}
- tcgetattr(tty, &term);
-
+ tcgetattr(STDIN_FILENO, &term);
+
/* switch mode */
fb_setmode(mode);
-
+
/* checks & initialisation */
if (-1 == ioctl(fb,FBIOGET_FSCREENINFO,&fb_fix)) {
perror("ioctl FBIOGET_FSCREENINFO");
@@ -332,11 +330,11 @@ gfxstate* fb_init(char *device, char *mode, int vt)
goto err;
}
}
- if (-1 == ioctl(tty,KDSETMODE, KD_GRAPHICS)) {
+ if (-1 == ioctl(STDIN_FILENO, KDSETMODE, KD_GRAPHICS)) {
perror("ioctl KDSETMODE");
goto err;
}
- console_activate_current(tty);
+ console_activate_current();
/* cls */
fb_memset(fb_mem+fb_mem_offset, 0, fb_fix.line_length * fb_var.yres);
@@ -384,7 +382,6 @@ gfxstate* fb_init(char *device, char *mode, int vt)
gfx->cleanup_display = fb_cleanup_display;
gfx->fb_fd = fb;
- gfx->tty_fd = tty;
return gfx;
err:
diff --git a/gfx.h b/gfx.h
index 2ee61a8..a64b1e8 100644
--- a/gfx.h
+++ b/gfx.h
@@ -18,6 +18,5 @@ struct gfxstate {
void (*cleanup_display)(void);
/* FIXME: legacy */
- int tty_fd;
int fb_fd;
};
diff --git a/vt.c b/vt.c
index 746bdc7..c03f4f0 100644
--- a/vt.c
+++ b/vt.c
@@ -23,7 +23,7 @@ int console_visible = 1;
extern int debug;
-static int switch_last, tty;
+static int switch_last;
static int console_switch_state = CONSOLE_ACTIVE;
static struct vt_mode vt_mode;
static int orig_vt_no = 0;
@@ -47,7 +47,7 @@ static void console_switch_signal(int signal)
static void console_switch_release(void)
{
- ioctl(tty, VT_RELDISP, 1);
+ ioctl(STDIN_FILENO, VT_RELDISP, 1);
console_switch_state = CONSOLE_INACTIVE;
if (debug)
write(2,"vt: release\n",12);
@@ -55,17 +55,16 @@ static void console_switch_release(void)
static void console_switch_acquire(void)
{
- ioctl(tty, VT_RELDISP, VT_ACKACQ);
+ ioctl(STDIN_FILENO, VT_RELDISP, VT_ACKACQ);
console_switch_state = CONSOLE_ACTIVE;
if (debug)
write(2,"vt: acquire\n",12);
}
-int console_switch_init(int tty_fd, void (*redraw)(void))
+int console_switch_init(void (*redraw)(void))
{
struct sigaction act,old;
- tty = tty_fd;
console_redraw = redraw;
memset(&act,0,sizeof(act));
@@ -74,7 +73,7 @@ int console_switch_init(int tty_fd, void (*redraw)(void))
sigaction(SIGUSR1,&act,&old);
sigaction(SIGUSR2,&act,&old);
- if (-1 == ioctl(tty, VT_GETMODE, &vt_mode)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_GETMODE, &vt_mode)) {
perror("ioctl VT_GETMODE");
exit(1);
}
@@ -83,7 +82,7 @@ int console_switch_init(int tty_fd, void (*redraw)(void))
vt_mode.relsig = SIGUSR1;
vt_mode.acqsig = SIGUSR2;
- if (-1 == ioctl(tty, VT_SETMODE, &vt_mode)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_SETMODE, &vt_mode)) {
perror("ioctl VT_SETMODE");
exit(1);
}
@@ -120,7 +119,7 @@ void console_set_vt(int vtno)
char vtname[12];
if (vtno < 0) {
- if (-1 == ioctl(tty, VT_OPENQRY, &vtno) || vtno == -1) {
+ if (-1 == ioctl(STDIN_FILENO, VT_OPENQRY, &vtno) || vtno == -1) {
perror("ioctl VT_OPENQRY");
exit(1);
}
@@ -152,16 +151,16 @@ void console_set_vt(int vtno)
dup(0);
dup(0);
- if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
+ if (-1 == ioctl(STDIN_FILENO,VT_GETSTATE, &vts)) {
perror("ioctl VT_GETSTATE");
exit(1);
}
orig_vt_no = vts.v_active;
- if (-1 == ioctl(tty,VT_ACTIVATE, vtno)) {
+ if (-1 == ioctl(STDIN_FILENO,VT_ACTIVATE, vtno)) {
perror("ioctl VT_ACTIVATE");
exit(1);
}
- if (-1 == ioctl(tty,VT_WAITACTIVE, vtno)) {
+ if (-1 == ioctl(STDIN_FILENO,VT_WAITACTIVE, vtno)) {
perror("ioctl VT_WAITACTIVE");
exit(1);
}
@@ -172,26 +171,26 @@ void console_restore_vt(void)
if (!orig_vt_no)
return;
- if (ioctl(tty, VT_ACTIVATE, orig_vt_no) < 0)
+ if (ioctl(STDIN_FILENO, VT_ACTIVATE, orig_vt_no) < 0)
perror("ioctl VT_ACTIVATE");
- if (ioctl(tty, VT_WAITACTIVE, orig_vt_no) < 0)
+ if (ioctl(STDIN_FILENO, VT_WAITACTIVE, orig_vt_no) < 0)
perror("ioctl VT_WAITACTIVE");
}
/* Hmm. radeonfb needs this. matroxfb doesn't. */
-int console_activate_current(int tty)
+int console_activate_current(void)
{
struct vt_stat vts;
- if (-1 == ioctl(tty,VT_GETSTATE, &vts)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_GETSTATE, &vts)) {
perror("ioctl VT_GETSTATE");
return -1;
}
- if (-1 == ioctl(tty,VT_ACTIVATE, vts.v_active)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_ACTIVATE, vts.v_active)) {
perror("ioctl VT_ACTIVATE");
return -1;
}
- if (-1 == ioctl(tty,VT_WAITACTIVE, vts.v_active)) {
+ if (-1 == ioctl(STDIN_FILENO, VT_WAITACTIVE, vts.v_active)) {
perror("ioctl VT_WAITACTIVE");
return -1;
}
diff --git a/vt.h b/vt.h
index 931df4d..ae4b8f9 100644
--- a/vt.h
+++ b/vt.h
@@ -1,8 +1,8 @@
extern int console_visible;
-int console_switch_init(int fd, void (*redraw)(void));
+int console_switch_init(void (*redraw)(void));
int check_console_switch(void);
void console_set_vt(int vtno);
void console_restore_vt(void);
-int console_activate_current(int tty);
+int console_activate_current(void);