From patchwork Mon Oct 3 03:12:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 677610 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3snRxk5QVpz9rxv for ; Mon, 3 Oct 2016 14:15:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=kVVdsPnj; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5810AA76BB; Mon, 3 Oct 2016 05:14:09 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DDI6L4LQdbFf; Mon, 3 Oct 2016 05:14:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1786CA76C1; Mon, 3 Oct 2016 05:13:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C329A7638 for ; Mon, 3 Oct 2016 05:13:27 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eFJmKYtQYxq4 for ; Mon, 3 Oct 2016 05:13:27 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-oi0-f46.google.com (mail-oi0-f46.google.com [209.85.218.46]) by theia.denx.de (Postfix) with ESMTPS id 34EEDA7679 for ; Mon, 3 Oct 2016 05:13:04 +0200 (CEST) Received: by mail-oi0-f46.google.com with SMTP id w11so187101033oia.2 for ; Sun, 02 Oct 2016 20:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bTVogtDwuc/pDAqPwYGFoW7qvDGWrPX3Hpqghwm3Mc0=; b=kVVdsPnjFg23ao0r/peLtU4m49B/+NyjKu1x+luBOmE9BtZzqNATOAHrfsJoePuHMW 4kr46NNGwv8cDZXp1KXdtNU+T1fosN8oDlVHvjbkYPp5C2YDt0mzb6foBcePeBz+kgEK QSQjLR/ikOYBpbH7KVu478Xj+2XzMdaftsIDs6zrTw7MHTRw20JuJGLhqT8EOGX1q+eG 0PxGxtZD7syHqzBqmzVuYsc1IWIyZB46YDcVciXdFKxrUOMXl28yybQLtm7hmRXBq7xK KTDaQu2z3Fim3PvbvO+NszdWRMpa1xiHPlEecvIM/lJKqdwOYMdjE8Dgis8gTPWPGnIq KZ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=bTVogtDwuc/pDAqPwYGFoW7qvDGWrPX3Hpqghwm3Mc0=; b=JKgzkLRvI8Hc3paGh2aD3y1+W1IR+qi+zw1bu4Mi2x68CGKAP2FD1bQy03A5JPzouK pRMfr8Km1mT0aSFsZZt+k4E6IHPv+SqPmvFWCTIoRw/efKkQxz9/f8cJVktPBdSVXwvR +fcxcIFcEEYETWXKqJTB0lyQCQHohyInZBKqAasv9X6SHva5aCdI0ZkR5zM8iSKRrE/e 7cGb/Nnr63DzKYb9LtZBZ/NMrfvGwOw6zCigUgT2/C27u57Pc0DQh6iYxRJ5xmhWY2V4 rXv8V4zGvzivvgh38lEWVIAgjFNM/7JGuRGXongGpEKJBgIVAhbNO+l2D2xw6qNG9JNf aTDw== X-Gm-Message-State: AA6/9RmfLHcWQMZnYyLP2UIPBh9n7t5xp+XY6TXSdPRiqiuLm2D7LcSAZ8UkdgMs13l6NTzR X-Received: by 10.202.252.139 with SMTP id a133mr508774oii.130.1475464383084; Sun, 02 Oct 2016 20:13:03 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.202.55]) by smtp.gmail.com with ESMTPSA id e186sm11241902oig.18.2016.10.02.20.13.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Oct 2016 20:13:02 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 02732220EF0; Sun, 2 Oct 2016 21:13:01 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 2 Oct 2016 21:12:42 -0600 Message-Id: <1475464365-18437-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1475464365-18437-1-git-send-email-sjg@chromium.org> References: <1475464365-18437-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH 09/12] dm: video: Add driver-model support to vesa graphics X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Provide a function to run the Vesa BIOS for a given PCI device and obtain the resulting configuration (e.g. display size) for use by the video uclass. This makes it easier to write a video driver that uses vesa and supports driver model. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- drivers/pci/pci_rom.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/vbe.h | 2 ++ 2 files changed, 57 insertions(+) diff --git a/drivers/pci/pci_rom.c b/drivers/pci/pci_rom.c index 399055b..1805dac 100644 --- a/drivers/pci/pci_rom.c +++ b/drivers/pci/pci_rom.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -348,3 +349,57 @@ err: free(ram); return ret; } + +#ifdef CONFIG_DM_VIDEO +int vbe_setup_video_priv(struct vesa_mode_info *vesa, + struct video_priv *uc_priv, + struct video_uc_platdata *plat) +{ + if (!vesa->x_resolution) + return -ENXIO; + uc_priv->xsize = vesa->x_resolution; + uc_priv->ysize = vesa->y_resolution; + switch (vesa->bits_per_pixel) { + case 32: + case 24: + uc_priv->bpix = VIDEO_BPP32; + break; + case 16: + uc_priv->bpix = VIDEO_BPP16; + break; + default: + return -EPROTONOSUPPORT; + } + plat->base = vesa->phys_base_ptr; + plat->size = vesa->bytes_per_scanline * vesa->y_resolution; + + return 0; +} + +int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)) +{ + struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); + struct video_priv *uc_priv = dev_get_uclass_priv(dev); + int ret; + + /* If we are running from EFI or coreboot, this can't work */ + if (!ll_boot_init()) + return -EPERM; + bootstage_start(BOOTSTAGE_ID_ACCUM_LCD, "vesa display"); + ret = dm_pci_run_vga_bios(dev, int15_handler, PCI_ROM_USE_NATIVE | + PCI_ROM_ALLOW_FALLBACK); + bootstage_accum(BOOTSTAGE_ID_ACCUM_LCD); + if (ret) { + debug("failed to run video BIOS: %d\n", ret); + return ret; + } + + ret = vbe_setup_video_priv(&mode_info.vesa, uc_priv, plat); + if (ret) { + debug("No video mode configured\n"); + return ret; + } + + return 0; +} +#endif diff --git a/include/vbe.h b/include/vbe.h index 164ccae..a743892 100644 --- a/include/vbe.h +++ b/include/vbe.h @@ -106,5 +106,7 @@ extern struct vbe_mode_info mode_info; struct graphic_device; int vbe_get_video_info(struct graphic_device *gdev); +struct video_priv; +int vbe_setup_video(struct udevice *dev, int (*int15_handler)(void)); #endif