From nobody Thu May 2 05:43:28 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552738888487247.25738665680933; Sat, 16 Mar 2019 05:21:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:41315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h58JS-0004U7-Qd for importer@patchew.org; Sat, 16 Mar 2019 08:21:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h58Hl-0003TZ-Iu for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h58AM-0004BM-Q1 for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:11:55 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:26216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h58AM-00048h-Cg for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:11:54 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 47C257456B1; Sat, 16 Mar 2019 13:11:48 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id B68F074569A; Sat, 16 Mar 2019 13:11:47 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Sat, 16 Mar 2019 13:05:57 +0100 MIME-Version: 1.0 To: qemu-devel@nongnu.org Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v4 1/2] i2c: Move bitbang_i2c.h to include/hw/i2c/ 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: Corey Minyard , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The bitbang i2c implementation is also useful for other device models such as DDC in display controllers. Move the header to include/hw/i2c/ to allow it to be used from other device models and adjust users of this include. This also reverts commit 2b4c1125ac which is no longer needed. Signed-off-by: BALATON Zoltan Reviewed-by: Corey Minyard --- hw/i2c/bitbang_i2c.c | 2 +- hw/i2c/ppc4xx_i2c.c | 1 - hw/i2c/versatile_i2c.c | 2 +- {hw =3D> include/hw}/i2c/bitbang_i2c.h | 2 ++ include/hw/i2c/i2c.h | 2 -- include/hw/i2c/ppc4xx_i2c.h | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) rename {hw =3D> include/hw}/i2c/bitbang_i2c.h (80%) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index 8be88ee265..b3534a3bd4 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -11,7 +11,7 @@ */ #include "qemu/osdep.h" #include "hw/hw.h" -#include "bitbang_i2c.h" +#include "hw/i2c/bitbang_i2c.h" #include "hw/sysbus.h" =20 //#define DEBUG_BITBANG_I2C diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c index d6dfafab31..a907d0194e 100644 --- a/hw/i2c/ppc4xx_i2c.c +++ b/hw/i2c/ppc4xx_i2c.c @@ -30,7 +30,6 @@ #include "cpu.h" #include "hw/hw.h" #include "hw/i2c/ppc4xx_i2c.h" -#include "bitbang_i2c.h" =20 #define PPC4xx_I2C_MEM_SIZE 18 =20 diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c index da9f298ee5..39cbcf1948 100644 --- a/hw/i2c/versatile_i2c.c +++ b/hw/i2c/versatile_i2c.c @@ -23,7 +23,7 @@ =20 #include "qemu/osdep.h" #include "hw/sysbus.h" -#include "bitbang_i2c.h" +#include "hw/i2c/bitbang_i2c.h" #include "qemu/log.h" =20 #define TYPE_VERSATILE_I2C "versatile_i2c" diff --git a/hw/i2c/bitbang_i2c.h b/include/hw/i2c/bitbang_i2c.h similarity index 80% rename from hw/i2c/bitbang_i2c.h rename to include/hw/i2c/bitbang_i2c.h index 9443021710..3a7126d5de 100644 --- a/hw/i2c/bitbang_i2c.h +++ b/include/hw/i2c/bitbang_i2c.h @@ -3,6 +3,8 @@ =20 #include "hw/i2c/i2c.h" =20 +typedef struct bitbang_i2c_interface bitbang_i2c_interface; + #define BITBANG_I2C_SDA 0 #define BITBANG_I2C_SCL 1 =20 diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 8e236f7bb4..75c5bd638b 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -81,8 +81,6 @@ uint8_t i2c_recv(I2CBus *bus); =20 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr); =20 -typedef struct bitbang_i2c_interface bitbang_i2c_interface; - /* lm832x.c */ void lm832x_key_event(DeviceState *dev, int key, int state); =20 diff --git a/include/hw/i2c/ppc4xx_i2c.h b/include/hw/i2c/ppc4xx_i2c.h index b3450bacf7..368a5598fe 100644 --- a/include/hw/i2c/ppc4xx_i2c.h +++ b/include/hw/i2c/ppc4xx_i2c.h @@ -29,7 +29,7 @@ =20 #include "qemu-common.h" #include "hw/sysbus.h" -#include "hw/i2c/i2c.h" +#include "hw/i2c/bitbang_i2c.h" =20 #define TYPE_PPC4xx_I2C "ppc4xx-i2c" #define PPC4xx_I2C(obj) OBJECT_CHECK(PPC4xxI2CState, (obj), TYPE_PPC4xx_I2= C) --=20 2.13.7 From nobody Thu May 2 05:43:28 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552738888488685.513630044598; Sat, 16 Mar 2019 05:21:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:41317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h58JV-0004WJ-Bt for importer@patchew.org; Sat, 16 Mar 2019 08:21:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h58Hl-0003DU-JL for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h58AK-0004A2-SV for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:11:54 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:26217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h58AK-00048i-DP for qemu-devel@nongnu.org; Sat, 16 Mar 2019 08:11:52 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 725137465DB; Sat, 16 Mar 2019 13:11:48 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id BB092745694; Sat, 16 Mar 2019 13:11:47 +0100 (CET) Message-Id: <26803e916b43c7f4a561bdf14d489fb26d7b7ac2.1552737957.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Date: Sat, 16 Mar 2019 13:05:57 +0100 MIME-Version: 1.0 To: qemu-devel@nongnu.org Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v4 2/2] ati-vga: Implement DDC and EDID info from monitor 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: Corey Minyard , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This adds DDC support to ati-vga and connects i2c-ddc to provide EDID info that is read by guests to find available screen modes. Not sure if this is 100% correct yet but at least MorphOS is happy with it and starts in a high resolution mode instead of 640x480 (although its splash screen is still not correct). Linux needs support from VESA vgabios, it seems to be missing INT10 0x4F15 function (see https://gitlab.freedesktop.org/xorg/xserver/blob/master/hw/xfree86/vbe/vbe.= c) without which no DDC is available that also prevents loading the accelerated X driver. Signed-off-by: BALATON Zoltan --- hw/display/Kconfig | 2 ++ hw/display/ati.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- hw/display/ati_int.h | 4 ++++ hw/display/ati_regs.h | 1 + 4 files changed, 49 insertions(+), 2 deletions(-) diff --git a/hw/display/Kconfig b/hw/display/Kconfig index 86c1d544c5..f8d65802a9 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -112,3 +112,5 @@ config ATI_VGA default y if PCI_DEVICES depends on PCI select VGA + select BITBANG_I2C + select DDC diff --git a/hw/display/ati.c b/hw/display/ati.c index 8322f52aff..055cc69e16 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -24,6 +24,7 @@ #include "qapi/error.h" #include "hw/hw.h" #include "ui/console.h" +#include "hw/i2c/i2c-ddc.h" #include "trace.h" =20 #define ATI_DEBUG_HW_CURSOR 0 @@ -267,7 +268,12 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr,= unsigned int size) case DAC_CNTL: val =3D s->regs.dac_cntl; break; -/* case GPIO_MONID: FIXME hook up DDC I2C here */ + case GPIO_DVI_DDC: + val =3D s->regs.gpio_dvi_ddc; + break; + case GPIO_MONID: + val =3D s->regs.gpio_monid; + break; case PALETTE_INDEX: /* FIXME unaligned access */ val =3D vga_ioport_read(&s->vga, VGA_PEL_IR) << 16; @@ -501,7 +507,34 @@ static void ati_mm_write(void *opaque, hwaddr addr, s->regs.dac_cntl =3D data & 0xffffe3ff; s->vga.dac_8bit =3D !!(data & DAC_8BIT_EN); break; -/* case GPIO_MONID: FIXME hook up DDC I2C here */ + case GPIO_DVI_DDC: + if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + break; + } + s->regs.gpio_dvi_ddc =3D data & 0xf000f; + if (data & BIT(17)) { + s->regs.gpio_dvi_ddc |=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_dvi_ddc |=3D bitbang_i2c_set(s->bbi2c, BITBANG_I2= C_SDA, + data & BIT(0)) << 8; + } + break; + case GPIO_MONID: + if (s->dev_id !=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + break; /* FIXME What does Radeon have here? */ + } + s->regs.gpio_monid =3D data & 0x0f0f000f; + if (data & BIT(2) << 24) { + s->regs.gpio_monid |=3D !!(data & BIT(2)) << 10; + bitbang_i2c_set(s->bbi2c, BITBANG_I2C_SCL, (data & BIT(2)) != =3D 0); + } + if (data & BIT(1) << 24) { + s->regs.gpio_monid |=3D bitbang_i2c_set(s->bbi2c, BITBANG_I2C_= SDA, + (data & BIT(1)) !=3D 0) = << 9; + } + break; case PALETTE_INDEX ... PALETTE_INDEX + 3: if (size =3D=3D 4) { vga_ioport_write(&s->vga, VGA_PEL_IR, (data >> 16) & 0xff); @@ -792,6 +825,12 @@ static void ati_vga_realize(PCIDevice *dev, Error **er= rp) vga->cursor_draw_line =3D ati_cursor_draw_line; } =20 + /* ddc, edid */ + I2CBus *i2cbus =3D i2c_init_bus(DEVICE(s), "ati-vga.ddc"); + s->bbi2c =3D bitbang_i2c_init(i2cbus); + I2CSlave *i2cddc =3D I2C_SLAVE(qdev_create(BUS(i2cbus), TYPE_I2CDDC)); + i2c_set_slave_address(i2cddc, 0x50); + /* mmio register space */ memory_region_init_io(&s->mm, OBJECT(s), &ati_mm_ops, s, "ati.mmregs", 0x4000); @@ -817,6 +856,7 @@ static void ati_vga_exit(PCIDevice *dev) ATIVGAState *s =3D ATI_VGA(dev); =20 graphic_console_close(s->vga.con); + g_free(s->bbi2c); } =20 static Property ati_vga_properties[] =3D { diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index a6f3e20e63..bad1846c76 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -11,6 +11,7 @@ =20 #include "qemu/osdep.h" #include "hw/pci/pci.h" +#include "hw/i2c/bitbang_i2c.h" #include "vga_int.h" =20 /*#define DEBUG_ATI*/ @@ -36,6 +37,8 @@ typedef struct ATIVGARegs { uint32_t crtc_gen_cntl; uint32_t crtc_ext_cntl; uint32_t dac_cntl; + uint32_t gpio_dvi_ddc; + uint32_t gpio_monid; uint32_t crtc_h_total_disp; uint32_t crtc_h_sync_strt_wid; uint32_t crtc_v_total_disp; @@ -84,6 +87,7 @@ typedef struct ATIVGAState { uint16_t cursor_size; uint32_t cursor_offset; QEMUCursor *cursor; + bitbang_i2c_interface *bbi2c; MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index 923bfd33ce..b9cd373862 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -37,6 +37,7 @@ #define CRTC_GEN_CNTL 0x0050 #define CRTC_EXT_CNTL 0x0054 #define DAC_CNTL 0x0058 +#define GPIO_DVI_DDC 0x0064 #define GPIO_MONID 0x0068 #define I2C_CNTL_1 0x0094 #define PALETTE_INDEX 0x00b0 --=20 2.13.7