From patchwork Sun May 29 09:40:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rongrong Zou X-Patchwork-Id: 9139715 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 7EABB60221 for ; Sun, 29 May 2016 09:44:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72E9C2796F for ; Sun, 29 May 2016 09:44:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F2527F17; Sun, 29 May 2016 09:44:25 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D88F22796F for ; Sun, 29 May 2016 09:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932256AbcE2JnZ (ORCPT ); Sun, 29 May 2016 05:43:25 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:33626 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932075AbcE2JnV (ORCPT ); Sun, 29 May 2016 05:43:21 -0400 Received: by mail-yw0-f193.google.com with SMTP id y6so11612766ywe.0; Sun, 29 May 2016 02:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OPw6jh63NgS9A8wUZixzQJ6pZfFcjetfS99lc5nEQxU=; b=Cl3FRrANjLsCW26xd6WKH+iP88MV6L9Se0QdjiW7gpr42t/2IIVRGzVVy34Zqswz9M 4oAofoOprEgUCHtXhjGT9vlCrODXpBa/xFVmeTibRBF8791dw0/13zvVqspNGR7gbHFM 5USDuBBnjNFgaQhWyKeDlCLp3AslBBnXTr+uJpkuko/C/lKVUWgex6bSUncGG6WNnioB nx+hdCXPbcuWLMlFMLabM1wHNHmx14aHU8ECwMUnTSm9X4UYBtno9Fcjzxg3ueAfKxe7 Of/KQs6I1yoiQziIOslkMqDISkfpQAe+LCaqspcWPC0lv0m45fRAyDNmpK4+YuLEu+qB Vxaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OPw6jh63NgS9A8wUZixzQJ6pZfFcjetfS99lc5nEQxU=; b=XfVYRMCFxDhYRmYiLHh6fiB0kkElm/u3+YUA5r5oiTu/Mok1Jcaap/T/3y4n+Cf8tZ MhkCDpUW8Sn1phdZla6XxXbAL4qqdO7ffR+bzf11xpoDyQheoQ0dZfHa/PoE4szNnwWV 4Jg4yjizGAJm3e0bsxkz96btzw4fXPeBFmTflrAOLq7EadH46IZQs6osN1iClRDxIcvz NFSbzuUTTZEJ2Tf5AZGHIomNzqSL5DOqJqFGBi3g69SbEz+rZMoz32xdcPrYVX5L1ack BfRwxaI4VWTo4N77JMAs1i6cTvB8QwX5aKxL5M4mHHvK8jQuqepsNvTSv+edgflKYScr cWiQ== X-Gm-Message-State: ALyK8tJ/TgXml55YmhJnO8W9tMPFGxsPikDvikr/qg34apTX3W9KFfp+H3liecXIDTxtqg== X-Received: by 10.13.226.142 with SMTP id l136mr12825489ywe.294.1464515000463; Sun, 29 May 2016 02:43:20 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id l200sm10414744ywe.40.2016.05.29.02.43.14 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 May 2016 02:43:19 -0700 (PDT) From: Rongrong Zou To: zourongrong@huawei.com, airlied@linux.ie, emil.l.velikov@gmail.com, lijianhua@huawei.com, xinliang.liu@linaro.org Cc: dri-devel@lists.freedesktop.org, guohanjun@huawei.com, majun258@huawei.com, linuxarm@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org Subject: [path v2 4/7] drm/hisilicon/hibmc: Add encoder for VDAC Date: Sun, 29 May 2016 17:40:52 +0800 Message-Id: <1464514855-108050-5-git-send-email-zourongrong@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464514855-108050-1-git-send-email-zourongrong@gmail.com> References: <1464514855-108050-1-git-send-email-zourongrong@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add encoder funcs and helpers for VDAC. Signed-off-by: Rongrong Zou Signed-off-by: Jianhua Li --- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 85 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c diff --git a/drivers/gpu/drm/hisilicon/hibmc/Makefile b/drivers/gpu/drm/hisilicon/hibmc/Makefile index faa7e64..4e7797a 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/Makefile +++ b/drivers/gpu/drm/hisilicon/hibmc/Makefile @@ -1,4 +1,4 @@ -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_power.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_drm_power.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c index f7837cc..962072f 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c @@ -129,6 +129,12 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev) return ret; } + ret = hibmc_encoder_init(hidev); + if (ret) { + DRM_ERROR("failed to init encoder\n"); + return ret; + } + return 0; } diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h index e64ec8d..d0c5982 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h @@ -34,11 +34,13 @@ struct hibmc_drm_device { struct drm_device *dev; struct drm_plane plane; struct drm_crtc crtc; + struct drm_encoder encoder; bool mode_config_initialized; }; int hibmc_plane_init(struct hibmc_drm_device *hidev); int hibmc_crtc_init(struct hibmc_drm_device *hidev); +int hibmc_encoder_init(struct hibmc_drm_device *hidev); #endif diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c new file mode 100644 index 0000000..cb9a130 --- /dev/null +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -0,0 +1,85 @@ +/* Hisilicon Hibmc SoC drm driver + * + * Based on the bochs drm driver. + * + * Copyright (c) 2016 Huawei Limited. + * + * Author: + * Rongrong Zou + * Rongrong Zou + * Jianhua Li + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include +#include +#include +#include + +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" + + +static void hibmc_encoder_disable(struct drm_encoder *encoder) +{ +} + +static void hibmc_encoder_enable(struct drm_encoder *encoder) +{ +} + +static void hibmc_encoder_mode_set(struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adj_mode) +{ + u32 reg; + struct drm_device *dev = encoder->dev; + struct hibmc_drm_device *hidev = dev->dev_private; + + /* just open DISPLAY_CONTROL_HISILE register bit 3:0*/ + reg = readl(hidev->mmio + DISPLAY_CONTROL_HISILE); + reg |= 0xf; + writel(reg, hidev->mmio + DISPLAY_CONTROL_HISILE); +} + +static int hibmc_encoder_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + return 0; +} + +static const struct drm_encoder_helper_funcs hibmc_encoder_helper_funcs = { + .mode_set = hibmc_encoder_mode_set, + .disable = hibmc_encoder_disable, + .enable = hibmc_encoder_enable, + .atomic_check = hibmc_encoder_atomic_check, +}; + +static const struct drm_encoder_funcs hibmc_encoder_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + +int hibmc_encoder_init(struct hibmc_drm_device *hidev) +{ + struct drm_device *dev = hidev->dev; + struct drm_encoder *encoder = &hidev->encoder; + int ret; + + encoder->possible_crtcs = 0x1; + ret = drm_encoder_init(dev, encoder, &hibmc_encoder_encoder_funcs, + DRM_MODE_ENCODER_DAC, NULL); + if (ret) { + DRM_ERROR("failed to init encoder\n"); + return ret; + } + + drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); + return 0; +} +