From patchwork Fri Aug 11 06:49:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hean-Loong, Ong" X-Patchwork-Id: 9895089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BBC760351 for ; Fri, 11 Aug 2017 06:50:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B52328760 for ; Fri, 11 Aug 2017 06:50:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E9B128BFA; Fri, 11 Aug 2017 06:50:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E485828970 for ; Fri, 11 Aug 2017 06:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=D8DwnH2xR6aditXWSEp4W0aDZH6iHaW019EbnvyUUzU=; b=cD1mCjSTj2kJP7O2GYFYcTI1K1 DMOeFcKs6yV6RB9BShz0quQsj5oaA/OrqB0qdOzq1SEfxZucEf3X5peEf9yKQhMInZ3pP41vVKZvn jw01isjL4Z+B/cUZkaewGW1TXiU+//5DGU1w7qZgXJRj8sZZuMjaK5ImHDZaOEX09x+4/9oH0P3ey NXtOvqxCQqJXIB/Zi/jP/H1C45DoAtcPrgEebJ246NYyTto0pQ1aMmfVU5qJG5aJr4GHMLauPb99O cLEuAFlN5Hfhwi/TlXBwlAjHkrT4zq2AdL/mogF5CYkTdKI6nwatH3i4UYsStRhSam+szCgF1x4F+ /1VWq1TQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dg3mH-0003my-3h; Fri, 11 Aug 2017 06:50:37 +0000 Received: from mga06.intel.com ([134.134.136.31]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dg3lt-0002KP-Vd for linux-arm-kernel@lists.infradead.org; Fri, 11 Aug 2017 06:50:16 +0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 10 Aug 2017 23:50:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,356,1498546800"; d="scan'208";a="139033304" Received: from helong-vb.png.intel.com ([10.226.242.95]) by fmsmga006.fm.intel.com with ESMTP; 10 Aug 2017 23:49:58 -0700 From: "Hean-Loong, Ong" To: Rob Herring , Dinh Nguyen , Daniel Vetter , Laurent Pinchart , Randy Dunlap Subject: [PATCHv6 3/3] ARM:drm ivip Intel FPGA Video and Image Processing Suite Date: Fri, 11 Aug 2017 14:49:47 +0800 Message-Id: <1502434187-6407-4-git-send-email-hean.loong.ong@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502434187-6407-1-git-send-email-hean.loong.ong@intel.com> References: <1502434187-6407-1-git-send-email-hean.loong.ong@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170810_235014_092323_AB9764AE X-CRM114-Status: GOOD ( 21.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hean.loong.ong@intel.com, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ong Hean Loong Driver for Intel FPGA Video and Image Processing Suite Frame Buffer II. The driver only supports the Intel Arria10 devkit and its variants. This driver can be either loaded staticlly or in modules. The OF device tree binding is located at: Documentation/devicetree/bindings/display/altr,vip-fb2.txt Signed-off-by: Ong Hean Loong --- V6: *Fix Comments for Makefile and Kconfig V5: *Fix Comments V4: *Fix Comments V3: *Changes to fixing drm_simple_pipe *Used drm_fb_cma_get_gem_addr V2: *Adding drm_simple_display_pipe_init --- --- drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/ivip/Kconfig | 14 +++ drivers/gpu/drm/ivip/Makefile | 9 ++ drivers/gpu/drm/ivip/intel_vip_conn.c | 96 +++++++++++++++++ drivers/gpu/drm/ivip/intel_vip_core.c | 162 ++++++++++++++++++++++++++++ drivers/gpu/drm/ivip/intel_vip_drv.h | 52 +++++++++ drivers/gpu/drm/ivip/intel_vip_of.c | 194 ++++++++++++++++++++++++++++++++++ 8 files changed, 530 insertions(+) create mode 100644 drivers/gpu/drm/ivip/Kconfig create mode 100644 drivers/gpu/drm/ivip/Makefile create mode 100644 drivers/gpu/drm/ivip/intel_vip_conn.c create mode 100644 drivers/gpu/drm/ivip/intel_vip_core.c create mode 100644 drivers/gpu/drm/ivip/intel_vip_drv.h create mode 100644 drivers/gpu/drm/ivip/intel_vip_of.c diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 83cb2a8..38a184d 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -195,6 +195,8 @@ source "drivers/gpu/drm/nouveau/Kconfig" source "drivers/gpu/drm/i915/Kconfig" +source "drivers/gpu/drm/ivip/Kconfig" + config DRM_VGEM tristate "Virtual GEM provider" depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 24a066e..4162a0e 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/ obj-$(CONFIG_DRM_MGA) += mga/ obj-$(CONFIG_DRM_I810) += i810/ obj-$(CONFIG_DRM_I915) += i915/ +obj-$(CONFIG_DRM_IVIP) += ivip/ obj-$(CONFIG_DRM_MGAG200) += mgag200/ obj-$(CONFIG_DRM_VC4) += vc4/ obj-$(CONFIG_DRM_CIRRUS_QEMU) += cirrus/ diff --git a/drivers/gpu/drm/ivip/Kconfig b/drivers/gpu/drm/ivip/Kconfig new file mode 100644 index 0000000..398c9ab --- /dev/null +++ b/drivers/gpu/drm/ivip/Kconfig @@ -0,0 +1,14 @@ +config DRM_IVIP + tristate "Intel FGPA Video and Image Processing" + depends on DRM && OF + select DRM_GEM_CMA_HELPER + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_KMS_CMA_HELPER + help + Choose this option if you have a Intel FPGA Arria 10 system + and above with an Intel Display Port IP. This does not support + legacy Intel FPGA Cyclone V display port. Currently only single + frame buffer is supported. Note that ACPI and X_86 architecture + is not supported for Arria10.If M is selected the module will be + called ivip. diff --git a/drivers/gpu/drm/ivip/Makefile b/drivers/gpu/drm/ivip/Makefile new file mode 100644 index 0000000..cc55b04 --- /dev/null +++ b/drivers/gpu/drm/ivip/Makefile @@ -0,0 +1,9 @@ +# +# Makefile for the drm device driver. This driver provides support for the +# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. + +ccflags-y := -Iinclude/drm + +obj-$(CONFIG_DRM_IVIP) += ivip.o +ivip-objs := intel_vip_of.o intel_vip_core.o \ + intel_vip_conn.o diff --git a/drivers/gpu/drm/ivip/intel_vip_conn.c b/drivers/gpu/drm/ivip/intel_vip_conn.c new file mode 100644 index 0000000..c88df23 --- /dev/null +++ b/drivers/gpu/drm/ivip/intel_vip_conn.c @@ -0,0 +1,96 @@ +/* + * intel_vip_conn.c -- Intel Video and Image Processing(VIP) + * Frame Buffer II driver + * + * This driver supports the Intel VIP Frame Reader component. + * More info on the hardware can be found in the Intel Video + * and Image Processing Suite User Guide at this address + * http://www.altera.com/literature/ug/ug_vip.pdf. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Authors: + * Ong, Hean-Loong + * + */ + +#include +#include +#include +#include +#include +#include + +static enum drm_connector_status +intelvipfb_drm_connector_detect(struct drm_connector *connector, bool force) +{ + return connector_status_connected; +} + +static void intelvipfb_drm_connector_destroy(struct drm_connector *connector) +{ + drm_connector_unregister(connector); + drm_connector_cleanup(connector); +} + +static const struct drm_connector_funcs intelvipfb_drm_connector_funcs = { + .dpms = drm_atomic_helper_connector_dpms, + .reset = drm_atomic_helper_connector_reset, + .detect = intelvipfb_drm_connector_detect, + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = intelvipfb_drm_connector_destroy, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static int intelvipfb_drm_connector_get_modes(struct drm_connector *connector) +{ + struct drm_device *drm = connector->dev; + int count; + + count = drm_add_modes_noedid(connector, drm->mode_config.max_width, + drm->mode_config.max_height); + drm_set_preferred_mode(connector, drm->mode_config.max_width, + drm->mode_config.max_height); + return count; +} + +static const struct drm_connector_helper_funcs +intelvipfb_drm_connector_helper_funcs = { + .get_modes = intelvipfb_drm_connector_get_modes, +}; + +struct drm_connector * +intelvipfb_conn_setup(struct drm_device *drm) +{ + struct drm_connector *conn; + int ret; + + conn = devm_kzalloc(drm->dev, sizeof(*conn), GFP_KERNEL); + if (IS_ERR(conn)) + return NULL; + + ret = drm_connector_init(drm, conn, &intelvipfb_drm_connector_funcs, + DRM_MODE_CONNECTOR_DisplayPort); + if (ret < 0) { + dev_err(drm->dev, "failed to initialize drm connector\n"); + ret = -ENOMEM; + goto error_connector_cleanup; + } + + drm_connector_helper_add(conn, &intelvipfb_drm_connector_helper_funcs); + + return conn; + +error_connector_cleanup: + drm_connector_cleanup(conn); + + return NULL; +} diff --git a/drivers/gpu/drm/ivip/intel_vip_core.c b/drivers/gpu/drm/ivip/intel_vip_core.c new file mode 100644 index 0000000..6b43c13 --- /dev/null +++ b/drivers/gpu/drm/ivip/intel_vip_core.c @@ -0,0 +1,162 @@ +/* + * intel_vip_core.c -- Intel Video and Image Processing(VIP) + * Frame Buffer II driver + * + * This driver supports the Intel VIP Frame Reader component. + * More info on the hardware can be found in the Intel Video + * and Image Processing Suite User Guide at this address + * http://www.altera.com/literature/ug/ug_vip.pdf. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Authors: + * Ong, Hean-Loong + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "intel_vip_drv.h" + +static void intelvipfb_enable(struct drm_simple_display_pipe *pipe, + struct drm_crtc_state *crtc_state) +{ + /* + * The frameinfo variable has to correspond to the size of the VIP Suite + * Frame Reader register 7 which will determine the maximum size used + * in this frameinfo + */ + + u32 frameinfo; + struct intelvipfb_priv *priv = pipe->plane.dev->dev_private; + void __iomem *base = priv->base; + struct drm_plane_state *state = pipe->plane.state; + dma_addr_t addr; + + addr = drm_fb_cma_get_gem_addr(state->fb, state, 0); + + dev_info(pipe->plane.dev->dev, "Address 0x%x\n", addr); + + frameinfo = + readl(base + INTELVIPFB_FRAME_READER) & 0x00ffffff; + writel(frameinfo, base + INTELVIPFB_FRAME_INFO); + writel(addr, base + INTELVIPFB_FRAME_START); + /* Finally set the control register to 1 to start streaming */ + writel(1, base + INTELVIPFB_CONTROL); +} + +static void intelvipfb_disable(struct drm_simple_display_pipe *pipe) +{ + struct intelvipfb_priv *priv = pipe->plane.dev->dev_private; + void __iomem *base = priv->base; + /* set the control register to 0 to stop streaming */ + writel(0, base + INTELVIPFB_CONTROL); +} + +static const struct drm_mode_config_funcs intelvipfb_mode_config_funcs = { + .fb_create = drm_fb_cma_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, +}; + +static void intelvipfb_setup_mode_config(struct drm_device *drm) +{ + drm_mode_config_init(drm); + drm->mode_config.funcs = &intelvipfb_mode_config_funcs; +} + +static int intelvipfb_pipe_prepare_fb(struct drm_simple_display_pipe *pipe, + struct drm_plane_state *plane_state) +{ + return drm_fb_cma_prepare_fb(&pipe->plane, plane_state); +} + + +static struct drm_simple_display_pipe_funcs fbpriv_funcs = { + .prepare_fb = intelvipfb_pipe_prepare_fb, + .enable = intelvipfb_enable, + .disable = intelvipfb_disable +}; + +int intelvipfb_probe(struct device *dev) +{ + int retval; + struct drm_device *drm; + struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev); + struct drm_connector *connector; + u32 formats[] = {DRM_FORMAT_XRGB8888}; + + drm = fbpriv->drm; + + drm->dev_private = fbpriv; + + intelvipfb_setup_mode_config(drm); + + connector = intelvipfb_conn_setup(drm); + if (!connector) { + dev_err(drm->dev, "Connector setup failed\n"); + goto err_mode_config; + } + + retval = drm_simple_display_pipe_init(drm, &fbpriv->pipe, + &fbpriv_funcs, formats, + ARRAY_SIZE(formats), connector); + if (retval < 0) { + dev_err(drm->dev, "Cannot setup simple display pipe\n"); + goto err_mode_config; + } + + fbpriv->fbcma = drm_fbdev_cma_init(drm, + drm->mode_config.preferred_depth, + drm->mode_config.num_connector); + + drm_mode_config_reset(drm); + + drm_dev_register(drm, 0); + + return retval; + +err_mode_config: + + drm_mode_config_cleanup(drm); + return -ENODEV; +} + +int intelvipfb_remove(struct device *dev) +{ + struct intelvipfb_priv *fbpriv = dev_get_drvdata(dev); + struct drm_device *drm = fbpriv->drm; + + drm_dev_unregister(drm); + + if (fbpriv->fbcma) + drm_fbdev_cma_fini(fbpriv->fbcma); + + drm_mode_config_cleanup(drm); + drm_dev_unref(drm); + + return 0; +} + +MODULE_AUTHOR("Ong, Hean-Loong "); +MODULE_DESCRIPTION("Intel VIP Frame Buffer II driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/ivip/intel_vip_drv.h b/drivers/gpu/drm/ivip/intel_vip_drv.h new file mode 100644 index 0000000..0a3555d --- /dev/null +++ b/drivers/gpu/drm/ivip/intel_vip_drv.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2017 Intel Corporation. + * + * Intel Video and Image Processing(VIP) Frame Buffer II driver. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * Authors: + * Ong, Hean-Loong + * + */ +#ifndef _INTEL_VIP_DRV_H +#define _INTEL_VIP_DRV_H + +#define DRIVER_NAME "intelvipfb" +#define BYTES_PER_PIXEL 4 +#define CRTC_NUM 1 +#define CONN_NUM 1 + +/* control registers */ +#define INTELVIPFB_CONTROL 0 +#define INTELVIPFB_STATUS 0x4 +#define INTELVIPFB_INTERRUPT 0x8 +#define INTELVIPFB_FRAME_COUNTER 0xC +#define INTELVIPFB_FRAME_DROP 0x10 +#define INTELVIPFB_FRAME_INFO 0x14 +#define INTELVIPFB_FRAME_START 0x18 +#define INTELVIPFB_FRAME_READER 0x1C + +int intelvipfb_probe(struct device *dev); +int intelvipfb_remove(struct device *dev); +int intelvipfb_setup_crtc(struct drm_device *drm); +struct drm_connector *intelvipfb_conn_setup(struct drm_device *drm); + +struct intelvipfb_priv { + struct drm_simple_display_pipe pipe; + struct drm_fbdev_cma *fbcma; + struct drm_device *drm; + void __iomem *base; +}; + +#endif diff --git a/drivers/gpu/drm/ivip/intel_vip_of.c b/drivers/gpu/drm/ivip/intel_vip_of.c new file mode 100644 index 0000000..b46f789 --- /dev/null +++ b/drivers/gpu/drm/ivip/intel_vip_of.c @@ -0,0 +1,194 @@ +/* + * intel_vip_of.c -- Intel Video and Image Processing(VIP) + * Frame Buffer II driver + * + * This driver supports the Intel VIP Frame Reader component. + * More info on the hardware can be found in the Intel Video + * and Image Processing Suite User Guide at this address + * http://www.altera.com/literature/ug/ug_vip.pdf. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Authors: + * Ong, Hean-Loong + * + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "intel_vip_drv.h" + +DEFINE_DRM_GEM_CMA_FOPS(drm_fops); + +static void intelvipfb_lastclose(struct drm_device *drm) +{ + struct intelvipfb_priv *priv = drm->dev_private; + + drm_fbdev_cma_restore_mode(priv->fbcma); +} + +static struct drm_driver intelvipfb_drm = { + .driver_features = + DRIVER_MODESET | DRIVER_GEM | + DRIVER_PRIME | DRIVER_ATOMIC, + .gem_free_object_unlocked = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + .lastclose = intelvipfb_lastclose, + .name = DRIVER_NAME, + .date = "20170729", + .desc = "Intel FPGA VIP SUITE", + .major = 1, + .minor = 0, + .ioctls = NULL, + .patchlevel = 0, + .fops = &drm_fops, +}; + +/* + * Setting up information derived from OF Device Tree Nodes + * max-width, max-height, bits per pixel, memory port width + */ + +static int intelvipfb_drm_setup(struct device *dev, + struct intelvipfb_priv *fbpriv) +{ + struct drm_device *drm = fbpriv->drm; + struct device_node *np = dev->of_node; + int mem_word_width; + int max_h, max_w; + int ret; + + ret = of_property_read_u32(np, "altr,max-width", &max_w); + if (ret) { + dev_err(dev, + "Missing required parameter 'altr,max-width'"); + return ret; + } + + ret = of_property_read_u32(np, "altr,max-height", &max_h); + if (ret) { + dev_err(dev, + "Missing required parameter 'altr,max-height'"); + return ret; + } + + ret = of_property_read_u32(np, "altr,mem-port-width", &mem_word_width); + if (ret) { + dev_err(dev, "Missing required parameter 'altr,mem-port-width '"); + return ret; + } + + if (!(mem_word_width >= 32 && mem_word_width % 32 == 0)) { + dev_err(dev, + "mem-word-width is set to %i. must be >= 32 and multiple of 32.", + mem_word_width); + return -ENODEV; + } + + drm->mode_config.min_width = 640; + drm->mode_config.min_height = 480; + drm->mode_config.max_width = max_w; + drm->mode_config.max_height = max_h; + drm->mode_config.preferred_depth = 32; + + return 0; +} + +static int intelvipfb_of_probe(struct platform_device *pdev) +{ + int retval; + struct resource *reg_res; + struct intelvipfb_priv *fbpriv; + struct device *dev = &pdev->dev; + struct drm_device *drm; + + fbpriv = devm_kzalloc(dev, sizeof(*fbpriv), GFP_KERNEL); + if (!fbpriv) + return -ENOMEM; + + /*setup DRM */ + drm = drm_dev_alloc(&intelvipfb_drm, dev); + if (IS_ERR(drm)) + return PTR_ERR(drm); + + retval = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)); + if (retval) + return -ENODEV; + + fbpriv->drm = drm; + + reg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!reg_res) + return -ENOMEM; + + fbpriv->base = devm_ioremap_resource(dev, reg_res); + + if (IS_ERR(fbpriv->base)) { + dev_err(dev, "devm_ioremap_resource failed\n"); + retval = PTR_ERR(fbpriv->base); + return -ENOMEM; + } + + intelvipfb_drm_setup(dev, fbpriv); + + dev_set_drvdata(dev, fbpriv); + + return intelvipfb_probe(dev); +} + +static int intelvipfb_of_remove(struct platform_device *pdev) +{ + return intelvipfb_remove(&pdev->dev); +} + +/* + * The name vip-frame-buffer-2.0 is derived from + * http://www.altera.com/literature/ug/ug_vip.pdf + * frame buffer IP cores section 14 + */ + +static const struct of_device_id intelvipfb_of_match[] = { + { .compatible = "altr,vip-frame-buffer-2.0" }, + {}, +}; + +MODULE_DEVICE_TABLE(of, intelvipfb_of_match); + +static struct platform_driver intelvipfb_driver = { + .probe = intelvipfb_of_probe, + .remove = intelvipfb_of_remove, + .driver = { + .name = DRIVER_NAME, + .of_match_table = intelvipfb_of_match, + }, +}; + +module_platform_driver(intelvipfb_driver);