From patchwork Wed Dec 8 16:42:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dzianis Kahanovich X-Patchwork-Id: 391012 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 oB8GhIvL017237 for ; Wed, 8 Dec 2010 16:43:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423Ab0LHQnS (ORCPT ); Wed, 8 Dec 2010 11:43:18 -0500 Received: from mail.bspu.unibel.by ([195.50.2.21]:40615 "EHLO mail.bspu.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750993Ab0LHQnR (ORCPT ); Wed, 8 Dec 2010 11:43:17 -0500 Received: from [10.200.200.1] ([10.200.200.1]) by mail.bspu.local (8.14.4/8.14.4) with ESMTP id oB8GgeLJ006837; Wed, 8 Dec 2010 18:42:45 +0200 Message-ID: <4CFFB587.8070103@bspu.unibel.by> Date: Wed, 08 Dec 2010 18:42:47 +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: Florian Tobias Schandinat CC: Paul Mundt , Joseph Chan , linux-fbdev@vger.kernel.org Subject: [PATCH v2] (new way) I2C/DDC defaults & I2C/DDC detection for VIA framebuffer. References: <4CED3DD5.5080405@bspu.unibel.by> <20101130061357.GE17114@linux-sh.org> <4CF8DA25.4020204@bspu.unibel.by> <4CF9879A.3090409@gmx.de> In-Reply-To: <4CF9879A.3090409@gmx.de> 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 08 Dec 2010 16:43:19 +0000 (UTC) diff -pruN a/viafbdev.c c/viafbdev.c --- a/drivers/video/via/viafbdev.c 2010-12-07 18:35:22.000000000 +0200 +++ c/drivers/video/via/viafbdev.c 2010-12-08 18:24:18.000000000 +0200 @@ -1485,6 +1485,125 @@ static int parse_mode(const char *str, u return 0; } +/* stage=0: count devices to set dual and/or SAMM; + stage=1: add devices, detected only via i2c legacy; + set LCD/DVI/CRT if viafb_active_dev unset */ +static void viafb_detect_dev(int stage, struct viafb_dev *vdev) +{ + u8 *edid; + struct fb_var_screeninfo var; + int i, t, ndev = 0, nlcd = 0; + struct i2c_adapter *adapter; + struct lvds_setting_information *inf; + + /* FIXME: viaparinfo1->chip_info looks equal to viaparinfo */ + i = !viafb_active_dev && stage; + if (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name) { + ndev++; + if (i) + viafb_DVI_ON = STATE_ON; + } + if (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { + ndev++; + nlcd = 1; + if (i) + viafb_LCD_ON = STATE_ON; + } + if (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { + ndev++; + nlcd = 2; + if (i) + viafb_LCD2_ON = STATE_ON; + } + /* enabling CRT in textmode is at least no bad */ + if (viafb_CRT_ON) { + ndev++; + viafb_crt_enable(); + } + for (i = 0; i < VIAFB_NUM_PORTS; i++) { + t = vdev->port_cfg[i].type; + /* detect only i2c ports, undetected in other places */ + if ((viaparinfo && viaparinfo->chip_info && ( + (viaparinfo->chip_info->tmds_chip_info.tmds_chip_name && + viaparinfo->chip_info->tmds_chip_info.i2c_port == t) || + (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name && + viaparinfo->chip_info->lvds_chip_info.i2c_port == t) || + (viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name && + viaparinfo->chip_info->lvds_chip_info2.i2c_port == t) + )) || (viaparinfo1 && viaparinfo1->chip_info && ( + (viaparinfo1->chip_info->tmds_chip_info.tmds_chip_name && + viaparinfo1->chip_info->tmds_chip_info.i2c_port == t) || + (viaparinfo1->chip_info->lvds_chip_info.lvds_chip_name && + viaparinfo1->chip_info->lvds_chip_info.i2c_port == t) || + (viaparinfo1->chip_info->lvds_chip_info2.lvds_chip_name && + viaparinfo1->chip_info->lvds_chip_info2.i2c_port == t) + )) || !(adapter = viafb_find_i2c_adapter(i)) || + !(edid = fb_ddc_read(adapter))) + continue; + memset(&var, 0, sizeof(var)); + if (fb_parse_edid(edid, &var)) + goto free_edid; + printk(KERN_INFO "viafb: %48s\n", adapter->name); + inf = NULL; + if (!stage) { + } else if (!nlcd) { + fb_edid_to_monspecs(edid, &viafbinfo->monspecs); + if (viafbinfo->monspecs.input & FB_DISP_DDI) + inf = viaparinfo->lvds_setting_info; + } else if (nlcd > 1) { + printk(KERN_ERR "viafb: too many LCD\n"); + } else if (viafb_dual_fb) { + fb_edid_to_monspecs(edid, &viafbinfo1->monspecs); + if (viafbinfo1->monspecs.input & FB_DISP_DDI) + inf = viaparinfo1->lvds_setting_info; + } else { + fb_edid_to_monspecs(edid, &viafbinfo->monspecs); + if (viafbinfo->monspecs.input & FB_DISP_DDI) + inf = viaparinfo->lvds_setting_info2; + } + if (inf) { + if (!viafb_active_dev) { + if (nlcd) + viafb_LCD2_ON = STATE_ON; + else + viafb_LCD_ON = STATE_ON; + } + nlcd++; + if (var.xres) + inf->lcd_panel_hres = var.xres; + if (var.yres) + inf->lcd_panel_vres = var.yres; + } + ndev++; +free_edid: + kfree(edid); + } + if (!viafb_active_dev) { + /* SAMM on Chrome9 LCD+CRT is wrong here + then keep CRT OFF & dual detection together */ +#if 1 + if (ndev > 1 && viafb_CRT_ON) { + viafb_CRT_ON = STATE_OFF; + viafb_crt_disable(); + ndev--; + } + /* SAMM may be detected on stage 1, + but troubles coming together */ + if (ndev > 1 && !stage) + viafb_SAMM_ON = viafb_dual_fb = STATE_ON; +#endif + if (viafb_DVI_ON) + viafb_primary_dev = DVI_Device; + else if (viafb_LCD_ON) + viafb_primary_dev = LCD_Device; + else if (viafb_CRT_ON) + viafb_primary_dev = CRT_Device; + viafb_DeviceStatus = viafb_primary_dev; + if (stage) + viafb_set_iga_path(); + } +} + int __devinit via_fb_pci_probe(struct viafb_dev *vdev) { @@ -1526,6 +1645,10 @@ int __devinit via_fb_pci_probe(struct vi parse_dvi_port(); viafb_init_chip_info(vdev->chip_type); + /* detect dual_fb & SAMM_ON, but let's keep it to options */ +#if 0 + viafb_detect_dev(0, vdev); +#endif /* * The framebuffer will have been successfully mapped by * the core (or we'd not be here), but we still need to @@ -1675,6 +1798,8 @@ int __devinit via_fb_pci_probe(struct vi viafb_init_proc(&viaparinfo->shared->proc_entry); #endif viafb_init_dac(IGA2); + /* update from legacy i2c DDC info */ + viafb_detect_dev(1, vdev); return 0; out_fb_unreg: diff -pruN a/via_i2c.c c/via_i2c.c --- a/drivers/video/via/via_i2c.c 2010-12-08 15:12:05.000000000 +0200 +++ c/drivers/video/via/via_i2c.c 2010-11-29 18:04:24.000000000 +0200 @@ -167,7 +167,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);