From nobody Tue Apr 16 13:57:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552554430316457.38798063348804; Thu, 14 Mar 2019 02:07:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:59426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4MKQ-0000Iy-AS for importer@patchew.org; Thu, 14 Mar 2019 05:07:06 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D s->regs.gpio_vga_ddc; break; + case GPIO_DVI_DDC: + val =3D s->regs.gpio_dvi_ddc; + break; case GPIO_MONID: val =3D s->regs.gpio_monid; break; @@ -426,6 +429,22 @@ static inline void ati_reg_write_offs(uint32_t *reg, i= nt offs, } } =20 +static uint64_t ati_i2c(bitbang_i2c_interface *i2c, + uint64_t data) +{ + bool clk =3D !(data & BIT(17)); + bool out =3D !(data & BIT(16)); + bool in; + + bitbang_i2c_set(i2c, BITBANG_I2C_SCL, clk); + in =3D bitbang_i2c_set(i2c, BITBANG_I2C_SDA, out); + + data &=3D 0xf000f; + data |=3D clk ? BIT(9) : 0; + data |=3D 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 =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { break; } - s->regs.gpio_vga_ddc =3D data & 0xf000f; - if (data & BIT(17)) { - s->regs.gpio_monid |=3D !!(data & BIT(1)) << 9; - bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SCL, (data & BIT(1)) != =3D 0); - } - if (data & BIT(16)) { - s->regs.gpio_monid |=3D bitbang_i2c_set(s->bbi2c, BITBANG_I2C_= SDA, - data & BIT(0)) << 8; +#if 0 + s->regs.gpio_vga_ddc =3D ati_i2c(s->bbi2c, data); +#endif + break; + case GPIO_DVI_DDC: + if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + break; } + s->regs.gpio_dvi_ddc =3D ati_i2c(s->bbi2c, data); break; case GPIO_MONID: if (s->dev_id !=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { --=20 2.18.1