patch-2.3.99-pre3 linux/drivers/video/macmodes.c
Next file: linux/drivers/video/modedb.c
Previous file: linux/drivers/video/cgthreefb.c
Back to the patch index
Back to the overall index
- Lines: 150
- Date:
Thu Mar 23 10:07:42 2000
- Orig file:
v2.3.99-pre2/linux/drivers/video/macmodes.c
- Orig date:
Wed Aug 18 10:10:06 1999
diff -u --recursive --new-file v2.3.99-pre2/linux/drivers/video/macmodes.c linux/drivers/video/macmodes.c
@@ -3,15 +3,22 @@
*
* Copyright (C) 1998 Geert Uytterhoeven
*
+ * 2000 - Removal of OpenFirmware dependencies by:
+ * - Ani Joshi
+ * - Brad Douglas <brad@neruo.com>
+ *
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
*/
-#include <linux/tty.h>
+#include <linux/errno.h>
#include <linux/fb.h>
#include <linux/string.h>
+#include <asm/vc_ioctl.h>
+
+#include <video/fbcon.h>
#include <video/macmodes.h>
@@ -181,6 +188,107 @@
{ -1, VMODE_640_480_60 }, /* catch-all, must be last */
};
+struct fb_info *console_fb_info = NULL;
+struct vc_mode display_info;
+static u16 palette_red[16];
+static u16 palette_green[16];
+static u16 palette_blue[16];
+static struct fb_cmap palette_cmap = {
+ 0, 16, palette_red, palette_green, palette_blue, NULL
+};
+
+
+int console_getmode(struct vc_mode *);
+int console_setmode(struct vc_mode *, int);
+int console_setcmap(int, unsigned char *, unsigned char *, unsigned char *);
+int console_powermode(int);
+int mac_var_to_vmode(const struct fb_var_screeninfo *, int *, int *);
+
+
+int console_getmode(struct vc_mode *mode)
+{
+ *mode = display_info;
+ return 0;
+}
+
+
+int console_setmode(struct vc_mode *mode, int doit)
+{
+ struct fb_var_screeninfo var;
+ int cmode, err;
+
+ if (!console_fb_info)
+ return -EOPNOTSUPP;
+
+ switch(mode->depth) {
+ case 0:
+ case 8:
+ cmode = CMODE_8;
+ break;
+ case 16:
+ cmode = CMODE_16;
+ break;
+ case 24:
+ case 32:
+ cmode = CMODE_32;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if ((err = mac_vmode_to_var(mode->mode, cmode, &var)))
+ return err;
+
+ var.activate = FB_ACTIVATE_TEST;
+ err = console_fb_info->fbops->fb_set_var(&var, fg_console,
+ console_fb_info);
+ if (err || !doit)
+ return err;
+ else {
+ int unit;
+
+ var.activate = FB_ACTIVATE_NOW;
+ for (unit = 0; unit < MAX_NR_CONSOLES; unit++)
+ if (fb_display[unit].conp &&
+ (GET_FB_IDX(console_fb_info->node) == con2fb_map[unit]))
+ console_fb_info->fbops->fb_set_var(&var, unit,
+ console_fb_info);
+ }
+
+ return 0;
+}
+
+
+int console_setcmap(int n_entries, unsigned char *red, unsigned char *green,
+ unsigned char *blue)
+{
+ int i, j, n = 0, err;
+
+ if (!console_fb_info)
+ return -EOPNOTSUPP;
+
+ for (i = 0; i < n_entries; i += n) {
+ n = n_entries - i;
+ if (n > 16)
+ n = 16;
+ palette_cmap.start = 1;
+ palette_cmap.len = n;
+
+ for (j = 0; j < n; j++) {
+ palette_cmap.red[j] = (red[i+j] << 8) | red[i+j];
+ palette_cmap.green[j] = (green[i+j] << 8) | green[i+j];
+ palette_cmap.blue[j] = (blue[i+j] << 8) | blue[i+j];
+ }
+ err = console_fb_info->fbops->fb_set_cmap(&palette_cmap, 1,
+ fg_console,
+ console_fb_info);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
/*
* Convert a MacOS vmode/cmode pair to a frame buffer video mode structure
@@ -252,6 +360,17 @@
var->sync = mode->sync;
var->vmode = mode->vmode;
return 0;
+}
+
+
+int console_powermode(int mode)
+{
+ if (mode == VC_POWERMODE_INQUIRY)
+ return 0;
+ if (mode < VESA_NO_BLANKING || mode > VESA_POWERDOWN)
+ return -EINVAL;
+ /* Not Supported */
+ return -ENXIO;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)