From patchwork Thu Mar 14 08:49:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10852529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AA541850 for ; Thu, 14 Mar 2019 09:06:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A0172A293 for ; Thu, 14 Mar 2019 09:06:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DC2A2A29E; Thu, 14 Mar 2019 09:06:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7DE52A297 for ; Thu, 14 Mar 2019 09:06:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:59426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4MJy-0000Iy-5O for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Mar 2019 05:06:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4MGL-0005mC-QW for qemu-devel@nongnu.org; Thu, 14 Mar 2019 05:02:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4M3Q-0003Al-3I for qemu-devel@nongnu.org; Thu, 14 Mar 2019 04:49:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40742) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4M3P-00039Z-Qn for qemu-devel@nongnu.org; Thu, 14 Mar 2019 04:49:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D865DC04D283; Thu, 14 Mar 2019 08:49:30 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-24.ams2.redhat.com [10.36.116.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CB666B8ED; Thu, 14 Mar 2019 08:49:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C84A016E0A; Thu, 14 Mar 2019 09:49:27 +0100 (CET) From: Gerd Hoffmann To: balaton@eik.bme.hu Date: Thu, 14 Mar 2019 09:49:24 +0100 Message-Id: <20190314084924.8854-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 14 Mar 2019 08:49:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ati-vga: i2c fix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , "open list:All patches CC here" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP gets radeonfb going for me, on top of your i2c patches. --- hw/display/ati_int.h | 1 + hw/display/ati_regs.h | 1 + hw/display/ati.c | 35 +++++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index 3f4a06f1e1ed..7289db206cd2 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -38,6 +38,7 @@ typedef struct ATIVGARegs { uint32_t crtc_ext_cntl; uint32_t dac_cntl; uint32_t gpio_vga_ddc; + uint32_t gpio_dvi_ddc; uint32_t gpio_monid; uint32_t crtc_h_total_disp; uint32_t crtc_h_sync_strt_wid; diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index 90384c886ecb..1ec3498b731c 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -38,6 +38,7 @@ #define CRTC_EXT_CNTL 0x0054 #define DAC_CNTL 0x0058 #define GPIO_VGA_DDC 0x0060 +#define GPIO_DVI_DDC 0x0064 #define GPIO_MONID 0x0068 #define I2C_CNTL_1 0x0094 #define PALETTE_INDEX 0x00b0 diff --git a/hw/display/ati.c b/hw/display/ati.c index e2efc6f2225e..ffced39aad9c 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -272,6 +272,9 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, unsigned int size) case GPIO_VGA_DDC: val = s->regs.gpio_vga_ddc; break; + case GPIO_DVI_DDC: + val = s->regs.gpio_dvi_ddc; + break; case GPIO_MONID: val = s->regs.gpio_monid; break; @@ -426,6 +429,22 @@ static inline void ati_reg_write_offs(uint32_t *reg, int offs, } } +static uint64_t ati_i2c(bitbang_i2c_interface *i2c, + uint64_t data) +{ + bool clk = !(data & BIT(17)); + bool out = !(data & BIT(16)); + bool in; + + bitbang_i2c_set(i2c, BITBANG_I2C_SCL, clk); + in = bitbang_i2c_set(i2c, BITBANG_I2C_SDA, out); + + data &= 0xf000f; + data |= clk ? BIT(9) : 0; + data |= in ? BIT(8) : 0; + return data; +} + static void ati_mm_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { @@ -512,15 +531,15 @@ static void ati_mm_write(void *opaque, hwaddr addr, if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) { break; } - s->regs.gpio_vga_ddc = data & 0xf000f; - if (data & BIT(17)) { - s->regs.gpio_monid |= !!(data & BIT(1)) << 9; - bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SCL, (data & BIT(1)) != 0); - } - if (data & BIT(16)) { - s->regs.gpio_monid |= bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SDA, - data & BIT(0)) << 8; +#if 0 + s->regs.gpio_vga_ddc = ati_i2c(s->bbi2c, data); +#endif + break; + case GPIO_DVI_DDC: + if (s->dev_id == PCI_DEVICE_ID_ATI_RAGE128_PF) { + break; } + s->regs.gpio_dvi_ddc = ati_i2c(s->bbi2c, data); break; case GPIO_MONID: if (s->dev_id != PCI_DEVICE_ID_ATI_RAGE128_PF) {