vt: redefine world of cursor macros
authorJiri Slaby <jslaby@suse.cz>
Mon, 15 Jun 2020 07:48:57 +0000 (09:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:08:33 +0000 (17:08 +0200)
The cursor code used to use magic constants, ANDs, ORs, and some macros.
Redefine all this to make some sense.

In particular:
* Drop CUR_DEFAULT, which is CUR_UNDERLINE. CUR_DEFAULT was used only
  for cur_default variable initialization, so use CUR_UNDERLINE there to
  make obvious what's the default.
* Drop CUR_HWMASK. Instead, define CUR_SIZE() which explains it more.
  And use it all over the places.
* Define few more masks and bits which will be used in next patches
  instead of magic constants.
* Define CUR_MAKE to build up cursor value.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-fbdev@vger.kernel.org
Link: https://lore.kernel.org/r/20200615074910.19267-25-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c
drivers/video/fbdev/core/bitblit.c
drivers/video/fbdev/core/fbcon_ccw.c
drivers/video/fbdev/core/fbcon_cw.c
drivers/video/fbdev/core/fbcon_ud.c
include/linux/console_struct.h

index f7d5a3c3845f746960059c75f286d064fb769d97..af1ef717f416bb05dbd546ac2abc9a9791b893e5 100644 (file)
@@ -163,7 +163,7 @@ module_param(default_utf8, int, S_IRUGO | S_IWUSR);
 int global_cursor_default = -1;
 module_param(global_cursor_default, int, S_IRUGO | S_IWUSR);
 
-static int cur_default = CUR_DEFAULT;
+static int cur_default = CUR_UNDERLINE;
 module_param(cur_default, int, S_IRUGO | S_IWUSR);
 
 /*
index c750470a31ec9e30bc36cf0ff549a21e53714b18..3b002b365a5aa4852df4f2da36a802bac04e8f7c 100644 (file)
@@ -325,7 +325,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                ops->p->cursor_shape = vc->vc_cursor_type;
                cursor.set |= FB_CUR_SETSHAPE;
 
-               switch (ops->p->cursor_shape & CUR_HWMASK) {
+               switch (CUR_SIZE(ops->p->cursor_shape)) {
                case CUR_NONE:
                        cur_height = 0;
                        break;
index 9d06446a1a3bfb2a902f5043e58e1096273daacc..5b67bcebe34c28047196c23759553340c00b6860 100644 (file)
@@ -325,7 +325,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                ops->p->cursor_shape = vc->vc_cursor_type;
                cursor.set |= FB_CUR_SETSHAPE;
 
-               switch (ops->p->cursor_shape & CUR_HWMASK) {
+               switch (CUR_SIZE(ops->p->cursor_shape)) {
                case CUR_NONE:
                        cur_height = 0;
                        break;
index 4b5f76bb01e50eeed51ba4fb7d6ca8f46bbc383b..f1aab3ae3bc91109aa05b599658572cd41dc62c5 100644 (file)
@@ -308,7 +308,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                ops->p->cursor_shape = vc->vc_cursor_type;
                cursor.set |= FB_CUR_SETSHAPE;
 
-               switch (ops->p->cursor_shape & CUR_HWMASK) {
+               switch (CUR_SIZE(ops->p->cursor_shape)) {
                case CUR_NONE:
                        cur_height = 0;
                        break;
index 7e0ae3549dc709422957f9ece3999d58035ed845..81ed6f6bed67938d1e0463cb0616532f288ae87b 100644 (file)
@@ -348,7 +348,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
                ops->p->cursor_shape = vc->vc_cursor_type;
                cursor.set |= FB_CUR_SETSHAPE;
 
-               switch (ops->p->cursor_shape & CUR_HWMASK) {
+               switch (CUR_SIZE(ops->p->cursor_shape)) {
                case CUR_NONE:
                        cur_height = 0;
                        break;
index 40ed52f67bc5e270e85e6b8a2cafb903fafb33ab..153734816b49cfdc534d8138e576f174a78d0218 100644 (file)
@@ -173,17 +173,23 @@ struct vc {
 extern struct vc vc_cons [MAX_NR_CONSOLES];
 extern void vc_SAK(struct work_struct *work);
 
-#define CUR_DEF                0
-#define CUR_NONE       1
-#define CUR_UNDERLINE  2
-#define CUR_LOWER_THIRD        3
-#define CUR_LOWER_HALF 4
-#define CUR_TWO_THIRDS 5
-#define CUR_BLOCK      6
-#define CUR_HWMASK     0x0f
-#define CUR_SWMASK     0xfff0
-
-#define CUR_DEFAULT CUR_UNDERLINE
+#define CUR_MAKE(size, change, set)    ((size) | ((change) << 8) |     \
+               ((set) << 16))
+#define CUR_SIZE(c)             ((c) & 0x00000f)
+# define CUR_DEF                              0
+# define CUR_NONE                             1
+# define CUR_UNDERLINE                        2
+# define CUR_LOWER_THIRD                      3
+# define CUR_LOWER_HALF                               4
+# define CUR_TWO_THIRDS                               5
+# define CUR_BLOCK                            6
+#define CUR_SW                         0x000010
+#define CUR_ALWAYS_BG                  0x000020
+#define CUR_INVERT_FG_BG               0x000040
+#define CUR_FG                         0x000700
+#define CUR_BG                         0x007000
+#define CUR_CHANGE(c)           ((c) & 0x00ff00)
+#define CUR_SET(c)             (((c) & 0xff0000) >> 8)
 
 bool con_is_visible(const struct vc_data *vc);