From patchwork Fri Jul 8 09:40:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying Liu X-Patchwork-Id: 9220337 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 3C87060572 for ; Fri, 8 Jul 2016 09:41:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A9DA28638 for ; Fri, 8 Jul 2016 09:41:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EE8E2863A; Fri, 8 Jul 2016 09:41:40 +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, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,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 B884028638 for ; Fri, 8 Jul 2016 09:41:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B0D96E0FF; Fri, 8 Jul 2016 09:41:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0065.outbound.protection.outlook.com [104.47.36.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2793D6E188 for ; Fri, 8 Jul 2016 09:41:34 +0000 (UTC) Received: from BN3PR0301CA0038.namprd03.prod.outlook.com (10.160.180.176) by BLUPR0301MB2018.namprd03.prod.outlook.com (10.164.22.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Fri, 8 Jul 2016 09:41:31 +0000 Received: from BL2FFO11FD026.protection.gbl (2a01:111:f400:7c09::167) by BN3PR0301CA0038.outlook.office365.com (2a01:111:e400:4000::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Fri, 8 Jul 2016 09:41:31 +0000 Authentication-Results: spf=softfail (sender IP is 192.88.168.50) smtp.mailfrom=gmail.com; ffwll.ch; dkim=none (message not signed) header.d=none; ffwll.ch; dmarc=fail action=none header.from=gmail.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 192.88.168.50 as permitted sender) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD026.mail.protection.outlook.com (10.173.161.105) with Microsoft SMTP Server (TLS) id 15.1.534.7 via Frontend Transport; Fri, 8 Jul 2016 09:41:30 +0000 Received: from victor.ap.freescale.net (victor.ap.freescale.net [10.192.241.62]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u689fBMs003192; Fri, 8 Jul 2016 02:41:28 -0700 From: Liu Ying To: Subject: [PATCH v4 06/10] drm/imx: Remove encoders' ->prepare callbacks Date: Fri, 8 Jul 2016 17:40:58 +0800 Message-ID: <1467970862-28012-7-git-send-email-gnuiyl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467970862-28012-1-git-send-email-gnuiyl@gmail.com> References: <1467970862-28012-1-git-send-email-gnuiyl@gmail.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131124444911331903; (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)(189002)(199003)(305945005)(87572001)(76482005)(50986999)(97736004)(6260500002)(110136002)(76176999)(50466002)(48376002)(8676002)(106466001)(81156014)(189998001)(77096005)(81166006)(586003)(81442002)(61266001)(50226002)(8936002)(33646002)(5003940100001)(47776003)(5890100001)(73392002)(68736007)(36756003)(11100500001)(229853001)(92566002)(87936001)(4326007)(575784001)(86362001)(104016004)(356003)(2351001)(82202001)(55446002)(6806005)(2950100001)(105596002)(19580405001)(83322999)(19580395003)(7846002)(73972006)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB2018; H:tx30smr01.am.freescale.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD026; 1:ykcaWapEO9YzpJcSMnJsLKP1zUjp5iZAdVH4brTdqgr/QfI+46bu3mya7OJdW3Ro23AbzI4YbCWGHi4k+qZ5VmERBwhMRTYWCvv48n3rWwzyQqZVfKwsCamzQFhkqhSPHmKm/lP6gALOEkrZ0CxBFYXVtMosxIS/GWGI2NoPpNIodsQepeKC7XnLxqN0KCSBhhYJaFjA1w/0kz6Na+tBtjOdgf26SvQJzWamiIMjqiouK9xRoxZMPB+AJaLmQcSSAJ2kH5Z2wRfeR5EvOhGXsDtsJ6/1//OoIvzRWUDAr39WfZr+/5GALk7dcCPLiH7UTBFruyZy5liw1w30WpRTUiZCmQxh9t9o/jM4ym5sEn5rsjfbr6mQPGlNbp0OkwXxzoOvkZvneJGUlf5hCRvnQ/NQNnABGqKm1LCfwjjO+MlA/MhAnU19A5ptMIzKzBf7CeMtXpP4vCjFpu8VxwTOapfhoA+WuBgvhAl4+DBx8CpTsRMLj45ZSjawYGDS9xrsMDtAWp97SX8a/ZIDXmiyqIaZLs1SeWihA0GkpSVzJq2xOK31cMgljI7Z2y0MQNuLCkHTSWeTiTpQ0SzdjJvz9A== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 952fe4a3-bebe-4de2-08de-08d3a7140ac4 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2018; 2:/zWX/yeLz1wlaetJtv3uv3qobCsGY9BVDKRWjwxObIK27upc2/NiJt4qBETwPwQx3Lgh2Vrnbibc6OVadRTodJsJ5+E2l4KXJMGvCq5YbYXjUmhJodm9u4RUTydBRGTWYUmUmND3EQCVXefYMcUZNDmeeu/CxVl45Qx3Hv2wAxRaa5l4bSxaaKi6Kqu99zHc; 3:SqRv4PjELE8SHjrq3gmFP2SfkZuJ3c47Bjch4dxILfgq9hnv/BiS7owYyN1hmF16LXcnMSCLS+7mGC748P+o7F2TULW8tH/refKzqEcXpHr5UinK6txQ4C4C50EjWPCq182hlWtZjwXtoK628GXRRGUCHxst1stSm23001E9ugZBXYb/qHP2cVoBrAPyCLkCHP0HZoy8d7X15OLfTK+87TDuBepdAxEAUsHb7/QmetI=; 25:zuYDMuNL8hY+G7UoYsDN86F8XtsbiSdGG8kGPOehHUqwIDyjXhmad8G76qJ0l/Altsz3e+q0H8jMfY8/IdfaUg3AZMRl4NAOdpH8hdQpioENHUrso5JRifgVm6uVI7Z8um3V/2E31QF+mCG4beXz5AfbOK1IsY5c9fUKf/1TvzUa05qqnx3zJF1EuFC51+oLSm9b5o2Zbwg3qRrX2FM1sw6aa1KXXvJENeJ2dWZVitG/8d3av74v/qG4hKT26ZBPZXS72n/jBVy2ZA3ThXnOaJ1M4Du4PjZOBog79nEroLtxzd6iwZkCNz+ld+WmCbUFHZU6dijISG6XriKt8BrwI7W9mDL65IflmR8ru7ZfF72xDISa+ghRqbNq5JkgWzBrOnouEB7mTJiiqmRS/IpY8CDxS+95mNkTLiolyPd7asU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB2018; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2018; 31:MECyZoDq5aKsKg0Gk4KtVHDAtNNINAxlriLmIxTC6Lurq1NUBW9kVVCSqGkie94ZPrOwAHThP3yrRLf1Oo8czmShYS66xz4KbSJ1FPO7NzxbYxNBvfcGMTOqS+AeM5Z8BwOWD/o+i21KuiruQIGKp/ks6XexvEMHjr3cU7Awi8KLJ9jO+nxbEFzznM/IfPAt+h55jwhXQ4eWJvpjGGpl/w==; 4:ZFZn0c6v1lEVgliujtd28NvhpKc2NW22d7vV4Je650GfX+ykSzKlEyjl6n1jhmg3jXF7XA3y5ur08UhxjSXEWo1iiSrIwI585T8+O86a+abTOB/m8GzJQoNxCl/HHjN5iFxscWxW8rPgyeY1peee5hPIsz6azyyzMHuXFBFGhQP5+X+M/U1rPWjmebG3plATghaS9ZUOZiKds3Rsz7WTsvavoyOXoE9Fy33uhgRxkEF4AXMWiJ8ga/R/8idEFKjcgHgNGO2eXmVEObHFqXhcJYkVD0COUWcYH+Ovnr7/hxKTsDQJ7FkJRAlHth9v/6t/7LcDpglzRhnQqmBf8JbTs0k9yy0j0gY1szGmDW8OM5b9l8s7pnOt8iMhi6KS6Ts1aokZOWen9nJKZdRSGXvLJPbygOWAKyFvWtzcqXoXuI3QtUULz6LJSJH/+sYSWcWkwkuPLuz11GqysnOhAl1MJ3XMBykbDpbmTmab69gGK9d4mJyafjEFaUw1gURuk/UP7AbRtTXT9tb3FFPoWyDvGg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13018025)(13024025)(13015025)(13017025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BLUPR0301MB2018; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR0301MB2018; X-Forefront-PRVS: 0997523C40 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB2018; 23:O7Du5TP0fmEFiWOMz/ICiSEjMMQGq6wB3eBSrrr?= =?us-ascii?Q?y6ixPYVlNWRUksmH54ziZUvZ19R+86q+tCCjOPBu80BghUv7L70xHm2mWMS5?= =?us-ascii?Q?/SgL3PFrQ03ICl05ObQzJMNTmI5ss+hQemr/kTjJI+3g7nWXji34j+WI+9f0?= =?us-ascii?Q?uXaRYTAj2s77qYc9OeHjdGw7Knt6n55X8JxNcQ6Q9aYtgaNlxKettSujcdDo?= =?us-ascii?Q?yS2X5WRN3OUKIt1tn3KRzXi5kFntsAUk/EPk9HS3wx4sA7KI1lD1VMSDGdPF?= =?us-ascii?Q?Dk2X3B5pi0eUlcbd5VSBochB89rJGADGQqRH8eYZp7MH8Hq2S6zH0J5tlVtX?= =?us-ascii?Q?fPTWJ6mgf13+IZnOPBpyq3kDQjXBuZvJiSyAmEM1HGrsW7tcsvUGO8EQ/5h+?= =?us-ascii?Q?KVpHKYmcnpSpFWK5/q2HHZm0cxwqmCjJfxWZ2wPsJHdgYor5RFLENgAzRS+Z?= =?us-ascii?Q?9KWTtOdwHV1wN4ixeF97p5G8ofV9KBGq46gqeFhiyzkjX0pCKH8j45gLTvEc?= =?us-ascii?Q?cKSeyxuyqfjO2RLB+stDrCiiXHNUACYNgdMCW/IZWE2SE3qMg5K9bZsHYjTi?= =?us-ascii?Q?5GqYTiZvYqrt6n6K7Srg/zrDmhf39BTadogi5Wk0Dz/q9xJAhYc83o8968hX?= =?us-ascii?Q?KSRnFeYG3ymwtmQAOf495jVUdgxaAd/XUEe7HCbA3xAYtxI1w00jy0OSnOO/?= =?us-ascii?Q?y49pDZPusEvr48gEWlETdiXFR+EQPzuoj8ensTXLSMKze8RUg9qs+KoFJitb?= =?us-ascii?Q?d2aUn1wz2XL32FBVb2nwCHWVbJp9PbqTg5RxCh7FW9AVJ44+j4iqI7VI2STz?= =?us-ascii?Q?nt6VW6yufvby1y9GYHK3aencubPdA7kw2aqgPVt0BG7FgxOaZqc172mrnlO0?= =?us-ascii?Q?UwnbW+pB/E8i3SH+rE1FJ2UpMoHoGtD7/HdR9nDJsGtiDTiRw3q1abWVqSjm?= =?us-ascii?Q?zwfwBGM+nxpkf0IfNC2wzUFpy6xX/DzQjVsfwaKQdpWyHnjtdaowkaw4QQks?= =?us-ascii?Q?Xti/rKElOOYfYkECCnjYQu3844Lp8cwrO4/k4PCG5VhX6iwcx+0aWexvqPiv?= =?us-ascii?Q?OsRPaQiGSLGcmRMprc9QzHvtNiKv+p/I49a269aonple7O/PhV6MyX2nvAHM?= =?us-ascii?Q?v1cGP5EH2Ri61ZJejJk8jCBaAWE2vkdFOme4ORd4Br8DUY0EbnQ4teiFMNTT?= =?us-ascii?Q?NMQgX1XCzlkwMhuYmU7LMpJFcVdvLRz7/Sj4eShrQd45bXUCGMKclJcLjT+6?= =?us-ascii?Q?KRBTlId0sqQeyy3iLhgiTHuHa+kqAdOZpHLazCNsSj/2VORoyKvOnm+W9A9s?= =?us-ascii?Q?anw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB2018; 6:iwS2xHAxIv3XVYs7RbY5SaXUy3nNR7dC4hYwSK0LP26nMg0YhxK8BeP2XWnlhFBo5j7eYWtRkawO4mjEbCNUKHpN/gDtA3en5uuHMj4LMxQowsCnoK68G8GRmMmdIlmf2tyeig3kxM2pN7vT3gsgIDEfZj7w/fwH4Yy5ATVuG+l6nvtQZE9JG4WiieoEKOA5cldNineHk2Bk+RqJ3uvqE17820hx3TyqW1q4Al7cCKtg5r4C/wOdINZ9LXloSDdxaKmME8JmOmNk3/PZ28im8Jtrdnq1h1oX5dbhgDh8ZNs=; 5:eV4hBNAUDfFy+ZDNvKJrYJ9dmxMMmBgL6J8zjH7xUHy3Lr1/ps2g3r0tER6ZUx3GaQ8M+ZiprsA8Yyv9eXMxLadJLO9Qs8Wug9TF1ArIWkfkKgUEsktyTBPuTFfdAIxfGA1zPyERgqGCsB4imhjO+Fjz6txkddU3o6/vJLhRIBg=; 24:SHQYtfAG0Oz+yOw54FsJPbVl9ssOFyZYHxk0LlnYlRN+DCgYAeh7hMfDobyWoQaWuLoWUij8QrQHnpm+iqzkYndxLDO6HavPBXR3PYUWr1Y=; 7:9ftAGvcRxGfweKTCIkB4JZKvilsmghrhNdoSM+XPI4W7nT4UlNhU2nqIEFjWx3tBNJoPvwvxdiPkyW2MIG8YZi2tcYlE/MBJDRGZ1dE21PTvX9CLwZDbRPpb4q3ZntnPlDGM0/JkVbJF1JoNEtzZERTTlUizSp4ltS/t+MxCNl+Cdq2giYmfD4elTW1e0rsgoseoDchs75uAk4nbV2eQHc1TIG3D6yvuJMZyymEtm4FcGdE7xLb4AEYAklXEMLxp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2016 09:41:30.9459 (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: BLUPR0301MB2018 Cc: Russell King , Daniel Vetter 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 The main task of imx encoders' ->prepare callbacks is to set bus_format, bus_flags, di_vsync_pin and di_hsync_pin. We may create a structure named imx_encoder to cache them. The atomic encoder callback ->disable may replace ->prepare later, so let's remove ->prepare. Signed-off-by: Liu Ying --- v3->v4: * Fix wrong LVDS bus format translation issue in imx_ldb_connector_get_modes() so that bus format could be determined by panel instead of device tree. This issue was found by Philipp Zabel. v2->v3: * Newly introduced. The logic is picked from patch 07/10 in v2 to generate a self-contained patch. drivers/gpu/drm/imx/dw_hdmi-imx.c | 18 ++--- drivers/gpu/drm/imx/imx-drm-core.c | 39 ----------- drivers/gpu/drm/imx/imx-drm.h | 18 ++--- drivers/gpu/drm/imx/imx-ldb.c | 118 +++++++++++++++++---------------- drivers/gpu/drm/imx/imx-tve.c | 58 ++++++---------- drivers/gpu/drm/imx/ipuv3-crtc.c | 38 ++++------- drivers/gpu/drm/imx/parallel-display.c | 56 ++++++++-------- 7 files changed, 142 insertions(+), 203 deletions(-) diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c index a24631fd..5f64674 100644 --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c @@ -22,9 +22,11 @@ #include "imx-drm.h" +#define imx_enc_to_imx_hdmi(x) container_of(x, struct imx_hdmi, imx_encoder) + struct imx_hdmi { struct device *dev; - struct drm_encoder encoder; + struct imx_drm_encoder imx_encoder; struct regmap *regmap; }; @@ -117,7 +119,8 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder, static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder) { - struct imx_hdmi *hdmi = container_of(encoder, struct imx_hdmi, encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_hdmi *hdmi = imx_enc_to_imx_hdmi(imx_encoder); int mux = drm_of_encoder_active_port_id(hdmi->dev->of_node, encoder); regmap_update_bits(hdmi->regmap, IOMUXC_GPR3, @@ -125,14 +128,8 @@ static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder) mux << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT); } -static void dw_hdmi_imx_encoder_prepare(struct drm_encoder *encoder) -{ - imx_drm_set_bus_format(encoder, MEDIA_BUS_FMT_RGB888_1X24); -} - static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = { .mode_set = dw_hdmi_imx_encoder_mode_set, - .prepare = dw_hdmi_imx_encoder_prepare, .commit = dw_hdmi_imx_encoder_commit, .disable = dw_hdmi_imx_encoder_disable, }; @@ -215,7 +212,10 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master, match = of_match_node(dw_hdmi_imx_dt_ids, pdev->dev.of_node); plat_data = match->data; hdmi->dev = &pdev->dev; - encoder = &hdmi->encoder; + encoder = &hdmi->imx_encoder.encoder; + hdmi->imx_encoder.bus_format = MEDIA_BUS_FMT_RGB888_1X24; + hdmi->imx_encoder.di_hsync_pin = 2; + hdmi->imx_encoder.di_vsync_pin = 3; irq = platform_get_irq(pdev, 0); if (irq < 0) diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index b5a5173..f6e44c2 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c @@ -85,45 +85,6 @@ static int imx_drm_driver_unload(struct drm_device *drm) return 0; } -static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc) -{ - struct imx_drm_device *imxdrm = crtc->dev->dev_private; - unsigned i; - - for (i = 0; i < MAX_CRTC; i++) - if (imxdrm->crtc[i] && imxdrm->crtc[i]->crtc == crtc) - return imxdrm->crtc[i]; - - return NULL; -} - -int imx_drm_set_bus_config(struct drm_encoder *encoder, u32 bus_format, - int hsync_pin, int vsync_pin, u32 bus_flags) -{ - struct imx_drm_crtc_helper_funcs *helper; - struct imx_drm_crtc *imx_crtc; - - imx_crtc = imx_drm_find_crtc(encoder->crtc); - if (!imx_crtc) - return -EINVAL; - - helper = &imx_crtc->imx_drm_helper_funcs; - if (helper->set_interface_pix_fmt) - return helper->set_interface_pix_fmt(encoder->crtc, - bus_format, hsync_pin, vsync_pin, - bus_flags); - return 0; -} -EXPORT_SYMBOL_GPL(imx_drm_set_bus_config); - -int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format) -{ - return imx_drm_set_bus_config(encoder, bus_format, 2, 3, - DRM_BUS_FLAG_DE_HIGH | - DRM_BUS_FLAG_PIXDATA_NEGEDGE); -} -EXPORT_SYMBOL_GPL(imx_drm_set_bus_format); - int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc) { return drm_crtc_vblank_get(imx_drm_crtc->crtc); diff --git a/drivers/gpu/drm/imx/imx-drm.h b/drivers/gpu/drm/imx/imx-drm.h index 74320a1..39cef15 100644 --- a/drivers/gpu/drm/imx/imx-drm.h +++ b/drivers/gpu/drm/imx/imx-drm.h @@ -15,12 +15,19 @@ struct platform_device; unsigned int imx_drm_crtc_id(struct imx_drm_crtc *crtc); +struct imx_drm_encoder { + struct drm_encoder encoder; + u32 bus_format; + u32 bus_flags; + int di_hsync_pin; + int di_vsync_pin; +}; + +#define enc_to_imx_enc(x) container_of(x, struct imx_drm_encoder, encoder) + struct imx_drm_crtc_helper_funcs { int (*enable_vblank)(struct drm_crtc *crtc); void (*disable_vblank)(struct drm_crtc *crtc); - int (*set_interface_pix_fmt)(struct drm_crtc *crtc, - u32 bus_format, int hsync_pin, int vsync_pin, - u32 bus_flags); const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; }; @@ -42,11 +49,6 @@ void imx_drm_mode_config_init(struct drm_device *drm); struct drm_gem_cma_object *imx_drm_fb_get_obj(struct drm_framebuffer *fb); -int imx_drm_set_bus_config(struct drm_encoder *encoder, u32 bus_format, - int hsync_pin, int vsync_pin, u32 bus_flags); -int imx_drm_set_bus_format(struct drm_encoder *encoder, - u32 bus_format); - int imx_drm_encoder_parse_of(struct drm_device *drm, struct drm_encoder *encoder, struct device_node *np); diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c index 12bf368..6e110bb 100644 --- a/drivers/gpu/drm/imx/imx-ldb.c +++ b/drivers/gpu/drm/imx/imx-ldb.c @@ -51,14 +51,15 @@ #define LDB_BGREF_RMODE_INT (1 << 15) #define con_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, connector) -#define enc_to_imx_ldb_ch(x) container_of(x, struct imx_ldb_channel, encoder) +#define imx_enc_to_imx_ldb_ch(x) \ + container_of(x, struct imx_ldb_channel, imx_encoder) struct imx_ldb; struct imx_ldb_channel { struct imx_ldb *ldb; struct drm_connector connector; - struct drm_encoder encoder; + struct imx_drm_encoder imx_encoder; struct drm_panel *panel; struct device_node *child; struct i2c_adapter *ddc; @@ -67,7 +68,6 @@ struct imx_ldb_channel { int edid_len; struct drm_display_mode mode; int mode_valid; - int bus_format; }; struct bus_mux { @@ -94,6 +94,35 @@ static enum drm_connector_status imx_ldb_connector_detect( return connector_status_connected; } +static void imx_ldb_bus_format_translation(struct imx_ldb_channel *imx_ldb_ch, + u32 bus_format) +{ + struct imx_ldb *ldb = imx_ldb_ch->ldb; + int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; + + switch (bus_format) { + case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG: + imx_ldb_ch->imx_encoder.bus_format = MEDIA_BUS_FMT_RGB666_1X18; + break; + case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG: + imx_ldb_ch->imx_encoder.bus_format = MEDIA_BUS_FMT_RGB888_1X24; + if (imx_ldb_ch->chno == 0 || dual) + ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24; + if (imx_ldb_ch->chno == 1 || dual) + ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24; + break; + case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA: + imx_ldb_ch->imx_encoder.bus_format = MEDIA_BUS_FMT_RGB888_1X24; + if (imx_ldb_ch->chno == 0 || dual) + ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 | + LDB_BIT_MAP_CH0_JEIDA; + if (imx_ldb_ch->chno == 1 || dual) + ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 | + LDB_BIT_MAP_CH1_JEIDA; + break; + } +} + static int imx_ldb_connector_get_modes(struct drm_connector *connector) { struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector); @@ -104,8 +133,9 @@ static int imx_ldb_connector_get_modes(struct drm_connector *connector) struct drm_display_info *di = &connector->display_info; num_modes = imx_ldb_ch->panel->funcs->get_modes(imx_ldb_ch->panel); - if (!imx_ldb_ch->bus_format && di->num_bus_formats) - imx_ldb_ch->bus_format = di->bus_formats[0]; + if (!imx_ldb_ch->imx_encoder.bus_format && di->num_bus_formats) + imx_ldb_bus_format_translation(imx_ldb_ch, + di->bus_formats[0]); if (num_modes > 0) return num_modes; } @@ -139,7 +169,7 @@ static struct drm_encoder *imx_ldb_connector_best_encoder( { struct imx_ldb_channel *imx_ldb_ch = con_to_imx_ldb_ch(connector); - return &imx_ldb_ch->encoder; + return &imx_ldb_ch->imx_encoder.encoder; } static void imx_ldb_encoder_dpms(struct drm_encoder *encoder, int mode) @@ -174,45 +204,10 @@ static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno, chno); } -static void imx_ldb_encoder_prepare(struct drm_encoder *encoder) -{ - struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); - struct imx_ldb *ldb = imx_ldb_ch->ldb; - int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; - u32 bus_format; - - switch (imx_ldb_ch->bus_format) { - default: - dev_warn(ldb->dev, - "could not determine data mapping, default to 18-bit \"spwg\"\n"); - /* fallthrough */ - case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG: - bus_format = MEDIA_BUS_FMT_RGB666_1X18; - break; - case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG: - bus_format = MEDIA_BUS_FMT_RGB888_1X24; - if (imx_ldb_ch->chno == 0 || dual) - ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24; - if (imx_ldb_ch->chno == 1 || dual) - ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24; - break; - case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA: - bus_format = MEDIA_BUS_FMT_RGB888_1X24; - if (imx_ldb_ch->chno == 0 || dual) - ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 | - LDB_BIT_MAP_CH0_JEIDA; - if (imx_ldb_ch->chno == 1 || dual) - ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 | - LDB_BIT_MAP_CH1_JEIDA; - break; - } - - imx_drm_set_bus_format(encoder, bus_format); -} - static void imx_ldb_encoder_commit(struct drm_encoder *encoder) { - struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_ldb_channel *imx_ldb_ch = imx_enc_to_imx_ldb_ch(imx_encoder); struct imx_ldb *ldb = imx_ldb_ch->ldb; int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder); @@ -260,7 +255,8 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder, struct drm_display_mode *orig_mode, struct drm_display_mode *mode) { - struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_ldb_channel *imx_ldb_ch = imx_enc_to_imx_ldb_ch(imx_encoder); struct imx_ldb *ldb = imx_ldb_ch->ldb; int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN; unsigned long serial_clk; @@ -303,7 +299,8 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder, static void imx_ldb_encoder_disable(struct drm_encoder *encoder) { - struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_ldb_channel *imx_ldb_ch = imx_enc_to_imx_ldb_ch(imx_encoder); struct imx_ldb *ldb = imx_ldb_ch->ldb; int mux, ret; @@ -379,7 +376,6 @@ static const struct drm_encoder_funcs imx_ldb_encoder_funcs = { static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { .dpms = imx_ldb_encoder_dpms, - .prepare = imx_ldb_encoder_prepare, .commit = imx_ldb_encoder_commit, .mode_set = imx_ldb_encoder_mode_set, .disable = imx_ldb_encoder_disable, @@ -406,7 +402,7 @@ static int imx_ldb_register(struct drm_device *drm, struct imx_ldb *ldb = imx_ldb_ch->ldb; int ret; - ret = imx_drm_encoder_parse_of(drm, &imx_ldb_ch->encoder, + ret = imx_drm_encoder_parse_of(drm, &imx_ldb_ch->imx_encoder.encoder, imx_ldb_ch->child); if (ret) return ret; @@ -421,10 +417,10 @@ static int imx_ldb_register(struct drm_device *drm, return ret; } - drm_encoder_helper_add(&imx_ldb_ch->encoder, + drm_encoder_helper_add(&imx_ldb_ch->imx_encoder.encoder, &imx_ldb_encoder_helper_funcs); - drm_encoder_init(drm, &imx_ldb_ch->encoder, &imx_ldb_encoder_funcs, - DRM_MODE_ENCODER_LVDS, NULL); + drm_encoder_init(drm, &imx_ldb_ch->imx_encoder.encoder, + &imx_ldb_encoder_funcs, DRM_MODE_ENCODER_LVDS, NULL); drm_connector_helper_add(&imx_ldb_ch->connector, &imx_ldb_connector_helper_funcs); @@ -435,7 +431,7 @@ static int imx_ldb_register(struct drm_device *drm, drm_panel_attach(imx_ldb_ch->panel, &imx_ldb_ch->connector); drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, - &imx_ldb_ch->encoder); + &imx_ldb_ch->imx_encoder.encoder); return 0; } @@ -564,6 +560,7 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) struct imx_ldb_channel *channel; struct device_node *ddc_node; struct device_node *ep; + int bus_format; ret = of_property_read_u32(child, "reg", &i); if (ret || i < 0 || i > 1) @@ -636,21 +633,25 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) } } - channel->bus_format = of_get_bus_format(dev, child); - if (channel->bus_format == -EINVAL) { + bus_format = of_get_bus_format(dev, child); + if (bus_format == -EINVAL) { /* * If no bus format was specified in the device tree, * we can still get it from the connected panel later. */ if (channel->panel && channel->panel->funcs && channel->panel->funcs->get_modes) - channel->bus_format = 0; + bus_format = 0; } - if (channel->bus_format < 0) { + if (bus_format < 0) { dev_err(dev, "could not determine data mapping: %d\n", - channel->bus_format); - return channel->bus_format; + bus_format); + return bus_format; } + imx_ldb_bus_format_translation(channel, bus_format); + + channel->imx_encoder.di_hsync_pin = 2; + channel->imx_encoder.di_vsync_pin = 3; ret = imx_ldb_register(drm, channel); if (ret) @@ -675,7 +676,8 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, continue; channel->connector.funcs->destroy(&channel->connector); - channel->encoder.funcs->destroy(&channel->encoder); + channel->imx_encoder.encoder.funcs->destroy( + &channel->imx_encoder.encoder); kfree(channel->edid); i2c_put_adapter(channel->ddc); diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c index 0b0aeee..82a1edd 100644 --- a/drivers/gpu/drm/imx/imx-tve.c +++ b/drivers/gpu/drm/imx/imx-tve.c @@ -99,7 +99,7 @@ #define TVE_TVDAC_TEST_MODE_MASK (0x7 << 0) #define con_to_tve(x) container_of(x, struct imx_tve, connector) -#define enc_to_tve(x) container_of(x, struct imx_tve, encoder) +#define imx_enc_to_tve(x) container_of(x, struct imx_tve, imx_encoder) enum { TVE_MODE_TVOUT, @@ -108,7 +108,7 @@ enum { struct imx_tve { struct drm_connector connector; - struct drm_encoder encoder; + struct imx_drm_encoder imx_encoder; struct device *dev; spinlock_t lock; /* register lock */ bool enabled; @@ -121,8 +121,6 @@ struct imx_tve { struct clk *di_sel_clk; struct clk_hw clk_hw_di; struct clk *di_clk; - int vsync_pin; - int hsync_pin; }; static void tve_lock(void *__tve) @@ -273,12 +271,13 @@ static struct drm_encoder *imx_tve_connector_best_encoder( { struct imx_tve *tve = con_to_tve(connector); - return &tve->encoder; + return &tve->imx_encoder.encoder; } static void imx_tve_encoder_dpms(struct drm_encoder *encoder, int mode) { - struct imx_tve *tve = enc_to_tve(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_tve *tve = imx_enc_to_tve(imx_encoder); int ret; ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, @@ -287,30 +286,12 @@ static void imx_tve_encoder_dpms(struct drm_encoder *encoder, int mode) dev_err(tve->dev, "failed to disable TVOUT: %d\n", ret); } -static void imx_tve_encoder_prepare(struct drm_encoder *encoder) -{ - struct imx_tve *tve = enc_to_tve(encoder); - - tve_disable(tve); - - switch (tve->mode) { - case TVE_MODE_VGA: - imx_drm_set_bus_config(encoder, MEDIA_BUS_FMT_GBR888_1X24, - tve->hsync_pin, tve->vsync_pin, - DRM_BUS_FLAG_DE_HIGH | - DRM_BUS_FLAG_PIXDATA_NEGEDGE); - break; - case TVE_MODE_TVOUT: - imx_drm_set_bus_format(encoder, MEDIA_BUS_FMT_YUV8_1X24); - break; - } -} - static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, struct drm_display_mode *orig_mode, struct drm_display_mode *mode) { - struct imx_tve *tve = enc_to_tve(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_tve *tve = imx_enc_to_tve(imx_encoder); unsigned long rounded_rate; unsigned long rate; int div = 1; @@ -344,14 +325,16 @@ static void imx_tve_encoder_mode_set(struct drm_encoder *encoder, static void imx_tve_encoder_commit(struct drm_encoder *encoder) { - struct imx_tve *tve = enc_to_tve(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_tve *tve = imx_enc_to_tve(imx_encoder); tve_enable(tve); } static void imx_tve_encoder_disable(struct drm_encoder *encoder) { - struct imx_tve *tve = enc_to_tve(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_tve *tve = imx_enc_to_tve(imx_encoder); tve_disable(tve); } @@ -378,7 +361,6 @@ static const struct drm_encoder_funcs imx_tve_encoder_funcs = { static const struct drm_encoder_helper_funcs imx_tve_encoder_helper_funcs = { .dpms = imx_tve_encoder_dpms, - .prepare = imx_tve_encoder_prepare, .mode_set = imx_tve_encoder_mode_set, .commit = imx_tve_encoder_commit, .disable = imx_tve_encoder_disable, @@ -499,13 +481,14 @@ static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve) encoder_type = tve->mode == TVE_MODE_VGA ? DRM_MODE_ENCODER_DAC : DRM_MODE_ENCODER_TVDAC; - ret = imx_drm_encoder_parse_of(drm, &tve->encoder, + ret = imx_drm_encoder_parse_of(drm, &tve->imx_encoder.encoder, tve->dev->of_node); if (ret) return ret; - drm_encoder_helper_add(&tve->encoder, &imx_tve_encoder_helper_funcs); - drm_encoder_init(drm, &tve->encoder, &imx_tve_encoder_funcs, + drm_encoder_helper_add(&tve->imx_encoder.encoder, + &imx_tve_encoder_helper_funcs); + drm_encoder_init(drm, &tve->imx_encoder.encoder, &imx_tve_encoder_funcs, encoder_type, NULL); drm_connector_helper_add(&tve->connector, @@ -513,7 +496,8 @@ static int imx_tve_register(struct drm_device *drm, struct imx_tve *tve) drm_connector_init(drm, &tve->connector, &imx_tve_connector_funcs, DRM_MODE_CONNECTOR_VGA); - drm_mode_connector_attach_encoder(&tve->connector, &tve->encoder); + drm_mode_connector_attach_encoder(&tve->connector, + &tve->imx_encoder.encoder); return 0; } @@ -591,7 +575,7 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) if (tve->mode == TVE_MODE_VGA) { ret = of_property_read_u32(np, "fsl,hsync-pin", - &tve->hsync_pin); + &tve->imx_encoder.di_hsync_pin); if (ret < 0) { dev_err(dev, "failed to get vsync pin\n"); @@ -599,12 +583,14 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) } ret |= of_property_read_u32(np, "fsl,vsync-pin", - &tve->vsync_pin); + &tve->imx_encoder.di_vsync_pin); if (ret < 0) { dev_err(dev, "failed to get vsync pin\n"); return ret; } + + tve->imx_encoder.bus_format = MEDIA_BUS_FMT_GBR888_1X24; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -693,7 +679,7 @@ static void imx_tve_unbind(struct device *dev, struct device *master, struct imx_tve *tve = dev_get_drvdata(dev); tve->connector.funcs->destroy(&tve->connector); - tve->encoder.funcs->destroy(&tve->encoder); + tve->imx_encoder.encoder.funcs->destroy(&tve->imx_encoder.encoder); if (!IS_ERR(tve->dac_reg)) regulator_disable(tve->dac_reg); diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c index 7df51e8..f9d5d7c 100644 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c @@ -67,10 +67,6 @@ struct ipu_crtc { struct workqueue_struct *flip_queue; struct ipu_flip_work *flip_work; int irq; - u32 bus_format; - u32 bus_flags; - int di_hsync_pin; - int di_vsync_pin; }; #define to_ipu_crtc(x) container_of(x, struct ipu_crtc, base) @@ -321,6 +317,7 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; struct drm_encoder *encoder; + struct imx_drm_encoder *imx_encoder = NULL; struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); struct drm_display_mode *mode = &crtc->state->adjusted_mode; struct ipu_di_signal_cfg sig_cfg = {}; @@ -331,9 +328,12 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) dev_dbg(ipu_crtc->dev, "%s: mode->vdisplay: %d\n", __func__, mode->vdisplay); - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) - if (encoder->crtc == crtc) + list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { + if (encoder->crtc == crtc) { encoder_types |= BIT(encoder->encoder_type); + imx_encoder = enc_to_imx_enc(encoder); + } + } dev_dbg(ipu_crtc->dev, "%s: attached to encoder types 0x%lx\n", __func__, encoder_types); @@ -351,20 +351,20 @@ static void ipu_crtc_mode_set_nofb(struct drm_crtc *crtc) else sig_cfg.clkflags = 0; - sig_cfg.enable_pol = !(ipu_crtc->bus_flags & DRM_BUS_FLAG_DE_LOW); + sig_cfg.enable_pol = !(imx_encoder->bus_flags & DRM_BUS_FLAG_DE_LOW); /* Default to driving pixel data on negative clock edges */ - sig_cfg.clk_pol = !!(ipu_crtc->bus_flags & + sig_cfg.clk_pol = !!(imx_encoder->bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE); - sig_cfg.bus_format = ipu_crtc->bus_format; + sig_cfg.bus_format = imx_encoder->bus_format; sig_cfg.v_to_h_sync = 0; - sig_cfg.hsync_pin = ipu_crtc->di_hsync_pin; - sig_cfg.vsync_pin = ipu_crtc->di_vsync_pin; + sig_cfg.hsync_pin = imx_encoder->di_hsync_pin; + sig_cfg.vsync_pin = imx_encoder->di_vsync_pin; drm_display_mode_to_videomode(mode, &sig_cfg.mode); ipu_dc_init_sync(ipu_crtc->dc, ipu_crtc->di, mode->flags & DRM_MODE_FLAG_INTERLACE, - ipu_crtc->bus_format, mode->hdisplay); + imx_encoder->bus_format, mode->hdisplay); ipu_di_init_sync_panel(ipu_crtc->di, &sig_cfg); } @@ -402,23 +402,9 @@ static void ipu_disable_vblank(struct drm_crtc *crtc) disable_irq_nosync(ipu_crtc->irq); } -static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc, - u32 bus_format, int hsync_pin, int vsync_pin, u32 bus_flags) -{ - struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); - - ipu_crtc->bus_format = bus_format; - ipu_crtc->bus_flags = bus_flags; - ipu_crtc->di_hsync_pin = hsync_pin; - ipu_crtc->di_vsync_pin = vsync_pin; - - return 0; -} - static const struct imx_drm_crtc_helper_funcs ipu_crtc_helper_funcs = { .enable_vblank = ipu_enable_vblank, .disable_vblank = ipu_disable_vblank, - .set_interface_pix_fmt = ipu_set_interface_pix_fmt, .crtc_funcs = &ipu_crtc_funcs, .crtc_helper_funcs = &ipu_helper_funcs, }; diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c index 9fe88c9..7374d82 100644 --- a/drivers/gpu/drm/imx/parallel-display.c +++ b/drivers/gpu/drm/imx/parallel-display.c @@ -27,15 +27,15 @@ #include "imx-drm.h" #define con_to_imxpd(x) container_of(x, struct imx_parallel_display, connector) -#define enc_to_imxpd(x) container_of(x, struct imx_parallel_display, encoder) +#define imx_enc_to_imxpd(x) \ + container_of(x, struct imx_parallel_display, imx_encoder) struct imx_parallel_display { struct drm_connector connector; - struct drm_encoder encoder; + struct imx_drm_encoder imx_encoder; struct device *dev; void *edid; int edid_len; - u32 bus_format; struct drm_display_mode mode; struct drm_panel *panel; }; @@ -57,8 +57,9 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) struct drm_display_info *di = &connector->display_info; num_modes = imxpd->panel->funcs->get_modes(imxpd->panel); - if (!imxpd->bus_format && di->num_bus_formats) - imxpd->bus_format = di->bus_formats[0]; + if (!imxpd->imx_encoder.bus_format && di->num_bus_formats) + imxpd->imx_encoder.bus_format = di->bus_formats[0]; + imxpd->imx_encoder.bus_flags = di->bus_flags; if (num_modes > 0) return num_modes; } @@ -88,12 +89,13 @@ static struct drm_encoder *imx_pd_connector_best_encoder( { struct imx_parallel_display *imxpd = con_to_imxpd(connector); - return &imxpd->encoder; + return &imxpd->imx_encoder.encoder; } static void imx_pd_encoder_dpms(struct drm_encoder *encoder, int mode) { - struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder); if (mode != DRM_MODE_DPMS_ON) drm_panel_disable(imxpd->panel); @@ -101,16 +103,10 @@ static void imx_pd_encoder_dpms(struct drm_encoder *encoder, int mode) drm_panel_enable(imxpd->panel); } -static void imx_pd_encoder_prepare(struct drm_encoder *encoder) -{ - struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); - imx_drm_set_bus_config(encoder, imxpd->bus_format, 2, 3, - imxpd->connector.display_info.bus_flags); -} - static void imx_pd_encoder_commit(struct drm_encoder *encoder) { - struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder); drm_panel_prepare(imxpd->panel); drm_panel_enable(imxpd->panel); @@ -124,7 +120,8 @@ static void imx_pd_encoder_mode_set(struct drm_encoder *encoder, static void imx_pd_encoder_disable(struct drm_encoder *encoder) { - struct imx_parallel_display *imxpd = enc_to_imxpd(encoder); + struct imx_drm_encoder *imx_encoder = enc_to_imx_enc(encoder); + struct imx_parallel_display *imxpd = imx_enc_to_imxpd(imx_encoder); drm_panel_disable(imxpd->panel); drm_panel_unprepare(imxpd->panel); @@ -151,7 +148,6 @@ static const struct drm_encoder_funcs imx_pd_encoder_funcs = { static const struct drm_encoder_helper_funcs imx_pd_encoder_helper_funcs = { .dpms = imx_pd_encoder_dpms, - .prepare = imx_pd_encoder_prepare, .commit = imx_pd_encoder_commit, .mode_set = imx_pd_encoder_mode_set, .disable = imx_pd_encoder_disable, @@ -162,7 +158,7 @@ static int imx_pd_register(struct drm_device *drm, { int ret; - ret = imx_drm_encoder_parse_of(drm, &imxpd->encoder, + ret = imx_drm_encoder_parse_of(drm, &imxpd->imx_encoder.encoder, imxpd->dev->of_node); if (ret) return ret; @@ -174,9 +170,10 @@ static int imx_pd_register(struct drm_device *drm, */ imxpd->connector.dpms = DRM_MODE_DPMS_OFF; - drm_encoder_helper_add(&imxpd->encoder, &imx_pd_encoder_helper_funcs); - drm_encoder_init(drm, &imxpd->encoder, &imx_pd_encoder_funcs, - DRM_MODE_ENCODER_NONE, NULL); + drm_encoder_helper_add(&imxpd->imx_encoder.encoder, + &imx_pd_encoder_helper_funcs); + drm_encoder_init(drm, &imxpd->imx_encoder.encoder, + &imx_pd_encoder_funcs, DRM_MODE_ENCODER_NONE, NULL); drm_connector_helper_add(&imxpd->connector, &imx_pd_connector_helper_funcs); @@ -186,7 +183,8 @@ static int imx_pd_register(struct drm_device *drm, if (imxpd->panel) drm_panel_attach(imxpd->panel, &imxpd->connector); - drm_mode_connector_attach_encoder(&imxpd->connector, &imxpd->encoder); + drm_mode_connector_attach_encoder(&imxpd->connector, + &imxpd->imx_encoder.encoder); return 0; } @@ -199,6 +197,7 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) const u8 *edidp; struct imx_parallel_display *imxpd; int ret; + u32 bus_format = 0; const char *fmt; imxpd = devm_kzalloc(dev, sizeof(*imxpd), GFP_KERNEL); @@ -212,14 +211,17 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) ret = of_property_read_string(np, "interface-pix-fmt", &fmt); if (!ret) { if (!strcmp(fmt, "rgb24")) - imxpd->bus_format = MEDIA_BUS_FMT_RGB888_1X24; + bus_format = MEDIA_BUS_FMT_RGB888_1X24; else if (!strcmp(fmt, "rgb565")) - imxpd->bus_format = MEDIA_BUS_FMT_RGB565_1X16; + bus_format = MEDIA_BUS_FMT_RGB565_1X16; else if (!strcmp(fmt, "bgr666")) - imxpd->bus_format = MEDIA_BUS_FMT_RGB666_1X18; + bus_format = MEDIA_BUS_FMT_RGB666_1X18; else if (!strcmp(fmt, "lvds666")) - imxpd->bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI; + bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI; } + imxpd->imx_encoder.bus_format = bus_format; + imxpd->imx_encoder.di_hsync_pin = 2; + imxpd->imx_encoder.di_vsync_pin = 3; /* port@1 is the output port */ ep = of_graph_get_endpoint_by_regs(np, 1, -1); @@ -252,7 +254,7 @@ static void imx_pd_unbind(struct device *dev, struct device *master, { struct imx_parallel_display *imxpd = dev_get_drvdata(dev); - imxpd->encoder.funcs->destroy(&imxpd->encoder); + imxpd->imx_encoder.encoder.funcs->destroy(&imxpd->imx_encoder.encoder); imxpd->connector.funcs->destroy(&imxpd->connector); kfree(imxpd->edid);