'make clean' should tell buildrom that the package is now unconfigured.
[buildrom.git] / buildrom-devel / packages / kernel / dcon-detect.patch
blob2a85231dad2d884b1e230200d91a35b36398b5eb
1 [PATCH] Detect if the OLPC DCON was detected by the BIOS
3 From: Jordan Crouse <jordan.crouse@amd.com>
5 If the OLPC DCON is present, then we'll adjust the mode database
6 accordingly (since there is really only 1 mode available anyway).
8 Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
9 ---
11 arch/i386/Kconfig | 7 +++++++
12 arch/i386/kernel/Makefile | 1 +
13 arch/i386/kernel/olpc.c | 38 ++++++++++++++++++++++++++++++++++++++
14 drivers/video/geode/gxfb_core.c | 39 +++++++++++++++++++++++++++++++++++----
15 4 files changed, 81 insertions(+), 4 deletions(-)
17 Index: linux-2.6.18-rc4-olpc1/arch/i386/Kconfig
18 ===================================================================
19 --- linux-2.6.18-rc4-olpc1.orig/arch/i386/Kconfig 2006-08-08 11:13:24.000000000 -0600
20 +++ linux-2.6.18-rc4-olpc1/arch/i386/Kconfig 2006-10-03 10:44:14.000000000 -0600
21 @@ -1113,6 +1113,13 @@
22 def_bool y
23 depends on AGP_AMD64
25 +config OLPC
26 + bool "OLPC Support"
27 + default n
28 + help
29 + Add support for detecting the unique features of the OLPC
30 + Childrens Machine
32 source "drivers/pcmcia/Kconfig"
34 source "drivers/pci/hotplug/Kconfig"
35 Index: linux-2.6.18-rc4-olpc1/arch/i386/kernel/Makefile
36 ===================================================================
37 --- linux-2.6.18-rc4-olpc1.orig/arch/i386/kernel/Makefile 2006-08-08 11:13:24.000000000 -0600
38 +++ linux-2.6.18-rc4-olpc1/arch/i386/kernel/Makefile 2006-10-03 10:44:14.000000000 -0600
39 @@ -44,6 +44,7 @@
40 EXTRA_AFLAGS := -traditional
42 obj-$(CONFIG_SCx200) += scx200.o
43 +obj-$(CONFIG_OLPC) += olpc.o
45 # vsyscall.o contains the vsyscall DSO images as __initdata.
46 # We must build both images before we can assemble it.
47 Index: linux-2.6.18-rc4-olpc1/arch/i386/kernel/olpc.c
48 ===================================================================
49 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
50 +++ linux-2.6.18-rc4-olpc1/arch/i386/kernel/olpc.c 2006-10-03 10:44:14.000000000 -0600
51 @@ -0,0 +1,38 @@
52 +/* Support for the OLPC Childrens Machine
53 + * Copyright (C) 2006, Advanced Micro Devices, Inc.
54 + *
55 + * This program is free software; you can redistribute it and/or modify
56 + * it under the terms of the GNU General Public License as published by
57 + * the Free Software Foundation; either version 2 of the License, or
58 + * (at your option) any later version.
59 + */
61 +#include <linux/config.h>
62 +#include <linux/kernel.h>
63 +#include <linux/init.h>
64 +#include <linux/mc146818rtc.h>
66 +int olpc_dcon_present;
68 +/* REV_A CMOS map:
69 + * bit 440; DCON present bit
70 + */
72 +#define OLPC_CMOS_DCON_OFFSET (440 / 8)
73 +#define OLPC_CMOS_DCON_MASK 0x01
75 +static int __init olpc_init(void) {
77 + unsigned char val;
79 + /* Read the DCON present bit and set the flag accordingly */
81 + val = CMOS_READ(OLPC_CMOS_DCON_OFFSET);
82 + olpc_dcon_present = (val & OLPC_CMOS_DCON_MASK);
84 + return 0;
87 +subsys_initcall(olpc_init);
88 +EXPORT_SYMBOL(olpc_dcon_present);
90 Index: linux-2.6.18-rc4-olpc1/drivers/video/geode/gxfb_core.c
91 ===================================================================
92 --- linux-2.6.18-rc4-olpc1.orig/drivers/video/geode/gxfb_core.c 2006-08-08 11:13:24.000000000 -0600
93 +++ linux-2.6.18-rc4-olpc1/drivers/video/geode/gxfb_core.c 2006-10-03 10:46:58.000000000 -0600
94 @@ -38,6 +38,7 @@
95 static char *mode_option;
97 /* Modes relevant to the GX (taken from modedb.c) */
99 static const struct fb_videomode gx_modedb[] __initdata = {
100 /* 640x480-60 VESA */
101 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
102 @@ -103,11 +104,33 @@
103 { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3,
104 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
105 FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
106 - { "OLPC-1", 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
107 + /* 1200x900-75 - CRT timings for the OLPC mode */
108 + { NULL, 75, 1200, 900, 8049, 104, 240, 29, 54, 136, 3,
109 + FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
110 + FB_VMODE_NONINTERLACED, 0 }
113 +#ifdef CONFIG_OLPC
115 +/* If the DCON is not detected - then we need to choose a default mode
116 + * in OLPC mode
117 + */
119 +static const struct fb_videomode gx_nodcon_default = {
120 + NULL, 60, 1024, 768, 15384, 160, 24, 29, 3, 136, 6,
121 + 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA
124 +static const struct fb_videomode gx_dcon_modedb[] __initdata = {
125 + /* The only mode the DCON has is 1200x900 */
126 + { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
127 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
128 FB_VMODE_NONINTERLACED, 0 }
131 +extern int olpc_dcon_present;
132 +#endif
134 static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
136 if (var->xres > 1600 || var->yres > 1200)
137 @@ -313,6 +336,10 @@
138 int ret;
139 unsigned long val;
141 + struct fb_videomode *modedb_default = NULL;
142 + struct fb_videomode *modedb_ptr;
143 + int modedb_size;
145 info = gxfb_init_fbinfo(&pdev->dev);
146 if (!info)
147 return -ENOMEM;
148 @@ -336,15 +363,34 @@
149 else
150 par->enable_crt = 1;
152 + /* If the OLPC DCON is present, then we use a special
153 + * mode database (don't say we support modes that we don't).
154 + */
156 + modedb_ptr = (struct fb_videomode *) gx_modedb;
157 + modedb_size = ARRAY_SIZE(gx_modedb);
159 +#ifdef CONFIG_OLPC
160 + if (olpc_dcon_present) {
161 + printk(KERN_INFO "gxfb: DCON detected.\n");
162 + modedb_ptr = (struct fb_videomode *) gx_dcon_modedb;
163 + modedb_size = ARRAY_SIZE(gx_dcon_modedb);
165 + else {
166 + /* Specify the 1024x768@60 default for non DCON users */
167 + modedb_default = &gx_nodcon_default;
169 +#endif
171 ret = fb_find_mode(&info->var, info, mode_option,
172 - gx_modedb, ARRAY_SIZE(gx_modedb), NULL, 16);
173 + modedb_ptr, modedb_size, modedb_default, 16);
175 if (ret == 0 || ret == 4) {
176 dev_err(&pdev->dev, "could not find valid video mode\n");
177 ret = -EINVAL;
178 goto err;
182 /* Clear the frame buffer of garbage. */
183 memset_io(info->screen_base, 0, info->fix.smem_len);
185 Index: linux-2.6.18-rc4-olpc1/drivers/video/modedb.c
186 ===================================================================
187 --- linux-2.6.18-rc4-olpc1.orig/drivers/video/modedb.c 2006-08-08 11:13:24.000000000 -0600
188 +++ linux-2.6.18-rc4-olpc1/drivers/video/modedb.c 2006-10-03 10:44:14.000000000 -0600
189 @@ -506,7 +506,7 @@
190 dbsize = ARRAY_SIZE(modedb);
192 if (!default_mode)
193 - default_mode = &modedb[DEFAULT_MODEDB_INDEX];
194 + default_mode = &db[DEFAULT_MODEDB_INDEX];
195 if (!default_bpp)
196 default_bpp = 8;