From patchwork Tue Jun 14 09:20:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Meng Yi X-Patchwork-Id: 9175387 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 EA1BA6075D for ; Tue, 14 Jun 2016 09:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA750282ED for ; Tue, 14 Jun 2016 09:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF24028303; Tue, 14 Jun 2016 09:37:19 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28090282ED for ; Tue, 14 Jun 2016 09:37:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D0BA6E705; Tue, 14 Jun 2016 09:37:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0075.outbound.protection.outlook.com [65.55.169.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 744666E705 for ; Tue, 14 Jun 2016 09:31:04 +0000 (UTC) Received: from BLUPR0301CA0041.namprd03.prod.outlook.com (10.162.113.179) by BN3PR03MB2371.namprd03.prod.outlook.com (10.166.75.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8; Tue, 14 Jun 2016 09:31:02 +0000 Received: from BN1BFFO11FD014.protection.gbl (2a01:111:f400:7c10::1:142) by BLUPR0301CA0041.outlook.office365.com (2a01:111:e400:5259::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.517.8 via Frontend Transport; Tue, 14 Jun 2016 09:31:02 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD014.mail.protection.outlook.com (10.58.144.77) with Microsoft SMTP Server (TLS) id 15.1.511.7 via Frontend Transport; Tue, 14 Jun 2016 09:31:01 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u5E9UssY027941; Tue, 14 Jun 2016 02:30:56 -0700 From: Meng Yi To: , Subject: [PATCH v2 1/2] drm/fsl-dcu: Add HDMI driver for freescale DCU Date: Tue, 14 Jun 2016 17:20:36 +0800 Message-ID: <1465896037-537-1-git-send-email-meng.yi@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131103702622142838; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(2906002)(189998001)(356003)(19580395003)(19580405001)(5008740100001)(48376002)(6806005)(104016004)(586003)(105606002)(8936002)(36756003)(97736004)(50986999)(5001770100001)(92566002)(8666004)(5003940100001)(86362001)(106466001)(8676002)(81156014)(81166006)(4326007)(11100500001)(229853001)(5890100001)(47776003)(33646002)(68736007)(87936001)(50226002)(85426001)(77096005)(50466002)(7059030)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2371; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD014; 1:hvlfUW13J8sbzLTpecxlNDwoNy+T0gEFiBswpUOWdP4+E4pah/zXeD5+CugH15yhncILgNK51fb5F8w2kCIBKmvw49GEb9HRghJLsZ4OmKmKtR7hfX3/xwjWgNzfWJ6NCMNAgGhWg/usWAramgpQJE3bPpdNt+yXBtNq4YDcSpfPUupD/mclXcMQsGr7QW2J9rCPUp119zIqjsxxJZoIhyN94seY1kb3E6177qmLMjym/hxZDRL35wSza639grMD/M/uZsorBZYRZHWUHZ7Us79GhGA71zjS9XURbh9HQ6n92f6BjbJwXPdovVkeaaXxh9AqloOj91VFBMXuKi5j902uM3YomQuydKhNlu48r7XnWi0WAzVrz1fqrzE4vNpxCtwDmxmMLVNZFo6gL8EIlaTTJJv/kTCkgJFZSyBNy3iKaJHsuy2QITPjt+uKuyBdVXpdjlK+CuXeZ2iDiJRsLie6gUMYkSRwJ4kRC3NyTKRG9A9W8fssk2aMDq0Ktw3Kp4ObNv+VRzfzkH9m3FC79Q3rgjtf4JIJEOtneIkrRNJqsyKXKrsITL3dzUpjEGi+j20ma+9OgjbkjTgsfPYW7Q== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 8147763a-59c0-4322-a015-08d3943699fc X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 2:QsbomLInoOcUxUwad8c14MxMCc/oTwzIHoqeB1RBC/VdH0EmjisNMzC842FLEYV5YIwB5C8KWb6yWxLtlpMPHqAFzA4AEYQcObcK03drA3ShZS6fdCObZSoJg3KxoL2snM3KUcXNW6B11hAtiS3Zj3QPhN6eCuEkTBx+PrBOHbslvMuzODqpG+kgaES3g/L1; 3:AzQX0UL1poh5MquwSDl35bhRrnuhjVfRjQMno+U5h06Nhf9zDNqR3z4ovwMXwKnT0cFyfPdjTK0dyE/l7uW13OKsFv8NJ90mmChYLf+SvlMbjZ5wD2PJQn5tKehx4YED7SXqdjKYonfQ0Yvd9OODu79KT56WTtDoS6gjDIS+PbqVRS1jTjx2HB218u3k9Vg034zQe59hAdiI0uobbek0AVBNBGrApU4jubN4tTGdbxs=; 25:hecjVshWX/DWTbLd2QaOguLK2vcrDri2xr8SOxBbK+6QA6LnILhsnHxvN58IhI9IrWBo1vqqv/iLySIZ78iPc7TaLNezeRVSoDbv8NbDOJuE8u71F9SkVBvAzn+hfmqmd8zVjlzXPtEb7EVrDerVSdaCT7gTG1cyelQhEIumWn8stugSfEs2k+ozWAypBKoQBbIYLmFDsElXx4b8koy1wp3WeY5/FPXu2PDznm9k7G3aDFgvFOOgki+bNXwHBQX+VrYjuAG8vKmqFfDKsj51uFYxu8n8tOvSP1Kj6c40ZUcCaEDGXCLxdo0dC6r8uWjaZNwKqXauJkWkPJqks5jEr8p4t8dpxPKQjpPvqipI7WUYiOxM5BM+JD+xGueDUXXq8Dx9JdZh71DWy8XU+9eCUg9UiTCRPGjDsgFIX02oDds= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB2371; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13018025)(13023025)(13017025)(13015025)(13024025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BN3PR03MB2371; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2371; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 4:r7pZL8IhWRwk/qPKYzOF61H5r35VvmTLZFKUBAth8mI91uhuP4dwpBeZZPOxtcdQIKO/O/0KEow/En2lpEJMOBrIf+SPtT5s0AMUlRilIVXxPJkgBlNKS6n91dZaQr7seDDQN/lRD0KjmnOaigmv84VAvc1rg2M6nFiCSoc6IxB95ixdh7FKkVmP+cw6fFMbuG503nboJkpEFifJ1MXPzAVvAPV5vKg18eVCBc6IOVh+1f0zuDHHb12pVqNd6gKceO0YatMwFHZA7cgGZ7hr5xN9nkvZiSqd2NzqHkjCHUQJkBs3eftjfK8wP1c0iUB4yWok3dfizQ9tw9Gej19XMRG+1K6rbKVkD5USBCdRmsfSOSUsRKS4IHoFPr7DlJRSRgBkDwQUldRfPG/XGc8cNjy93RHWREEF2Leu19rdbPIPpM+jdD4xYuVl1utAiBX3BrCoi2heUSbkTTVC5Mqw4mn3zhJMAoRZ0RlNKIGRSzitcIjl2PIM4Pl3S8ys8Ww/JDF+d1y7d1qA7tf1SthILQ== X-Forefront-PRVS: 09730BD177 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2371; 23:+53Mm2OAVeyUDxkdyvoK1PQiAGqpUbLX1hH3TRfAS?= =?us-ascii?Q?3SNeF8mqYE7dvveIr/avJeOMMff9eNn2jd2dKi8/PUVaHCjrk7ok/x7xQmc+?= =?us-ascii?Q?8sMpBgKjptDolz2MYAtis5tB10ZeoyuEt7LgcqKTuFYvNNW2xEPZdGB8SOWq?= =?us-ascii?Q?uYE+U7ZBH5xxzjdEG35ck3pYB+mEFhsek9GPpvuHYnJuei+W5kiF1YtDqg+d?= =?us-ascii?Q?keNAyN7/SutBHaBBalUiko/CrJJzsraUuKTf2IpyN2CiG3xeNlWLE7hWq7fU?= =?us-ascii?Q?Nu9mfNu2RaNSgUemngBRBNktwchBYXfdUTcNJhcNuZLfUuHRGtInrUyL7IMQ?= =?us-ascii?Q?jAg6URjVYeGVzS/WSm+GP6qTlii6W2MPLq9ByMEZXP0ymjlWsUeVFxPGNhRl?= =?us-ascii?Q?LC1dXVo0r0PJPLlFZvWPPtDiZKXtrRe1xp7fRHcM9UKF5RuUFp3sUe9xLpMV?= =?us-ascii?Q?7fChTywwOQO7J5SZXHKJVsLdH8mr1e4AEiRhBsTkQz6JGHnyfXeNaOQOBAgB?= =?us-ascii?Q?xcFTW0Q7+eN10B9tquRUcSwtztqghMUzOZhAHPmmG09Plar78E/5WCV2tdTT?= =?us-ascii?Q?P62d4uThe097DqGRaVA8ADd+4muPgbke33bQsnP5mR4i+/ooYaN4kcGFbKqD?= =?us-ascii?Q?q6CYINmq5gZyBUU3kK0twUPkI3NTgYkIRwJvJSCYLnZ9Sjd+4EQEhzpuwaHB?= =?us-ascii?Q?uzmfTq48HN7Whb6Dq0ES9N7wz4P6WkVYNV6XAZdrNddZV3U1VBjYct+pWAY5?= =?us-ascii?Q?ev9HgbDDwSYX7HSn/kyCG0qFq2ZaNWiBDgpy7gFnl503XWDmtp1I37TTPO7W?= =?us-ascii?Q?L+XwCQz/sKJe/5QfF8l+wVZeBUPHhZF9+OhGAcE/NN6BjANEqJT7IbHaBV3v?= =?us-ascii?Q?212uyqUTCrcwBPPwsez4PLO5806+qOXphtA0wIR8Kji8x0zc7XCr8nTx2g+l?= =?us-ascii?Q?a9Na1fXpxR1Cqo0ABCk80ycdioYvVfBSxlWClegLkCNeAC715b2u3yCnB+2S?= =?us-ascii?Q?jDkONJGuJdApACYQfEmKgiOHyvX1+Rhu2lmmaMW6FuGsBgqTngbdIILx1WAO?= =?us-ascii?Q?hBWmKWo63i6259AThN63H9A+GLD2XiUtbua9M8KGA9NZ6XuocD6ioRzCVpC/?= =?us-ascii?Q?u9V7ZVvJrs80SZTnk3HOTpnQKrshx0Sngoh8iOMl5+LOC6SU614Vw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2371; 6:IXiLgM73x8I6SeCQBUUuLOzmWWBW3GjtC05GRe6hOghhesXz2CZYYJvvzF1/1rHF1fy923F0ir2ftPPXngDGHURp3Cwqw7yTfoZxr91psVpI8+HiONcCfomX3X9agKpIkJS1bhnQBLKdu50uMuaw6jHNq4oGXut4dIyXq7fNOSTGX4FYdosKQH8PtVoTJHGb5oLvgTFuPNzBC35ul/kppxami6dSx/1tpQkyTudn416BUucn+qV34EVRKWTF/KiYFtnbki7wvIttQeuF6QpYQQ==; 5:uobIg1Qqcug2fLKRGbHNxW/Hdrfvztk+zozM4l6o3dI6CgpPGK9Wax3hRpjSXQw1K53wO8yrZ/xmLfwXPnqbJvGuAo1CObqzNTJLfQUSKkXmJuT1afEIM0xhG5E3bRn9341aTRXqqMZqIkFbPg4cyhDfJSTwdf8KRPo8P4W5yfM=; 24:/29WtCs+LsYAoOUcrgeMVj4nvHsrIMi+lVsZG3gFp1q+5UJlELy/FCCeSYlo4TTt2hDKZDxUnsHDnSoNY1rvXAgSkKJ+7QNm8G38KefJPD8=; 7:zZvm0WB384O3Y182KCQVldFOCpVqf/QkPWs9BQd9VIqiMYdQI/FSPBgx3aw9MxFIlkravXFNUFPzByHblpzSxIOrCXwTw5Dvda6gHZ3fNLRTNyaFNccgAU4YbjLz2iQNpTmHCXUkP0yao/+M610+QgmtAPWWg2+2Kus9hZFoYBnd1riG37Hnrc6KHUCvKh/0gAsitWEBG4U2TyWf9buijA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 09:31:01.8086 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2371 X-Mailman-Approved-At: Tue, 14 Jun 2016 09:37:15 +0000 Cc: Jianwei Wang , Xiubo Li , Meng Yi , Alison Wang , emil.l.velikov@gmail.com, dri-devel@lists.freedesktop.org, maxime.ripard@free-electrons.com, alexander.stein@systec-electronic.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch creates another Encoder for HDMI port, and linking the Encoder to appropriate DRM bridge. And this Encoder using same CRTC with RGB-LCD. For RGB-LCD and HDMI using the same hardware connection to DCU, RGB-LCD panel should be unplugged when using the HDMI connection. Signed-off-by: Alison Wang Signed-off-by: Xiubo Li Signed-off-by: Jianwei Wang Signed-off-by: Meng Yi --- Changes in V2: -remove unused headers inclusion -remove module declarations -fix error handling coding style -drop moulde parameters and auto detect HDMI connection relying on deviece tree -modified comment lines --- drivers/gpu/drm/fsl-dcu/Makefile | 1 + drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_hdmi.c | 189 +++++++++++++++++++++++++++ drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c | 16 +++ drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_output.h | 4 + 4 files changed, 210 insertions(+) create mode 100644 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_hdmi.c diff --git a/drivers/gpu/drm/fsl-dcu/Makefile b/drivers/gpu/drm/fsl-dcu/Makefile index b35a292..12e2245 100644 --- a/drivers/gpu/drm/fsl-dcu/Makefile +++ b/drivers/gpu/drm/fsl-dcu/Makefile @@ -1,6 +1,7 @@ fsl-dcu-drm-y := fsl_dcu_drm_drv.o \ fsl_dcu_drm_kms.o \ fsl_dcu_drm_rgb.o \ + fsl_dcu_drm_hdmi.o \ fsl_dcu_drm_plane.o \ fsl_dcu_drm_crtc.o \ fsl_dcu_drm_fbdev.o \ diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_hdmi.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_hdmi.c new file mode 100644 index 0000000..f567534 --- /dev/null +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_hdmi.c @@ -0,0 +1,189 @@ +/* + * Copyright 2016 NXP Semiconductor, Inc. + * + * NXP DCU drm device driver + * + * 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 + +#include "fsl_dcu_drm_drv.h" +#include "fsl_dcu_drm_output.h" +#include "fsl_tcon.h" + +static void +fsl_dcu_drm_hdmienc_mode_set(struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + /*TODO*/ +} + +static int +fsl_dcu_drm_hdmienc_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + return 0; +} + +static void +fsl_dcu_drm_hdmienc_disable(struct drm_encoder *encoder) +{ + struct drm_device *dev = encoder->dev; + struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + + if (fsl_dev->tcon) + fsl_tcon_bypass_disable(fsl_dev->tcon); +} + +static void +fsl_dcu_drm_hdmienc_enable(struct drm_encoder *encoder) +{ + struct drm_device *dev = encoder->dev; + struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + + if (fsl_dev->tcon) + fsl_tcon_bypass_enable(fsl_dev->tcon); +} + +static const struct +drm_encoder_helper_funcs encoder_helper_funcs = { + .atomic_check = fsl_dcu_drm_hdmienc_atomic_check, + .disable = fsl_dcu_drm_hdmienc_disable, + .enable = fsl_dcu_drm_hdmienc_enable, + .mode_set = fsl_dcu_drm_hdmienc_mode_set, +}; + +static void +fsl_dcu_drm_hdmienc_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct +drm_encoder_funcs encoder_funcs = { + .destroy = fsl_dcu_drm_hdmienc_destroy, +}; + +int fsl_dcu_drm_hdmienc_create(struct fsl_dcu_drm_device *fsl_dev, + struct drm_crtc *crtc) +{ + struct drm_encoder *encoder; + int ret; + + encoder = devm_kzalloc(fsl_dev->dev, + sizeof(struct drm_encoder), GFP_KERNEL); + if (!encoder) + return -ENOMEM; + + encoder->possible_crtcs = 1; + ret = drm_encoder_init(fsl_dev->drm, encoder, &encoder_funcs, + DRM_MODE_ENCODER_TMDS, NULL); + if (ret) + goto fail_encoder; + + drm_encoder_helper_add(encoder, &encoder_helper_funcs); + encoder->crtc = crtc; + + return 0; + +fail_encoder: + devm_kfree(fsl_dev->dev, encoder); + return ret; +} + +static struct +drm_encoder *fsl_dcu_drm_hdmi_find_encoder(struct drm_device *dev) +{ + struct drm_encoder *encoder; + + list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { + if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) + return encoder; + } + + return NULL; +} + +static struct +device_node *detect_hdmi_connection(struct fsl_dcu_drm_device *fsl_dev) +{ + struct device_node *remote_port; + struct of_endpoint *ep; + struct device_node *ep_node; + int ret; + struct device_node *parent = fsl_dev->dev->of_node; + + ep = devm_kzalloc(fsl_dev->dev, + sizeof(struct of_endpoint), GFP_KERNEL); + if (!ep) + return NULL; + + ep_node = devm_kzalloc(fsl_dev->dev, + sizeof(struct device_node), GFP_KERNEL); + if (!ep_node) + return NULL; + + ep_node = of_graph_get_next_endpoint(parent, NULL); + if (!ep_node) + goto error; + + ret = of_graph_parse_endpoint(ep_node, ep); + if (ret) { + of_node_put(ep_node); + goto error; + } + + remote_port = of_graph_get_remote_port_parent(ep->local_node); + if (!remote_port) + goto error; + + return remote_port; +error: + devm_kfree(ep); + devm_kfree(ep_node); + return NULL; +} + +int fsl_dcu_drm_hdmienc_attach_bridge(struct fsl_dcu_drm_device *fsl_dev) +{ + struct drm_device *drm_dev = fsl_dev->drm; + struct drm_encoder *encoder; + struct drm_bridge *bridge; + struct device_node *remote_port; + int ret; + + remote_port = detect_hdmi_connection(fsl_dev); + if (!remote_port) + return -ENODEV; + + bridge = of_drm_find_bridge(remote_port); + if (!bridge) + return -ENODEV; + + encoder = fsl_dcu_drm_hdmi_find_encoder(drm_dev); + if (!encoder) + return -ENODEV; + + encoder->bridge = bridge; + bridge->encoder = encoder; + + ret = drm_bridge_attach(drm_dev, bridge); + if (ret) + goto error; + + return 0; +error: + encoder->funcs->destroy(encoder); + return ret; +} diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c index c564ec6..658bc92 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c @@ -17,10 +17,18 @@ #include "fsl_dcu_drm_crtc.h" #include "fsl_dcu_drm_drv.h" +static void fsl_dcu_drm_output_poll_changed(struct drm_device *dev) +{ + struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; + + drm_fbdev_cma_hotplug_event(fsl_dev->fbdev); +} + static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = { .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, .fb_create = drm_fb_cma_create, + .output_poll_changed = fsl_dcu_drm_output_poll_changed, }; int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) @@ -47,6 +55,14 @@ int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) if (ret) goto fail_connector; + ret = fsl_dcu_drm_hdmienc_create(fsl_dev, &fsl_dev->crtc); + if (ret) + DRM_ERROR("Failed to create HDMI encoder\n"); + + ret = fsl_dcu_drm_hdmienc_attach_bridge(fsl_dev); + if (ret) + DRM_ERROR("Failed to attach HDMI bridge\n"); + drm_mode_config_reset(fsl_dev->drm); drm_kms_helper_poll_init(fsl_dev->drm); diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_output.h b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_output.h index 7093109..8915b07 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_output.h +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_output.h @@ -29,5 +29,9 @@ int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev, struct drm_encoder *encoder); int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev, struct drm_crtc *crtc); +int fsl_dcu_drm_hdmienc_attach_bridge(struct fsl_dcu_drm_device *fsl_dev); +int fsl_dcu_drm_hdmienc_create(struct fsl_dcu_drm_device *fsl_dev, + struct drm_crtc *crtc); + #endif /* __FSL_DCU_DRM_CONNECTOR_H__ */