From patchwork Wed Nov 24 16:31:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzianis Kahanovich X-Patchwork-Id: 353471 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 oAOGS13f021711 for ; Wed, 24 Nov 2010 16:28:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754158Ab0KXQ02 (ORCPT ); Wed, 24 Nov 2010 11:26:28 -0500 Received: from mail.bspu.unibel.by ([195.50.2.21]:46399 "EHLO mail.bspu.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755026Ab0KXQ00 (ORCPT ); Wed, 24 Nov 2010 11:26:26 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 24 Nov 2010 16:28:01 +0000 (UTC) X-Greylist: delayed 659 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Nov 2010 11:26:26 EST Received: from [10.200.200.1] ([10.200.200.1]) by mail.bspu.local (8.14.4/8.14.4) with ESMTP id oAOGQHIS006004; Wed, 24 Nov 2010 18:26:22 +0200 Message-ID: <4CED3DD5.5080405@bspu.unibel.by> Date: Wed, 24 Nov 2010 18:31:17 +0200 From: Dzianis Kahanovich Reply-To: mahatma@eu.by User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0b7pre) Gecko/20101123 Firefox/4.0b7pre SeaMonkey/2.1b1 MIME-Version: 1.0 To: Joseph Chan , Florian Tobias Schandinat CC: linux-fbdev@vger.kernel.org Subject: [PATCH v4+] viafb: I2C/DDC LCD detection for VIA framebuffer X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.bspu.local Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org diff -pruN a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c --- a/drivers/video/via/via-core.c 2010-11-24 00:12:22.000000000 +0200 +++ b/drivers/video/via/via-core.c 2010-11-24 17:04:00.749999967 +0200 @@ -2,6 +2,7 @@ * Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved. * Copyright 2009 Jonathan Corbet + * Copyright 2010 Dzianis Kahanovich */ /* @@ -16,6 +17,8 @@ #include #include +extern char *viafb_active_dev; + /* * The default port config. */ @@ -575,6 +578,66 @@ static void via_teardown_subdevs(void) } } +static void via_i2c_detect(int stage) +{ + u8 *edid; + struct fb_var_screeninfo var; + int i, n = 0; + struct i2c_adapter *adapter; + struct lvds_setting_information *inf; + + for (i = 0; i < VIAFB_NUM_PORTS; i++) { + adapter = viafb_find_i2c_adapter(i); + if (!adapter || !adapter->algo_data || + !(edid = fb_ddc_read(adapter))) + continue; + if (fb_parse_edid(edid, &var)) + goto free_edid; + if (!stage) { + if (n && !viafb_active_dev) + viafb_dual_fb = STATE_ON; + inf = NULL; + } else if (!n || !viafb_LCD_ON) { + fb_edid_to_monspecs(edid, &viafbinfo->monspecs); + inf = viaparinfo->lvds_setting_info; + if (!viafb_active_dev) { + viafb_DVI_ON = + viaparinfo->tmds_setting_info->max_hres ? + STATE_ON : STATE_OFF; + if (viafbinfo->monspecs.input & FB_DISP_DDI) { + viafb_LCD_ON = STATE_ON; + viafb_DeviceStatus = LCD_Device; + if (!n) + viafb_primary_dev = LCD_Device; + } + } + } else if (viafb_dual_fb) { + fb_edid_to_monspecs(edid, &viafbinfo1->monspecs); + inf = viaparinfo1->lvds_setting_info; + if (!viafb_active_dev && + (viafbinfo1->monspecs.input & FB_DISP_DDI)) + viafb_LCD2_ON = STATE_ON; + } else { + fb_edid_to_monspecs(edid, &viafbinfo->monspecs); + inf = viaparinfo->lvds_setting_info2; + if (!viafb_active_dev && + (viafbinfo->monspecs.input & FB_DISP_DDI)) + viafb_LCD2_ON = STATE_ON; + } + if (inf) { + inf->lcd_panel_hres = var.xres; + inf->lcd_panel_vres = var.yres; + } + n++; +free_edid: + kfree(edid); + if (n > 1) + break; + } + if (stage && !viafb_active_dev) + viafb_set_iga_path(); +} + static int __devinit via_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) @@ -601,12 +665,16 @@ static int __devinit via_pci_probe(struc */ viafb_int_init(); via_setup_subdevs(&global_dev); + /* dual? */ + via_i2c_detect(0); /* * Set up the framebuffer device */ ret = via_fb_pci_probe(&global_dev); if (ret) goto out_subdevs; + /* LCD size & present */ + via_i2c_detect(1); return 0; out_subdevs: diff -pruN a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c --- a/drivers/video/via/viafbdev.c 2010-11-21 11:34:11.000000000 +0200 +++ b/drivers/video/via/viafbdev.c 2010-11-24 00:14:48.070000002 +0200 @@ -43,7 +43,7 @@ static int viafb_second_size; static int viafb_accel = 1; /* Added for specifying active devices.*/ -char *viafb_active_dev; +char *viafb_active_dev = NULL; /*Added for specify lcd output port*/ char *viafb_lcd_port = ""; diff -pruN a/drivers/video/via/via_i2c.c b/drivers/video/via/via_i2c.c --- a/drivers/video/via/via_i2c.c 2010-11-21 11:34:11.000000000 +0200 +++ b/drivers/video/via/via_i2c.c 2010-11-24 00:14:48.070000002 +0200 @@ -188,7 +188,7 @@ struct i2c_adapter *viafb_find_i2c_adapt { struct via_i2c_stuff *stuff = &via_i2c_par[which]; - return &stuff->adapter; + return stuff->is_active ? &stuff->adapter : NULL; } EXPORT_SYMBOL_GPL(viafb_find_i2c_adapter);