From rubini@unipv.it Wed May 18 21:24:27 EDT 1994
Article: 9211 of comp.os.linux.development
Path: bigblue.oit.unc.edu!concert!inxs.concert.net!taco.cc.ncsu.edu!gatech!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!ghost.dsi.unimi.it!mirage.unipv.it!rubini
From: rubini@unipv.it (Alessandro Rubini)
Newsgroups: comp.os.linux.development
Subject: The visual bell: patch and RFD
Date: 17 May 94 10:30:33 GMT
Organization: Pavia University
Lines: 88
Message-ID: <rubini.769170633@ipvvis.unipv.it>
NNTP-Posting-Host: ipvvis.unipv.it
Keywords: visual-bell, patch, console

(Sorry if this is a repost... the previous seems dead)

Hello linuxers,
   my own box doesn't have a loudspeaker, but now that I have access to a
full featured PC I had to turn off the bell from the linux console. It
has been very easy, and I include the patch below as I think the visual bell
is a good thing for all of us who go to bed late (most of us :-) and like
filename completion in the shell.

However, at times the bell is a good thing, so I wonder how to make it
dynamically switchable on and off. I thought of two ways, but I can't choose
between the two:

- modifying the setterm command is probably the best way, because it is the
        normal way to access console configuration, and it is already a
        linux-specific command.  However, it makes use of the escape
        sequences, which in turn are quite well standardized, and I won't like
        adding a non-standard escape sequence to the linux console.

- on the other way, addin an ioctl() of type TIOCLINUX is not useful to
        the final user without providing a command-line access, and it is not
        nice to mess setterm with ioctl()'s.

So I ask some suggestions to all of you who are interested in the matter.

Please reply by email to save bandwidth, and I'll post a
summary (and the patch) if there is enough interest.

--------------

I took the patch against the 1.0 kernel, but it applies well (offset -1line)
to both the 1.0.9 and the 1.1.12. Midway kernels should be allright, too.

to apply:             cd /usr/src/linux/drivers/char; patch < __this_patch__

to re-enable the audible bell: "#define CONFIG_NO_VISUALBELL" at the beginning
        of console.c

---8<------8<------8<------8<------8<------8<------8<------8<---
*** console.c.audible   Fri May 13 18:07:21 1994
--- console.c   Sat May 14 18:18:16 1994
***************
*** 992,997 ****
--- 992,1014 ----
        }
  }
  
+ #ifndef CONFIG_NO_VISUALBELL
+ static inline void con_visualbell(const int currcons)
+ {
+     unsigned char *p; int i;
+     unsigned char *screenstart = (unsigned char *)(origin-
+                 (currcons==fg_console 
+                   ? ((__real_origin - __origin) << 1) 
+                   : 0));
+     unsigned char *screenend=screenstart+video_num_columns*video_num_lines*2;
+ 
+     for (i=0;i<2;i++)
+       for (p=screenstart+1;p<screenend+1;p+=2)
+                 *p = (*p & 0x88) | ((*p << 4) & 0x70) | ((*p >> 4) & 0x07);
+ 
+ }
+ #endif
+ 
  void con_write(struct tty_struct * tty)
  {
        int c;
***************
*** 1034,1040 ****
--- 1051,1061 ----
                 */
                switch (c) {
                        case 7:
+ #ifdef CONFIG_NO_VISUALBELL
                                kd_mksound(0x637, HZ/8);
+ #else
+                               con_visualbell(currcons);
+ #endif
                                continue;
                        case 8:
                                bs(currcons);
---8<------8<------8<------8<------8<------8<------8<------8<---


--
    __ o	alessandro rubini - rubini@ipvvis.unipv.it
   _`\<,
__( )/( )____		I am italian, but I didn't vote for them...


