From nobody Sun Nov 9 20:19:53 2025 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 1552045087133564.0905938704329; Fri, 8 Mar 2019 03:38:07 -0800 (PST) Received: from localhost ([127.0.0.1]:41426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Dp9-0006hB-1j for importer@patchew.org; Fri, 08 Mar 2019 06:37:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2DoD-0006Kv-0V for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:37:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Do7-0004H4-Rk for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:36:58 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:45382) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2Do7-0003O1-Ge for qemu-devel@nongnu.org; Fri, 08 Mar 2019 06:36:55 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 4E2E8747F06; Fri, 8 Mar 2019 12:36:44 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 21DD4747F03; Fri, 8 Mar 2019 12:36:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 150D0747EEA; Fri, 8 Mar 2019 12:36:44 +0100 (CET) Date: Fri, 8 Mar 2019 12:36:44 +0100 (CET) From: BALATON Zoltan To: qemu-devel@nongnu.org Message-ID: User-Agent: Alpine 2.21.9999 (BSF 287 2018-06-16) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [RFC PATCH] 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: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" I was thinking about something like this for adding DDC/EDID support that=20 several clients seem to expect to get modes other than default 640x480 but=20 it's not working yet correctly. Problems: 1. Compilation fails during linking if I don't have CONFIG_BITBANG_I2C and=20 CONFIG_DDC in top level default-configs/*.mak even if I add these to=20 pci.mak that's included by these and is where CONFIG_ATI_VGA is defined.=20 So probably only compiles for ppc-softmmu at the moment. 2. Something is read from EDID but probably not correct as guests don't=20 like it. Need to debug and check if bits are wired up correctly 3. Want to use bitbang_i2c from outside hw/i2c but that's currently=20 private to that dir. We had to move the struct definition to the public=20 header before to avoid a warning (in commit 2b4c1125ac), maybe we need to=20 move all of bitbanh_i2c.h to include/hw/i2c.h now or make this header=20 public reverting the previous patch. Which one you prefer? I may not have time to finish this before the freeze so if anyone can fix=20 it feel free to take it and continue (drop me a note if you're taking it=20 so we avoid duplicate work). Signed-off-by: BALATON Zoltan --- hw/display/ati.c | 24 ++++++++++++++++++++++-- hw/display/ati_int.h | 4 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 8322f52aff..6ea845d550 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -24,6 +24,8 @@ #include "qapi/error.h" #include "hw/hw.h" #include "ui/console.h" +#include "hw/i2c/i2c-ddc.h" +#include "../i2c/bitbang_i2c.h" #include "trace.h" #define ATI_DEBUG_HW_CURSOR 0 @@ -267,7 +269,9 @@ 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_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 +505,17 @@ 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_MONID: + s->regs.gpio_monid =3D data & 0x000f000f; + if (data & BIT(2) << 16) { + s->regs.gpio_monid |=3D bitbang_i2c_set(s->bbi2c, BITBANG_I2C_= SCL, + (data & BIT(2)) !=3D 0) = << 10; + } + if (data & BIT(1) << 16) { + 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 +806,12 @@ static void ati_vga_realize(PCIDevice *dev, Error **er= rp) vga->cursor_draw_line =3D ati_cursor_draw_line; } + /* ddc, edid */ + s->ddc =3D i2c_init_bus(DEVICE(s), "ati-vga.ddc"); + s->bbi2c =3D bitbang_i2c_init(s->ddc); + I2CDDCState *i2cddc =3D I2CDDC(qdev_create(BUS(s->ddc), TYPE_I2CDDC)); + i2c_set_slave_address(I2C_SLAVE(i2cddc), 0x50); + /* mmio register space */ memory_region_init_io(&s->mm, OBJECT(s), &ati_mm_ops, s, "ati.mmregs", 0x4000); diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index a6f3e20e63..1636f4d710 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "hw/pci/pci.h" +#include "hw/i2c/i2c.h" #include "vga_int.h" /*#define DEBUG_ATI*/ @@ -36,6 +37,7 @@ typedef struct ATIVGARegs { uint32_t crtc_gen_cntl; uint32_t crtc_ext_cntl; uint32_t dac_cntl; + 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 +86,8 @@ typedef struct ATIVGAState { uint16_t cursor_size; uint32_t cursor_offset; QEMUCursor *cursor; + I2CBus *ddc; + bitbang_i2c_interface *bbi2c; MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; --=20 2.13.7