From patchwork Mon May 9 21:14:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 770942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p49LgPbp009206 for ; Mon, 9 May 2011 21:42:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754426Ab1EIVmY (ORCPT ); Mon, 9 May 2011 17:42:24 -0400 Received: from queueout02-winn.ispmail.ntl.com ([81.103.221.56]:57780 "EHLO queueout02-winn.ispmail.ntl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752937Ab1EIVmY (ORCPT ); Mon, 9 May 2011 17:42:24 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 09 May 2011 21:42:25 +0000 (UTC) X-Greylist: delayed 1660 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 May 2011 17:42:24 EDT Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110509211442.RGWJ14839.mtaout01-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com>; Mon, 9 May 2011 22:14:42 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110509211441.OEIY25656.aamtaout04-winn.ispmail.ntl.com@zog.reactivated.net>; Mon, 9 May 2011 22:14:41 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id AF70A9D401C; Mon, 9 May 2011 22:14:39 +0100 (BST) From: Daniel Drake To: FlorianSchandinat@gmx.de Cc: linux-fbdev@vger.kernel.org Cc: dilinger@queued.net Subject: [PATCH] viafb: Automatic OLPC XO-1.5 configuration Message-Id: <20110509211439.AF70A9D401C@zog.reactivated.net> Date: Mon, 9 May 2011 22:14:39 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=JvdXmxIgLJv2/GthKqHpGJEEHukvLcvELVXUanXFreg= c=1 sm=0 a=ii5F9npNXtwA:10 a=vJ1w_8FsMGIA:10 a=Op-mwl0xAAAA:8 a=p79jHFxem7nVWjTIeyoA:9 a=DV47Fp6ytKE6Ss67eikA:7 a=d4CUUju0HPYA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Detect presence of the OLPC laptop and configure default settings accordingly. This means the kernel can now boot on XO-1.5 without needing long, hardcoded boot options. Signed-off-by: Daniel Drake --- drivers/video/via/global.c | 2 +- drivers/video/via/viafbdev.c | 55 ++++++++++++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/video/via/global.c b/drivers/video/via/global.c index e10d824..b994e3b 100644 --- a/drivers/video/via/global.c +++ b/drivers/video/via/global.c @@ -29,7 +29,7 @@ int viafb_refresh = 60; int viafb_refresh1 = 60; int viafb_lcd_dsp_method = LCD_EXPANDSION; int viafb_lcd_mode = LCD_OPENLDI; -int viafb_CRT_ON = 1; +int viafb_CRT_ON = STATE_ON; int viafb_DVI_ON; int viafb_LCD_ON ; int viafb_LCD2_ON; diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 7b4390e..75b5fc7 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c @@ -24,6 +24,7 @@ #include #include #include +#include #define _MASTER_FILE #include "global.h" @@ -36,6 +37,8 @@ static char *viafb_mode; static char *viafb_mode1; static int viafb_bpp = 32; static int viafb_bpp1 = 32; +static int viafb_default_mode_xres = 640; +static int viafb_default_mode_yres = 480; static unsigned int viafb_second_xres = 640; static unsigned int viafb_second_yres = 480; @@ -1001,19 +1004,18 @@ static void retrieve_device_setting(struct viafb_ioctl_setting static int __init parse_active_dev(void) { - viafb_CRT_ON = STATE_OFF; viafb_DVI_ON = STATE_OFF; - viafb_LCD_ON = STATE_OFF; viafb_LCD2_ON = STATE_OFF; + + if (!viafb_active_dev) + return 0; + /* 1. Modify the active status of devices. */ /* 2. Keep the order of devices, so we can set corresponding IGA path to devices in SAMM case. */ /* Note: The previous of active_dev is primary device, and the following is secondary device. */ - if (!viafb_active_dev) { - viafb_CRT_ON = STATE_ON; - viafb_SAMM_ON = STATE_OFF; - } else if (!strcmp(viafb_active_dev, "CRT+DVI")) { + if (!strcmp(viafb_active_dev, "CRT+DVI")) { /* CRT+DVI */ viafb_CRT_ON = STATE_ON; viafb_DVI_ON = STATE_ON; @@ -1035,19 +1037,23 @@ static int __init parse_active_dev(void) viafb_primary_dev = LCD_Device; } else if (!strcmp(viafb_active_dev, "DVI+LCD")) { /* DVI+LCD */ + viafb_CRT_ON = STATE_OFF; viafb_DVI_ON = STATE_ON; viafb_LCD_ON = STATE_ON; viafb_primary_dev = DVI_Device; } else if (!strcmp(viafb_active_dev, "LCD+DVI")) { /* LCD+DVI */ + viafb_CRT_ON = STATE_OFF; viafb_DVI_ON = STATE_ON; viafb_LCD_ON = STATE_ON; viafb_primary_dev = LCD_Device; } else if (!strcmp(viafb_active_dev, "LCD+LCD2")) { + viafb_CRT_ON = STATE_OFF; viafb_LCD_ON = STATE_ON; viafb_LCD2_ON = STATE_ON; viafb_primary_dev = LCD_Device; } else if (!strcmp(viafb_active_dev, "LCD2+LCD")) { + viafb_CRT_ON = STATE_OFF; viafb_LCD_ON = STATE_ON; viafb_LCD2_ON = STATE_ON; viafb_primary_dev = LCD2_Device; @@ -1057,10 +1063,12 @@ static int __init parse_active_dev(void) viafb_SAMM_ON = STATE_OFF; } else if (!strcmp(viafb_active_dev, "DVI")) { /* DVI only */ + viafb_CRT_ON = STATE_OFF; viafb_DVI_ON = STATE_ON; viafb_SAMM_ON = STATE_OFF; } else if (!strcmp(viafb_active_dev, "LCD")) { /* LCD only */ + viafb_CRT_ON = STATE_OFF; viafb_LCD_ON = STATE_ON; viafb_SAMM_ON = STATE_OFF; } else @@ -1665,8 +1673,8 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres) char *ptr; if (!str) { - *xres = 640; - *yres = 480; + *xres = viafb_default_mode_xres; + *yres = viafb_default_mode_yres; return 0; } @@ -1922,11 +1930,16 @@ void __devexit via_fb_pci_remove(struct pci_dev *pdev) } #ifndef MODULE -static int __init viafb_setup(char *options) +static int __init viafb_setup(void) { char *this_opt; + char *options; + DEBUG_MSG(KERN_INFO "viafb_setup!\n"); + if (fb_get_options("viafb", &options)) + return -ENODEV; + if (!options || !*options) return 0; @@ -1994,17 +2007,33 @@ static int __init viafb_setup(char *options) } #endif +static void __init viafb_platform_setup(void) +{ + if (machine_is_olpc()) { + /* Apply XO-1.5-specific configuration. */ + viafb_lcd_panel_id = 23; + viafb_bpp = 24; + viafb_default_mode_xres = 1200; + viafb_default_mode_yres = 900; + + /* LCD only */ + viafb_CRT_ON = STATE_OFF; + viafb_LCD_ON = STATE_ON; + viafb_SAMM_ON = STATE_OFF; + } +} + /* * These are called out of via-core for now. */ int __init viafb_init(void) { u32 dummy_x, dummy_y; + + viafb_platform_setup(); + #ifndef MODULE - char *option = NULL; - if (fb_get_options("viafb", &option)) - return -ENODEV; - viafb_setup(option); + viafb_setup(); #endif if (parse_mode(viafb_mode, &dummy_x, &dummy_y) || !viafb_get_mode(dummy_x, dummy_y)