From patchwork Sun Feb 17 17:59:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2153681 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8B4D3DF283 for ; Sun, 17 Feb 2013 18:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810Ab3BQSCJ (ORCPT ); Sun, 17 Feb 2013 13:02:09 -0500 Received: from mail-bk0-f43.google.com ([209.85.214.43]:41485 "EHLO mail-bk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751705Ab3BQR7x (ORCPT ); Sun, 17 Feb 2013 12:59:53 -0500 Received: by mail-bk0-f43.google.com with SMTP id jm19so2199582bkc.16 for ; Sun, 17 Feb 2013 09:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=8ojw1r97yonipJS0r4nZjLl3eYX0ROVI9PQ+DGX5fJQ=; b=HibWLbQcunC6ymE1NJdEMyci5IV/a1JjmvSql0SISeLa0ZaU1p5qzinmZU8ZjBvdUX QHIT0KVUBLywtpyoFCHKA4UWCEPk0fels32nP4/n0TOWIKrDdCEnQJ68jrYWz1ewdAAq l8MWnAFkWGlVgIlV2hyZKn4Rs4UDu+whTSJ7ntOuPqwrxPca5G61PujLASntMGbVj24k wARGzVG187q1KDDoIHbLKGMnyjwDoxNj/JNUpBjTgR0jht2pSk0GXdW9ZERW84Lu2lWE U0AlVh6Jusb1zsWX3NIMFRQ1+Yq1nwZAS+gNXstCE317R5ngEhNCH49Qju2KZjQMA+9N Jcmg== X-Received: by 10.204.7.91 with SMTP id c27mr3537285bkc.25.1361123991630; Sun, 17 Feb 2013 09:59:51 -0800 (PST) Received: from localhost.localdomain (stgt-5f71b832.pool.mediaWays.net. [95.113.184.50]) by mx.google.com with ESMTPS id ho6sm20038738bkc.0.2013.02.17.09.59.50 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 09:59:51 -0800 (PST) From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Florian Tobias Schandinat , linux-fbdev@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, David Herrmann Subject: [PATCH 2/9] video: sysfb: new vbefb device type Date: Sun, 17 Feb 2013 18:59:04 +0100 Message-Id: <1361123951-587-3-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com> References: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: David Herrmann This adds the VESA BIOS Extension (VBE) device type. Platform code needs to provide the "vbefb" platform-device with a screen_info structure as platform code. All drivers that depend on VBE can now register as bus drivers and bind to SYSFB_VBE devices. There is no distinction between graphics framebuffers or plain text VGA. Drivers ought to inspect the screen_info and return -ENODEV during probe() is they cannot make use of the device. Only one framebuffer of type SYSFB_VBE is available on a system at a time. Signed-off-by: David Herrmann --- drivers/video/sysfb.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/sysfb.h | 5 +++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/drivers/video/sysfb.c b/drivers/video/sysfb.c index 8249006..5b47a9a 100644 --- a/drivers/video/sysfb.c +++ b/drivers/video/sysfb.c @@ -205,6 +205,72 @@ void sysfb_taint(struct sysfb_device *sdev, bool set) } EXPORT_SYMBOL(sysfb_taint); +static void sysfb_dev_release(struct device *dev) +{ + struct sysfb_device *sdev = to_sysfb_device(dev); + + kfree(sdev); +} + +static struct sysfb_device *sysfb_dev_new(struct device *parent) +{ + struct sysfb_device *sdev; + + sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); + if (!sdev) + return NULL; + + device_initialize(&sdev->dev); + sdev->dev.release = sysfb_dev_release; + sdev->dev.bus = &sysfb_bus_type; + sdev->dev.parent = parent; + + return sdev; +} + +static int sysfb_vbe_probe(struct platform_device *pdev) +{ + int ret; + struct sysfb_device *sdev; + + sdev = sysfb_dev_new(&pdev->dev); + if (!sdev) + return -ENOMEM; + + dev_set_name(&sdev->dev, "vbefb"); + sdev->type = SYSFB_VBE; + sdev->screen = pdev->dev.platform_data; + + ret = device_add(&sdev->dev); + if (ret) + goto err_free; + + platform_set_drvdata(pdev, sdev); + return 0; + +err_free: + put_device(&sdev->dev); + return ret; +} + +static int sysfb_vbe_remove(struct platform_device *pdev) +{ + struct sysfb_device *sdev = platform_get_drvdata(pdev); + + device_del(&sdev->dev); + put_device(&sdev->dev); + return 0; +} + +static struct platform_driver sysfb_vbe_driver = { + .driver = { + .name = "vbefb", + .owner = THIS_MODULE, + }, + .probe = sysfb_vbe_probe, + .remove = sysfb_vbe_remove, +}; + static int __init sysfb_init(void) { int ret; @@ -215,11 +281,22 @@ static int __init sysfb_init(void) return ret; } + ret = platform_driver_register(&sysfb_vbe_driver); + if (ret) { + pr_err("cannot register VBE framebuffer driver\n"); + goto err_bus; + } + return 0; + +err_bus: + bus_unregister(&sysfb_bus_type); + return ret; } static void __exit sysfb_exit(void) { + platform_driver_unregister(&sysfb_vbe_driver); bus_unregister(&sysfb_bus_type); } diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h index 6cd3c24..1796c1e 100644 --- a/include/linux/sysfb.h +++ b/include/linux/sysfb.h @@ -20,6 +20,7 @@ /** * sysfb_type + * @SYSFB_VBE: VESA BIOS Extension compatible device (includes VGA devices) * * Different types of available framebuffer devices. Only one device of each * type can be available at a time. In most systems there even is only one @@ -29,7 +30,9 @@ * devices. */ enum sysfb_type { - SYSFB_TYPES = 0, + SYSFB_VBE = 0x01, + + SYSFB_TYPES = SYSFB_VBE, }; /**