From patchwork Mon Feb 24 23:20:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 971C6C38C02 for ; Mon, 24 Feb 2020 23:21:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 778DD20732 for ; Mon, 24 Feb 2020 23:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728461AbgBXXVg (ORCPT ); Mon, 24 Feb 2020 18:21:36 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59764 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728445AbgBXXVf (ORCPT ); Mon, 24 Feb 2020 18:21:35 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 39E76291458 Received: by earth.universe (Postfix, from userid 1000) id 9489E3C0C84; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 01/56] ARM: dts: omap: add channel to DSI panels Date: Tue, 25 Feb 2020 00:20:31 +0100 Message-Id: <20200224232126.3385250-2-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The standard binding for DSI requires, that the channel number of the panel is encoded in DT. This adds the channel number in all OMAP3-5 boards, in preparation for using common infrastructure. Signed-off-by: Sebastian Reichel --- .../devicetree/bindings/display/panel/panel-dsi-cm.txt | 4 +++- arch/arm/boot/dts/motorola-mapphone-common.dtsi | 3 ++- arch/arm/boot/dts/omap3-n950.dts | 3 ++- arch/arm/boot/dts/omap3.dtsi | 3 +++ arch/arm/boot/dts/omap4-sdp.dts | 6 ++++-- arch/arm/boot/dts/omap4.dtsi | 6 ++++++ arch/arm/boot/dts/omap5.dtsi | 6 ++++++ 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt index dce48eb9db57..f92d5c9adfc5 100644 --- a/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt +++ b/Documentation/devicetree/bindings/display/panel/panel-dsi-cm.txt @@ -3,6 +3,7 @@ Generic MIPI DSI Command Mode Panel Required properties: - compatible: "panel-dsi-cm" +- reg: DSI channel number Optional properties: - label: a symbolic name for the panel @@ -15,9 +16,10 @@ Required nodes: Example ------- -lcd0: display { +lcd0: panel@0 { compatible = "tpo,taal", "panel-dsi-cm"; label = "lcd0"; + reg = <0>; reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>; diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi index 85665506f4f8..a5e4ba7c8dab 100644 --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi @@ -199,8 +199,9 @@ dsi1_out_ep: endpoint { }; }; - lcd0: display { + lcd0: panel@0 { compatible = "panel-dsi-cm"; + reg = <0>; label = "lcd0"; vddi-supply = <&lcd_regulator>; reset-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>; /* gpio101 */ diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts index 31d47a1fad84..80cf4e1177da 100644 --- a/arch/arm/boot/dts/omap3-n950.dts +++ b/arch/arm/boot/dts/omap3-n950.dts @@ -225,8 +225,9 @@ dsi_out_ep: endpoint { }; }; - lcd0: display { + lcd0: panel@0 { compatible = "nokia,himalaya", "panel-dsi-cm"; + reg = <0>; label = "lcd0"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi index 634ea16a711e..409d434a9b18 100644 --- a/arch/arm/boot/dts/omap3.dtsi +++ b/arch/arm/boot/dts/omap3.dtsi @@ -820,6 +820,9 @@ dsi: encoder@4804fc00 { ti,hwmods = "dss_dsi1"; clocks = <&dss1_alwon_fck>, <&dss2_alwon_fck>; clock-names = "fck", "sys_clk"; + + #address-cells = <1>; + #size-cells = <0>; }; rfbi: encoder@48050800 { diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts index 91480ac1f328..8a8307517dab 100644 --- a/arch/arm/boot/dts/omap4-sdp.dts +++ b/arch/arm/boot/dts/omap4-sdp.dts @@ -662,8 +662,9 @@ dsi1_out_ep: endpoint { }; }; - lcd0: display { + lcd0: panel@0 { compatible = "tpo,taal", "panel-dsi-cm"; + reg = <0>; label = "lcd0"; reset-gpios = <&gpio4 6 GPIO_ACTIVE_HIGH>; /* 102 */ @@ -687,8 +688,9 @@ dsi2_out_ep: endpoint { }; }; - lcd1: display { + lcd1: panel@0 { compatible = "tpo,taal", "panel-dsi-cm"; + reg = <0>; label = "lcd1"; reset-gpios = <&gpio4 8 GPIO_ACTIVE_HIGH>; /* 104 */ diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi index 9a87440d0b9d..a75734065cac 100644 --- a/arch/arm/boot/dts/omap4.dtsi +++ b/arch/arm/boot/dts/omap4.dtsi @@ -465,6 +465,9 @@ dsi1: encoder@58004000 { clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>, <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>; clock-names = "fck", "sys_clk"; + + #address-cells = <1>; + #size-cells = <0>; }; dsi2: encoder@58005000 { @@ -479,6 +482,9 @@ dsi2: encoder@58005000 { clocks = <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 8>, <&l3_dss_clkctrl OMAP4_DSS_CORE_CLKCTRL 10>; clock-names = "fck", "sys_clk"; + + #address-cells = <1>; + #size-cells = <0>; }; hdmi: encoder@58006000 { diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi index d0ecf54d5a23..5c7462e04716 100644 --- a/arch/arm/boot/dts/omap5.dtsi +++ b/arch/arm/boot/dts/omap5.dtsi @@ -333,6 +333,9 @@ dsi1: encoder@58004000 { clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>, <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>; clock-names = "fck", "sys_clk"; + + #address-cells = <1>; + #size-cells = <0>; }; dsi2: encoder@58005000 { @@ -347,6 +350,9 @@ dsi2: encoder@58005000 { clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>, <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>; clock-names = "fck", "sys_clk"; + + #address-cells = <1>; + #size-cells = <0>; }; hdmi: encoder@58060000 { From patchwork Mon Feb 24 23:20:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C29D9C38C05 for ; Mon, 24 Feb 2020 23:21:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A30D32467C for ; Mon, 24 Feb 2020 23:21:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgBXXVi (ORCPT ); Mon, 24 Feb 2020 18:21:38 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59838 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728475AbgBXXVh (ORCPT ); Mon, 24 Feb 2020 18:21:37 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 0860029360F Received: by earth.universe (Postfix, from userid 1000) id B2F783C0C89; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 06/56] drm/omap: constify write buffers Date: Tue, 25 Feb 2020 00:20:36 +0100 Message-Id: <20200224232126.3385250-7-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The write buffers are not modified, so they can be constant. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/dss/dsi.c | 24 ++++++++++++------------ drivers/gpu/drm/omapdrm/dss/omapdss.h | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index bb2548d091ef..f01e0476296d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -2601,11 +2601,11 @@ static inline void dsi_vc_write_long_payload(struct dsi_data *dsi, int channel, } static int dsi_vc_send_long(struct dsi_data *dsi, int channel, u8 data_type, - u8 *data, u16 len, u8 ecc) + const u8 *data, u16 len, u8 ecc) { /*u32 val; */ int i; - u8 *p; + const u8 *p; int r = 0; u8 b1, b2, b3, b4; @@ -2698,7 +2698,7 @@ static int dsi_vc_send_null(struct dsi_data *dsi, int channel) } static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel, - u8 *data, int len, + const u8 *data, int len, enum dss_dsi_content_type type) { int r; @@ -2729,7 +2729,7 @@ static int dsi_vc_write_nosync_common(struct dsi_data *dsi, int channel, } static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel, - u8 *data, int len) + const u8 *data, int len) { struct dsi_data *dsi = to_dsi_data(dssdev); @@ -2738,7 +2738,7 @@ static int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel, } static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel, - u8 *data, int len) + const u8 *data, int len) { struct dsi_data *dsi = to_dsi_data(dssdev); @@ -2747,7 +2747,7 @@ static int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int chann } static int dsi_vc_write_common(struct omap_dss_device *dssdev, - int channel, u8 *data, int len, + int channel, const u8 *data, int len, enum dss_dsi_content_type type) { struct dsi_data *dsi = to_dsi_data(dssdev); @@ -2776,15 +2776,15 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev, return r; } -static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 *data, - int len) +static int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, + const u8 *data, int len) { return dsi_vc_write_common(dssdev, channel, data, len, DSS_DSI_CONTENT_DCS); } -static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8 *data, - int len) +static int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, + const u8 *data, int len) { return dsi_vc_write_common(dssdev, channel, data, len, DSS_DSI_CONTENT_GENERIC); @@ -2810,7 +2810,7 @@ static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel, } static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel, - u8 *reqdata, int reqlen) + const u8 *reqdata, int reqlen) { u16 data; u8 data_type; @@ -2983,7 +2983,7 @@ static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_c } static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel, - u8 *reqdata, int reqlen, u8 *buf, int buflen) + const u8 *reqdata, int reqlen, u8 *buf, int buflen) { struct dsi_data *dsi = to_dsi_data(dssdev); int r; diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 53fea1cbbc2d..b909b3a8c835 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -308,18 +308,18 @@ struct omapdss_dsi_ops { /* data transfer */ int (*dcs_write)(struct omap_dss_device *dssdev, int channel, - u8 *data, int len); + const u8 *data, int len); int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel, - u8 *data, int len); + const u8 *data, int len); int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd, u8 *data, int len); int (*gen_write)(struct omap_dss_device *dssdev, int channel, - u8 *data, int len); + const u8 *data, int len); int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel, - u8 *data, int len); + const u8 *data, int len); int (*gen_read)(struct omap_dss_device *dssdev, int channel, - u8 *reqdata, int reqlen, + const u8 *reqdata, int reqlen, u8 *data, int len); int (*bta_sync)(struct omap_dss_device *dssdev, int channel); From patchwork Mon Feb 24 23:20:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD337C11D30 for ; Mon, 24 Feb 2020 23:21:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADFFD20732 for ; Mon, 24 Feb 2020 23:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728511AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59858 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728480AbgBXXVi (ORCPT ); Mon, 24 Feb 2020 18:21:38 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 212E729361D Received: by earth.universe (Postfix, from userid 1000) id B74AF3C0C8A; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 07/56] drm/omap: dsi: add generic transfer function Date: Tue, 25 Feb 2020 00:20:37 +0100 Message-Id: <20200224232126.3385250-8-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This prepares the driver for becoming a mipi_dsi_host implementation, which provides a generic transfer function instead of all kind of different read/write functions. The implementation will become more elegant after unexporting the specific functions in the following patches. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/dss/dsi.c | 52 +++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ++ 2 files changed, 55 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index f01e0476296d..84e2eb0b51d7 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -4836,6 +4836,56 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel) } } +static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev, + const struct mipi_dsi_msg *msg) +{ + /* + * no_sync can be used to optimize performance by sending + * e.g. column and page information without syncing in + * between. It's not absolutley required, so postpone this + * feature for now. + */ + bool no_sync = false; + u16 val; + + switch (msg->type) { + case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: + case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: + case MIPI_DSI_GENERIC_LONG_WRITE: + if (no_sync) + return dsi_vc_generic_write_nosync(dssdev, msg->channel, + msg->tx_buf, msg->tx_len); + else + return dsi_vc_generic_write(dssdev, msg->channel, + msg->tx_buf, msg->tx_len); + case MIPI_DSI_DCS_SHORT_WRITE: + case MIPI_DSI_DCS_SHORT_WRITE_PARAM: + case MIPI_DSI_DCS_LONG_WRITE: + if (no_sync) + return dsi_vc_dcs_write_nosync(dssdev, msg->channel, + msg->tx_buf, msg->tx_len); + else + return dsi_vc_dcs_write(dssdev, msg->channel, + msg->tx_buf, msg->tx_len); + case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: + case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: + case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: + return dsi_vc_generic_read(dssdev, msg->channel, msg->tx_buf, + msg->tx_len, msg->rx_buf, msg->rx_len); + case MIPI_DSI_DCS_READ: + return dsi_vc_dcs_read(dssdev, msg->channel, + ((u8*) msg->tx_buf)[0], + msg->rx_buf, msg->rx_len); + case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: + val = le16_to_cpu(*((__le16*) msg->tx_buf)); + return dsi_vc_set_max_rx_packet_size(dssdev, msg->channel, val); + case MIPI_DSI_NULL_PACKET: + return dsi_vc_send_null(to_dsi_data(dssdev), msg->channel); + } + + return -EINVAL; +} static int dsi_get_clocks(struct dsi_data *dsi) { @@ -4890,6 +4940,8 @@ static const struct omap_dss_device_ops dsi_ops = { .set_vc_id = dsi_set_vc_id, .release_vc = dsi_release_vc, + .transfer = omap_dsi_transfer, + .dcs_write = dsi_vc_dcs_write, .dcs_write_nosync = dsi_vc_dcs_write_nosync, .dcs_read = dsi_vc_dcs_read, diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b909b3a8c835..ea7bf0970677 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -307,6 +307,9 @@ struct omapdss_dsi_ops { void (*release_vc)(struct omap_dss_device *dssdev, int channel); /* data transfer */ + ssize_t (*transfer)(struct omap_dss_device *dssdev, + const struct mipi_dsi_msg *msg); + int (*dcs_write)(struct omap_dss_device *dssdev, int channel, const u8 *data, int len); int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel, From patchwork Mon Feb 24 23:20:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66988C38BFF for ; Mon, 24 Feb 2020 23:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46B4F22527 for ; Mon, 24 Feb 2020 23:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728480AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59872 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbgBXXVi (ORCPT ); Mon, 24 Feb 2020 18:21:38 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 2666A29361E Received: by earth.universe (Postfix, from userid 1000) id BD83F3C0C8B; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 08/56] drm/omap: panel-dsi-cm: convert to transfer API Date: Tue, 25 Feb 2020 00:20:38 +0100 Message-Id: <20200224232126.3385250-9-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This converts the panel-dsi-cm driver to use the transfer API instead of specific functions, so that the specific functions can be unexported and squashed into the generic transfer function. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 133 +++++++++++++----- 1 file changed, 96 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index e6ebfc35243e..92f510a771fe 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -140,45 +140,61 @@ static void hw_guard_wait(struct panel_drv_data *ddata) static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) { struct omap_dss_device *src = ddata->src; - int r; - u8 buf[1]; - - r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, buf, 1); - - if (r < 0) - return r; - - *data = buf[0]; + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_DCS_READ, + .tx_len = 1, + .tx_buf = &dcs_cmd, + .rx_len = 1, + .rx_buf = data + }; - return 0; + return src->ops->dsi.transfer(src, &msg); } static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) { struct omap_dss_device *src = ddata->src; + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_DCS_SHORT_WRITE, + .tx_buf = &dcs_cmd, + .tx_len = 1, + }; - return src->ops->dsi.dcs_write(src, ddata->channel, &dcs_cmd, 1); + return src->ops->dsi.transfer(src, &msg); } static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) { struct omap_dss_device *src = ddata->src; - u8 buf[2] = { dcs_cmd, param }; + const u8 buf[] = { dcs_cmd, param }; + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM, + .tx_buf = &buf, + .tx_len = 2, + }; - return src->ops->dsi.dcs_write(src, ddata->channel, buf, 2); + return src->ops->dsi.transfer(src, &msg); } static int dsicm_sleep_in(struct panel_drv_data *ddata) { struct omap_dss_device *src = ddata->src; - u8 cmd; int r; + const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE; + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_DCS_SHORT_WRITE, + .tx_buf = &cmd, + .tx_len = 1, + }; hw_guard_wait(ddata); - cmd = MIPI_DCS_ENTER_SLEEP_MODE; - r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, &cmd, 1); + r = src->ops->dsi.transfer(src, &msg); if (r) return r; @@ -233,28 +249,44 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata, u16 y1 = y; u16 y2 = y + h - 1; - u8 buf[5]; - buf[0] = MIPI_DCS_SET_COLUMN_ADDRESS; - buf[1] = (x1 >> 8) & 0xff; - buf[2] = (x1 >> 0) & 0xff; - buf[3] = (x2 >> 8) & 0xff; - buf[4] = (x2 >> 0) & 0xff; + const u8 paramX[] = { + MIPI_DCS_SET_COLUMN_ADDRESS, + (x1 >> 8) & 0xff, + (x1 >> 0) & 0xff, + (x2 >> 8) & 0xff, + (x2 >> 0) & 0xff, + }; - r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); - if (r) - return r; + const struct mipi_dsi_msg msgX = { + .channel = ddata->channel, + .type = MIPI_DSI_GENERIC_LONG_WRITE, + .tx_buf = paramX, + .tx_len = 5, + }; - buf[0] = MIPI_DCS_SET_PAGE_ADDRESS; - buf[1] = (y1 >> 8) & 0xff; - buf[2] = (y1 >> 0) & 0xff; - buf[3] = (y2 >> 8) & 0xff; - buf[4] = (y2 >> 0) & 0xff; + const u8 paramY[] = { + MIPI_DCS_SET_PAGE_ADDRESS, + (y1 >> 8) & 0xff, + (y1 >> 0) & 0xff, + (y2 >> 8) & 0xff, + (y2 >> 0) & 0xff, + }; - r = src->ops->dsi.dcs_write_nosync(src, ddata->channel, buf, sizeof(buf)); + const struct mipi_dsi_msg msgY = { + .channel = ddata->channel, + .type = MIPI_DSI_GENERIC_LONG_WRITE, + .tx_buf = paramY, + .tx_len = 5, + }; + + + r = src->ops->dsi.transfer(src, &msgX); if (r) return r; - src->ops->dsi.bta_sync(src, ddata->channel); + r = src->ops->dsi.transfer(src, &msgY); + if (r) + return r; return r; } @@ -991,6 +1023,27 @@ static int dsicm_get_te(struct omap_dss_device *dssdev) return r; } +static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev, + u16 size) +{ + struct panel_drv_data *ddata = to_panel_data(dssdev); + struct omap_dss_device *src = ddata->src; + + const u8 buf[] = { + size & 0xff, + size >> 8 & 0xff, + }; + + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, + .tx_buf = buf, + .tx_len = 2, + }; + + return src->ops->dsi.transfer(src, &msg); +} + static int dsicm_memory_read(struct omap_dss_device *dssdev, void *buf, size_t size, u16 x, u16 y, u16 w, u16 h) @@ -1031,17 +1084,23 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, dsicm_set_update_window(ddata, x, y, w, h); - r = src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, plen); + r = dsicm_set_max_rx_packet_size(dssdev, plen); if (r) goto err2; while (buf_used < size) { u8 dcs_cmd = first ? 0x2e : 0x3e; + const struct mipi_dsi_msg msg = { + .channel = ddata->channel, + .type = MIPI_DSI_DCS_READ, + .tx_buf = &dcs_cmd, + .tx_len = 1, + .rx_buf = buf + buf_used, + .rx_len = size - buf_used, + }; first = 0; - r = src->ops->dsi.dcs_read(src, ddata->channel, dcs_cmd, - buf + buf_used, size - buf_used); - + r = src->ops->dsi.transfer(src, &msg); if (r < 0) { dev_err(dssdev->dev, "read error\n"); goto err3; @@ -1065,7 +1124,7 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, r = buf_used; err3: - src->ops->dsi.set_max_rx_packet_size(src, ddata->channel, 1); + dsicm_set_max_rx_packet_size(dssdev, 1); err2: src->ops->dsi.bus_unlock(src); err1: From patchwork Mon Feb 24 23:20:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B4BCC11D3A for ; Mon, 24 Feb 2020 23:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05D9220732 for ; Mon, 24 Feb 2020 23:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728489AbgBXXVv (ORCPT ); Mon, 24 Feb 2020 18:21:51 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59882 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728486AbgBXXVi (ORCPT ); Mon, 24 Feb 2020 18:21:38 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 28140293644 Received: by earth.universe (Postfix, from userid 1000) id C88393C0C8D; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 10/56] drm/omap: dsi: drop virtual channel logic Date: Tue, 25 Feb 2020 00:20:40 +0100 Message-Id: <20200224232126.3385250-11-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This drops the virtual channel logic. Afterwards DSI clients request their channel number and get the virtual channel with the same number or -EBUSY if already in use. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 11 ++--- drivers/gpu/drm/omapdrm/dss/dsi.c | 46 ++++--------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 4 +- 3 files changed, 12 insertions(+), 49 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 92f510a771fe..ba046a596044 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -769,19 +769,12 @@ static int dsicm_connect(struct omap_dss_device *src, struct device *dev = &ddata->pdev->dev; int r; - r = src->ops->dsi.request_vc(src, &ddata->channel); + r = src->ops->dsi.request_vc(src, ddata->channel); if (r) { dev_err(dev, "failed to get virtual channel\n"); return r; } - r = src->ops->dsi.set_vc_id(src, ddata->channel, TCH); - if (r) { - dev_err(dev, "failed to set VC_ID\n"); - src->ops->dsi.release_vc(src, ddata->channel); - return r; - } - ddata->src = src; return 0; } @@ -1216,6 +1209,8 @@ static int dsicm_probe_of(struct platform_device *pdev) struct display_timing timing; int err; + ddata->channel = TCH; + ddata->reset_gpio = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ddata->reset_gpio)) { err = PTR_ERR(ddata->reset_gpio); diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 0990777a42f7..8c223b808740 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -350,7 +350,6 @@ struct dsi_data { struct omap_dss_device *dssdev; enum fifo_size tx_fifo_size; enum fifo_size rx_fifo_size; - int vc_id; } vc[4]; struct mutex lock; @@ -2579,7 +2578,7 @@ static inline void dsi_vc_write_long_header(struct dsi_data *dsi, int channel, WARN_ON(!dsi_bus_is_locked(dsi)); - data_id = data_type | dsi->vc[channel].vc_id << 6; + data_id = data_type | channel << 6; val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) | FLD_VAL(ecc, 31, 24); @@ -2683,7 +2682,7 @@ static int dsi_vc_send_short(struct dsi_data *dsi, int channel, u8 data_type, return -EINVAL; } - data_id = data_type | dsi->vc[channel].vc_id << 6; + data_id = data_type | channel << 6; r = (data_id << 0) | (data << 8) | (ecc << 24); @@ -4783,45 +4782,19 @@ static enum omap_channel dsi_get_channel(struct dsi_data *dsi) } } -static int dsi_request_vc(struct omap_dss_device *dssdev, int *channel) +static int dsi_request_vc(struct omap_dss_device *dssdev, int channel) { struct dsi_data *dsi = to_dsi_data(dssdev); - int i; - - for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { - if (!dsi->vc[i].dssdev) { - dsi->vc[i].dssdev = dssdev; - *channel = i; - return 0; - } - } - DSSERR("cannot get VC for display %s", dssdev->name); - return -ENOSPC; -} - -static int dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id) -{ - struct dsi_data *dsi = to_dsi_data(dssdev); - - if (vc_id < 0 || vc_id > 3) { - DSSERR("VC ID out of range\n"); - return -EINVAL; - } - - if (channel < 0 || channel > 3) { - DSSERR("Virtual Channel out of range\n"); + if (channel < 0 || channel > 3) return -EINVAL; - } - if (dsi->vc[channel].dssdev != dssdev) { - DSSERR("Virtual Channel not allocated to display %s\n", - dssdev->name); - return -EINVAL; + if (dsi->vc[channel].dssdev) { + DSSERR("cannot get VC for display %s", dssdev->name); + return -EBUSY; } - dsi->vc[channel].vc_id = vc_id; - + dsi->vc[channel].dssdev = dssdev; return 0; } @@ -4832,7 +4805,6 @@ static void dsi_release_vc(struct omap_dss_device *dssdev, int channel) if ((channel >= 0 && channel <= 3) && dsi->vc[channel].dssdev == dssdev) { dsi->vc[channel].dssdev = NULL; - dsi->vc[channel].vc_id = 0; } } @@ -4937,7 +4909,6 @@ static const struct omap_dss_device_ops dsi_ops = { .enable_te = dsi_enable_te, .request_vc = dsi_request_vc, - .set_vc_id = dsi_set_vc_id, .release_vc = dsi_release_vc, .transfer = omap_dsi_transfer, @@ -5393,7 +5364,6 @@ static int dsi_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { dsi->vc[i].source = DSI_VC_SOURCE_L4; dsi->vc[i].dssdev = NULL; - dsi->vc[i].vc_id = 0; } r = dsi_get_clocks(dsi); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 787e102eb068..587206c984a9 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -301,9 +301,7 @@ struct omapdss_dsi_ops { void (*disable_video_output)(struct omap_dss_device *dssdev, int channel); - int (*request_vc)(struct omap_dss_device *dssdev, int *channel); - int (*set_vc_id)(struct omap_dss_device *dssdev, int channel, - int vc_id); + int (*request_vc)(struct omap_dss_device *dssdev, int channel); void (*release_vc)(struct omap_dss_device *dssdev, int channel); /* data transfer */ From patchwork Mon Feb 24 23:20:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C4CC11D38 for ; Mon, 24 Feb 2020 23:21:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4061920732 for ; Mon, 24 Feb 2020 23:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728501AbgBXXVu (ORCPT ); Mon, 24 Feb 2020 18:21:50 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59820 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728489AbgBXXVi (ORCPT ); Mon, 24 Feb 2020 18:21:38 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 6674529367D Received: by earth.universe (Postfix, from userid 1000) id D470A3C0C8F; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 12/56] drm/omap: dsi: simplify read functions Date: Tue, 25 Feb 2020 00:20:42 +0100 Message-Id: <20200224232126.3385250-13-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Simplify the read related message handling by using the functionality provided by CONFIG_DRM_MIPI_DSI. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/dss/dsi.c | 109 +++++++++--------------------- 1 file changed, 33 insertions(+), 76 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index e5589e615808..9b5b078beb6d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -2741,60 +2741,6 @@ static int dsi_vc_write_common(struct omap_dss_device *dssdev, return 0; } -static int dsi_vc_dcs_send_read_request(struct dsi_data *dsi, int channel, - u8 dcs_cmd) -{ - int r; - - if (dsi->debug_read) - DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n", - channel, dcs_cmd); - - r = dsi_vc_send_short(dsi, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0); - if (r) { - DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)" - " failed\n", channel, dcs_cmd); - return r; - } - - return 0; -} - -static int dsi_vc_generic_send_read_request(struct dsi_data *dsi, int channel, - const u8 *reqdata, int reqlen) -{ - u16 data; - u8 data_type; - int r; - - if (dsi->debug_read) - DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n", - channel, reqlen); - - if (reqlen == 0) { - data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; - data = 0; - } else if (reqlen == 1) { - data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; - data = reqdata[0]; - } else if (reqlen == 2) { - data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; - data = reqdata[0] | (reqdata[1] << 8); - } else { - BUG(); - return -EINVAL; - } - - r = dsi_vc_send_short(dsi, channel, data_type, data, 0); - if (r) { - DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)" - " failed\n", channel, reqlen); - return r; - } - - return 0; -} - static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf, int buflen, enum dss_dsi_content_type type) { @@ -2903,61 +2849,75 @@ static int dsi_vc_read_rx_fifo(struct dsi_data *dsi, int channel, u8 *buf, return r; } -static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd, - u8 *buf, int buflen) +static int dsi_vc_dcs_read(struct omap_dss_device *dssdev, + const struct mipi_dsi_msg *msg) { struct dsi_data *dsi = to_dsi_data(dssdev); int r; + u8 dcs_cmd = ((u8*) msg->tx_buf)[0]; - r = dsi_vc_dcs_send_read_request(dsi, channel, dcs_cmd); + r = dsi_vc_send_short(dsi, msg->channel, MIPI_DSI_DCS_READ, dcs_cmd, 0); if (r) goto err; - r = dsi_vc_send_bta_sync(dssdev, channel); + r = dsi_vc_send_bta_sync(dssdev, msg->channel); if (r) goto err; - r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen, + r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len, DSS_DSI_CONTENT_DCS); if (r < 0) goto err; - if (r != buflen) { + if (r != msg->rx_len) { r = -EIO; goto err; } return 0; err: - DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd); + DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", + msg->channel, dcs_cmd); return r; } -static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel, - const u8 *reqdata, int reqlen, u8 *buf, int buflen) +static int dsi_vc_generic_read(struct omap_dss_device *dssdev, + const struct mipi_dsi_msg *msg) { struct dsi_data *dsi = to_dsi_data(dssdev); + struct mipi_dsi_packet packet; + u16 data; int r; - r = dsi_vc_generic_send_read_request(dsi, channel, reqdata, reqlen); + r = mipi_dsi_create_packet(&packet, msg); + if (r < 0) + goto err; + + data = packet.header[1] | (packet.header[2] << 8); + + r = dsi_vc_send_short(dsi, msg->channel, msg->type, data, 0); if (r) - return r; + goto err; - r = dsi_vc_send_bta_sync(dssdev, channel); + r = dsi_vc_send_bta_sync(dssdev, msg->channel); if (r) - return r; + goto err; - r = dsi_vc_read_rx_fifo(dsi, channel, buf, buflen, + r = dsi_vc_read_rx_fifo(dsi, msg->channel, msg->rx_buf, msg->rx_len, DSS_DSI_CONTENT_GENERIC); if (r < 0) - return r; + goto err; - if (r != buflen) { + if (r != msg->rx_len) { r = -EIO; - return r; + goto err; } return 0; +err: + DSSERR("dsi_vc_generic_read(ch %d, reqlen %d) failed\n", + msg->channel, msg->tx_len); + return r; } static int dsi_enter_ulps(struct dsi_data *dsi) @@ -4768,12 +4728,9 @@ static ssize_t omap_dsi_transfer(struct omap_dss_device *dssdev, case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: - return dsi_vc_generic_read(dssdev, msg->channel, msg->tx_buf, - msg->tx_len, msg->rx_buf, msg->rx_len); + return dsi_vc_generic_read(dssdev, msg); case MIPI_DSI_DCS_READ: - return dsi_vc_dcs_read(dssdev, msg->channel, - ((u8*) msg->tx_buf)[0], - msg->rx_buf, msg->rx_len); + return dsi_vc_dcs_read(dssdev, msg); } return -EINVAL; From patchwork Mon Feb 24 23:20:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AD6CC38C09 for ; Mon, 24 Feb 2020 23:21:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6197722527 for ; Mon, 24 Feb 2020 23:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728488AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59838 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728495AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 44055293982 Received: by earth.universe (Postfix, from userid 1000) id E59D13C0C92; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 15/56] drm/omap: panel-dsi-cm: use DSI helpers Date: Tue, 25 Feb 2020 00:20:45 +0100 Message-Id: <20200224232126.3385250-16-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org After converting the driver to mipi_dsi_device we can use the generic message helpers to simplify the driver a lot. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 126 +++--------------- 1 file changed, 18 insertions(+), 108 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index c34daecb1de5..4a4a55135494 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -138,62 +138,22 @@ static void hw_guard_wait(struct panel_drv_data *ddata) static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data) { - struct mipi_dsi_device *dsi = ddata->dsi; - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_DCS_READ, - .tx_len = 1, - .tx_buf = &dcs_cmd, - .rx_len = 1, - .rx_buf = data - }; - - return dsi->host->ops->transfer(dsi->host, &msg); -} - -static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd) -{ - struct mipi_dsi_device *dsi = ddata->dsi; - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_DCS_SHORT_WRITE, - .tx_buf = &dcs_cmd, - .tx_len = 1, - }; - - return dsi->host->ops->transfer(dsi->host, &msg); + return mipi_dsi_dcs_read(ddata->dsi, dcs_cmd, data, 1); } static int dsicm_dcs_write_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 param) { - struct mipi_dsi_device *dsi = ddata->dsi; - const u8 buf[] = { dcs_cmd, param }; - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_DCS_SHORT_WRITE_PARAM, - .tx_buf = &buf, - .tx_len = 2, - }; - - return dsi->host->ops->transfer(dsi->host, &msg); + return mipi_dsi_dcs_write(ddata->dsi, dcs_cmd, ¶m, 1); } static int dsicm_sleep_in(struct panel_drv_data *ddata) { - struct mipi_dsi_device *dsi = ddata->dsi; int r; - const u8 cmd = MIPI_DCS_ENTER_SLEEP_MODE; - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_DCS_SHORT_WRITE, - .tx_buf = &cmd, - .tx_len = 1, - }; hw_guard_wait(ddata); - r = dsi->host->ops->transfer(dsi->host, &msg); + r = mipi_dsi_dcs_enter_sleep_mode(ddata->dsi); if (r) return r; @@ -210,7 +170,7 @@ static int dsicm_sleep_out(struct panel_drv_data *ddata) hw_guard_wait(ddata); - r = dsicm_dcs_write_0(ddata, MIPI_DCS_EXIT_SLEEP_MODE); + r = mipi_dsi_dcs_exit_sleep_mode(ddata->dsi); if (r) return r; @@ -248,46 +208,15 @@ static int dsicm_set_update_window(struct panel_drv_data *ddata, u16 y1 = y; u16 y2 = y + h - 1; - const u8 paramX[] = { - MIPI_DCS_SET_COLUMN_ADDRESS, - (x1 >> 8) & 0xff, - (x1 >> 0) & 0xff, - (x2 >> 8) & 0xff, - (x2 >> 0) & 0xff, - }; - - const struct mipi_dsi_msg msgX = { - .channel = ddata->channel, - .type = MIPI_DSI_GENERIC_LONG_WRITE, - .tx_buf = paramX, - .tx_len = 5, - }; - - const u8 paramY[] = { - MIPI_DCS_SET_PAGE_ADDRESS, - (y1 >> 8) & 0xff, - (y1 >> 0) & 0xff, - (y2 >> 8) & 0xff, - (y2 >> 0) & 0xff, - }; - - const struct mipi_dsi_msg msgY = { - .channel = ddata->channel, - .type = MIPI_DSI_GENERIC_LONG_WRITE, - .tx_buf = paramY, - .tx_len = 5, - }; - - - r = dsi->host->ops->transfer(dsi->host, &msgX); - if (r) + r = mipi_dsi_dcs_set_column_address(dsi, x1, x2); + if (r < 0) return r; - r = dsi->host->ops->transfer(dsi->host, &msgY); - if (r) + r = mipi_dsi_dcs_set_page_address(dsi, y1, y2); + if (r < 0) return r; - return r; + return 0; } static void dsicm_queue_ulps_work(struct panel_drv_data *ddata) @@ -681,12 +610,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata) if (r) goto err; - r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_PIXEL_FORMAT, - MIPI_DCS_PIXEL_FMT_24BIT); + r = mipi_dsi_dcs_set_pixel_format(ddata->dsi, MIPI_DCS_PIXEL_FMT_24BIT); if (r) goto err; - r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_ON); + r = mipi_dsi_dcs_set_display_on(ddata->dsi); if (r) goto err; @@ -732,7 +660,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata) src->ops->dsi.disable_video_output(src, ddata->channel); - r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_DISPLAY_OFF); + r = mipi_dsi_dcs_set_display_off(ddata->dsi); if (!r) r = dsicm_sleep_in(ddata); @@ -950,12 +878,13 @@ static int dsicm_sync(struct omap_dss_device *dssdev) static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) { struct omap_dss_device *src = ddata->src; + struct mipi_dsi_device *dsi = ddata->dsi; int r; if (enable) - r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_TEAR_ON, 0); + r = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK); else - r = dsicm_dcs_write_0(ddata, MIPI_DCS_SET_TEAR_OFF); + r = mipi_dsi_dcs_set_tear_off(dsi); if (!ddata->ext_te_gpio) src->ops->dsi.enable_te(src, enable); @@ -1021,19 +950,7 @@ static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev, struct panel_drv_data *ddata = to_panel_data(dssdev); struct mipi_dsi_device *dsi = ddata->dsi; - const u8 buf[] = { - size & 0xff, - size >> 8 & 0xff, - }; - - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, - .tx_buf = buf, - .tx_len = 2, - }; - - return dsi->host->ops->transfer(dsi->host, &msg); + return mipi_dsi_set_maximum_return_packet_size(dsi, size); } static int dsicm_memory_read(struct omap_dss_device *dssdev, @@ -1083,17 +1000,10 @@ static int dsicm_memory_read(struct omap_dss_device *dssdev, while (buf_used < size) { u8 dcs_cmd = first ? 0x2e : 0x3e; - const struct mipi_dsi_msg msg = { - .channel = ddata->channel, - .type = MIPI_DSI_DCS_READ, - .tx_buf = &dcs_cmd, - .tx_len = 1, - .rx_buf = buf + buf_used, - .rx_len = size - buf_used, - }; first = 0; - r = dsi->host->ops->transfer(dsi->host, &msg); + r = mipi_dsi_dcs_read(dsi, dcs_cmd, + buf + buf_used, size - buf_used); if (r < 0) { dev_err(dssdev->dev, "read error\n"); goto err3; From patchwork Mon Feb 24 23:20:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7A82C11D30 for ; Mon, 24 Feb 2020 23:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 960EC20732 for ; Mon, 24 Feb 2020 23:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728522AbgBXXVt (ORCPT ); Mon, 24 Feb 2020 18:21:49 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59928 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728501AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 4E9E629398E Received: by earth.universe (Postfix, from userid 1000) id F03FC3C0C94; Tue, 25 Feb 2020 00:21:30 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 17/56] drm/omap: panel-dsi-cm: drop hardcoded VC Date: Tue, 25 Feb 2020 00:20:47 +0100 Message-Id: <20200224232126.3385250-18-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Use dsi->channel everywhere, which originates from DT. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index b3688a8ca3cf..9a2ccec27f7e 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -27,9 +27,6 @@ #include "../dss/omapdss.h" -/* DSI Virtual channel. Hardcoded for now. */ -#define TCH 0 - #define DCS_READ_NUM_ERRORS 0x05 #define DCS_BRIGHTNESS 0x51 #define DCS_CTRL_DISPLAY 0x53 @@ -73,7 +70,6 @@ struct panel_drv_data { bool te_enabled; atomic_t do_update; - int channel; struct delayed_work te_timeout_work; @@ -274,7 +270,7 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) return 0; src->ops->enable(src); - src->ops->dsi.enable_hs(src, ddata->channel, true); + src->ops->dsi.enable_hs(src, ddata->dsi->channel, true); r = _dsicm_enable_te(ddata, true); if (r) { @@ -591,7 +587,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) dsicm_hw_reset(ddata); - src->ops->dsi.enable_hs(src, ddata->channel, false); + src->ops->dsi.enable_hs(src, ddata->dsi->channel, false); r = dsicm_sleep_out(ddata); if (r) @@ -622,7 +618,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) if (r) goto err; - r = src->ops->dsi.enable_video_output(src, ddata->channel); + r = src->ops->dsi.enable_video_output(src, ddata->dsi->channel); if (r) goto err; @@ -634,7 +630,7 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ddata->intro_printed = true; } - src->ops->dsi.enable_hs(src, ddata->channel, true); + src->ops->dsi.enable_hs(src, ddata->dsi->channel, true); return 0; err: @@ -658,7 +654,7 @@ static void dsicm_power_off(struct panel_drv_data *ddata) struct omap_dss_device *src = ddata->src; int r; - src->ops->dsi.disable_video_output(src, ddata->channel); + src->ops->dsi.disable_video_output(src, ddata->dsi->channel); r = mipi_dsi_dcs_set_display_off(ddata->dsi); if (!r) @@ -777,7 +773,7 @@ static irqreturn_t dsicm_te_isr(int irq, void *data) if (old) { cancel_delayed_work(&ddata->te_timeout_work); - r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb, + r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, ddata); if (r) goto err; @@ -834,7 +830,7 @@ static int dsicm_update(struct omap_dss_device *dssdev, msecs_to_jiffies(250)); atomic_set(&ddata->do_update, 1); } else { - r = src->ops->dsi.update(src, ddata->channel, dsicm_framedone_cb, + r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, ddata); if (r) goto err; @@ -1110,8 +1106,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi) struct display_timing timing; int err; - ddata->channel = TCH; - ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ddata->reset_gpio)) { err = PTR_ERR(ddata->reset_gpio); From patchwork Mon Feb 24 23:20:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 558E1C11D32 for ; Mon, 24 Feb 2020 23:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26E5B20732 for ; Mon, 24 Feb 2020 23:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728530AbgBXXVt (ORCPT ); Mon, 24 Feb 2020 18:21:49 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59940 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728506AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 539202939B9 Received: by earth.universe (Postfix, from userid 1000) id 029AC3C0C95; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 18/56] drm/omap: panel-dsi-cm: use common MIPI DCS 1.3 defines Date: Tue, 25 Feb 2020 00:20:48 +0100 Message-Id: <20200224232126.3385250-19-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Drop local definition of common MIPI DCS 1.3 defines. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 9a2ccec27f7e..92c9dc211aeb 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -28,8 +28,6 @@ #include "../dss/omapdss.h" #define DCS_READ_NUM_ERRORS 0x05 -#define DCS_BRIGHTNESS 0x51 -#define DCS_CTRL_DISPLAY 0x53 #define DCS_GET_ID1 0xda #define DCS_GET_ID2 0xdb #define DCS_GET_ID3 0xdc @@ -333,8 +331,10 @@ static int dsicm_bl_update_status(struct backlight_device *dev) src->ops->dsi.bus_lock(src); r = dsicm_wake_up(ddata); - if (!r) - r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, level); + if (!r) { + r = dsicm_dcs_write_1(ddata, + MIPI_DCS_SET_DISPLAY_BRIGHTNESS, level); + } src->ops->dsi.bus_unlock(src); } @@ -597,11 +597,11 @@ static int dsicm_power_on(struct panel_drv_data *ddata) if (r) goto err; - r = dsicm_dcs_write_1(ddata, DCS_BRIGHTNESS, 0xff); + r = dsicm_dcs_write_1(ddata, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff); if (r) goto err; - r = dsicm_dcs_write_1(ddata, DCS_CTRL_DISPLAY, + r = dsicm_dcs_write_1(ddata, MIPI_DCS_WRITE_CONTROL_DISPLAY, (1<<2) | (1<<5)); /* BL | BCTRL */ if (r) goto err; From patchwork Mon Feb 24 23:20:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD36CC38C0A for ; Mon, 24 Feb 2020 23:21:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCC2B22527 for ; Mon, 24 Feb 2020 23:21:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728474AbgBXXVk (ORCPT ); Mon, 24 Feb 2020 18:21:40 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59858 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728510AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 6063F293A39 Received: by earth.universe (Postfix, from userid 1000) id 0A2523C0C96; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 19/56] drm/omap: dsi: drop unused memory_read() Date: Tue, 25 Feb 2020 00:20:49 +0100 Message-Id: <20200224232126.3385250-20-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 93 ------------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 4 - 2 files changed, 97 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 92c9dc211aeb..59b8fc71c974 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -931,97 +931,6 @@ static int dsicm_get_te(struct omap_dss_device *dssdev) return r; } -static int dsicm_set_max_rx_packet_size(struct omap_dss_device *dssdev, - u16 size) -{ - struct panel_drv_data *ddata = to_panel_data(dssdev); - struct mipi_dsi_device *dsi = ddata->dsi; - - return mipi_dsi_set_maximum_return_packet_size(dsi, size); -} - -static int dsicm_memory_read(struct omap_dss_device *dssdev, - void *buf, size_t size, - u16 x, u16 y, u16 w, u16 h) -{ - struct panel_drv_data *ddata = to_panel_data(dssdev); - struct mipi_dsi_device *dsi = ddata->dsi; - struct omap_dss_device *src = ddata->src; - int r; - int first = 1; - int plen; - unsigned int buf_used = 0; - - if (size < w * h * 3) - return -ENOMEM; - - mutex_lock(&ddata->lock); - - if (!ddata->enabled) { - r = -ENODEV; - goto err1; - } - - size = min((u32)w * h * 3, - ddata->vm.hactive * ddata->vm.vactive * 3); - - src->ops->dsi.bus_lock(src); - - r = dsicm_wake_up(ddata); - if (r) - goto err2; - - /* plen 1 or 2 goes into short packet. until checksum error is fixed, - * use short packets. plen 32 works, but bigger packets seem to cause - * an error. */ - if (size % 2) - plen = 1; - else - plen = 2; - - dsicm_set_update_window(ddata, x, y, w, h); - - r = dsicm_set_max_rx_packet_size(dssdev, plen); - if (r) - goto err2; - - while (buf_used < size) { - u8 dcs_cmd = first ? 0x2e : 0x3e; - first = 0; - - r = mipi_dsi_dcs_read(dsi, dcs_cmd, - buf + buf_used, size - buf_used); - if (r < 0) { - dev_err(dssdev->dev, "read error\n"); - goto err3; - } - - buf_used += r; - - if (r < plen) { - dev_err(&ddata->dsi->dev, "short read\n"); - break; - } - - if (signal_pending(current)) { - dev_err(&ddata->dsi->dev, "signal pending, " - "aborting memory read\n"); - r = -ERESTARTSYS; - goto err3; - } - } - - r = buf_used; - -err3: - dsicm_set_max_rx_packet_size(dssdev, 1); -err2: - src->ops->dsi.bus_unlock(src); -err1: - mutex_unlock(&ddata->lock); - return r; -} - static void dsicm_ulps_work(struct work_struct *work) { struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, @@ -1094,8 +1003,6 @@ static const struct omap_dss_driver dsicm_dss_driver = { .enable_te = dsicm_enable_te, .get_te = dsicm_get_te, - - .memory_read = dsicm_memory_read, }; static int dsicm_probe_of(struct mipi_dsi_device *dsi) diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b946b90ce01b..54f362cc5223 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -388,10 +388,6 @@ struct omap_dss_driver { int (*enable_te)(struct omap_dss_device *dssdev, bool enable); int (*get_te)(struct omap_dss_device *dssdev); - - int (*memory_read)(struct omap_dss_device *dssdev, - void *buf, size_t size, - u16 x, u16 y, u16 w, u16 h); }; struct dss_device *omapdss_get_dss(void); From patchwork Mon Feb 24 23:20:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF3AAC38BFF for ; Mon, 24 Feb 2020 23:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C37C924672 for ; Mon, 24 Feb 2020 23:21:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728495AbgBXXVk (ORCPT ); Mon, 24 Feb 2020 18:21:40 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59882 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728500AbgBXXVj (ORCPT ); Mon, 24 Feb 2020 18:21:39 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 60692293A5E Received: by earth.universe (Postfix, from userid 1000) id 0FC113C0C97; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 20/56] drm/omap: dsi: drop unused get_te() Date: Tue, 25 Feb 2020 00:20:50 +0100 Message-Id: <20200224232126.3385250-21-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The get_te() callback is not used, so we can drop the custom API. Signed-off-by: Sebastian Reichel --- drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 13 ------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 - 2 files changed, 14 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 59b8fc71c974..e4b24c67c45d 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -919,18 +919,6 @@ static int dsicm_enable_te(struct omap_dss_device *dssdev, bool enable) return r; } -static int dsicm_get_te(struct omap_dss_device *dssdev) -{ - struct panel_drv_data *ddata = to_panel_data(dssdev); - int r; - - mutex_lock(&ddata->lock); - r = ddata->te_enabled; - mutex_unlock(&ddata->lock); - - return r; -} - static void dsicm_ulps_work(struct work_struct *work) { struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, @@ -1002,7 +990,6 @@ static const struct omap_dss_driver dsicm_dss_driver = { .sync = dsicm_sync, .enable_te = dsicm_enable_te, - .get_te = dsicm_get_te, }; static int dsicm_probe_of(struct mipi_dsi_device *dsi) diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 54f362cc5223..a1e78ba665d8 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -387,7 +387,6 @@ struct omap_dss_driver { int (*sync)(struct omap_dss_device *dssdev); int (*enable_te)(struct omap_dss_device *dssdev, bool enable); - int (*get_te)(struct omap_dss_device *dssdev); }; struct dss_device *omapdss_get_dss(void); From patchwork Mon Feb 24 23:20:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99AB3C11D3D for ; Mon, 24 Feb 2020 23:28:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7908224649 for ; Mon, 24 Feb 2020 23:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728412AbgBXX2b (ORCPT ); Mon, 24 Feb 2020 18:28:31 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60500 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728274AbgBXX2b (ORCPT ); Mon, 24 Feb 2020 18:28:31 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 0E43B28A938 Received: by earth.universe (Postfix, from userid 1000) id 1ED443C0C9A; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 23/56] drm/omap: dsi: use pixel-format and mode from attach Date: Tue, 25 Feb 2020 00:20:53 +0100 Message-Id: <20200224232126.3385250-24-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In order to reduce the amount of custom functionality, this moves handling of pixel format and DSI mode from set_config() to dsi attach. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 2 -- drivers/gpu/drm/omapdrm/dss/dsi.c | 20 +++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index a45df247aad1..199eac88a777 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -550,8 +550,6 @@ static int dsicm_power_on(struct panel_drv_data *ddata) u8 id1, id2, id3; int r; struct omap_dss_dsi_config dsi_config = { - .mode = OMAP_DSS_DSI_CMD_MODE, - .pixel_format = MIPI_DSI_FMT_RGB888, .vm = &ddata->vm, .hs_clk_min = 150000000, .hs_clk_max = 300000000, diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 64407f4651af..6c625b6d6d6b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -4583,18 +4583,19 @@ static int dsi_set_config(struct omap_dss_device *dssdev, { struct dsi_data *dsi = to_dsi_data(dssdev); struct dsi_clk_calc_ctx ctx; + struct omap_dss_dsi_config cfg = *config; bool ok; int r; mutex_lock(&dsi->lock); - dsi->pix_fmt = config->pixel_format; - dsi->mode = config->mode; + cfg.mode = dsi->mode; + cfg.pixel_format = dsi->pix_fmt; - if (config->mode == OMAP_DSS_DSI_VIDEO_MODE) - ok = dsi_vm_calc(dsi, config, &ctx); + if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) + ok = dsi_vm_calc(dsi, &cfg, &ctx); else - ok = dsi_cm_calc(dsi, config, &ctx); + ok = dsi_cm_calc(dsi, &cfg, &ctx); if (!ok) { DSSERR("failed to find suitable DSI clock settings\n"); @@ -4605,7 +4606,7 @@ static int dsi_set_config(struct omap_dss_device *dssdev, dsi_pll_calc_dsi_fck(dsi, &ctx.dsi_cinfo); r = dsi_lp_clock_calc(ctx.dsi_cinfo.clkout[HSDIV_DSI], - config->lp_clk_min, config->lp_clk_max, &dsi->user_lp_cinfo); + cfg.lp_clk_min, cfg.lp_clk_max, &dsi->user_lp_cinfo); if (r) { DSSERR("failed to find suitable DSI LP clock settings\n"); goto err; @@ -4784,6 +4785,13 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host, } dsi->vc[channel].dest = client; + + dsi->pix_fmt = client->format; + if (client->mode_flags & MIPI_DSI_MODE_VIDEO) + dsi->mode = OMAP_DSS_DSI_VIDEO_MODE; + else + dsi->mode = OMAP_DSS_DSI_CMD_MODE; + return 0; } From patchwork Mon Feb 24 23:20:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CCAEC35DE1 for ; Mon, 24 Feb 2020 23:28:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FC2920732 for ; Mon, 24 Feb 2020 23:28:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728206AbgBXX2e (ORCPT ); Mon, 24 Feb 2020 18:28:34 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60628 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728221AbgBXX2d (ORCPT ); Mon, 24 Feb 2020 18:28:33 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 548E2293606 Received: by earth.universe (Postfix, from userid 1000) id 2FCDD3C0C9D; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 26/56] drm/omap: dsi: move TE GPIO handling into core Date: Tue, 25 Feb 2020 00:20:56 +0100 Message-Id: <20200224232126.3385250-27-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In preparation for removing custom DSS calls from the DSI panel driver, this moves support for external tearing event GPIOs into the DSI host driver. This way tearing events are always handled in the core resulting in simplification of the panel drivers. The TE GPIO acquisition follows works in the same way as the exynos DSI implementation. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 101 +------------ drivers/gpu/drm/omapdrm/dss/dsi.c | 140 ++++++++++++++++-- 2 files changed, 135 insertions(+), 106 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 79ac1f6b375a..30e48d0de961 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -54,7 +54,6 @@ struct panel_drv_data { /* panel HW configuration from DT or platform data */ struct gpio_desc *reset_gpio; - struct gpio_desc *ext_te_gpio; struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM]; @@ -68,10 +67,6 @@ struct panel_drv_data { bool te_enabled; - atomic_t do_update; - - struct delayed_work te_timeout_work; - bool intro_printed; struct workqueue_struct *workqueue; @@ -83,8 +78,6 @@ struct panel_drv_data { #define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev) -static irqreturn_t dsicm_te_isr(int irq, void *data); -static void dsicm_te_timeout_work_callback(struct work_struct *work); static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable); static int dsicm_panel_reset(struct panel_drv_data *ddata); @@ -240,9 +233,6 @@ static int dsicm_enter_ulps(struct panel_drv_data *ddata) if (r) goto err; - if (ddata->ext_te_gpio) - disable_irq(gpiod_to_irq(ddata->ext_te_gpio)); - src->ops->dsi.disable(src, false, true); ddata->ulps_enabled = true; @@ -271,15 +261,12 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) src->ops->enable(src); ddata->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; - r = _dsicm_enable_te(ddata, true); + r = _dsicm_enable_te(ddata, ddata->te_enabled); if (r) { dev_err(&ddata->dsi->dev, "failed to re-enable TE"); goto err2; } - if (ddata->ext_te_gpio) - enable_irq(gpiod_to_irq(ddata->ext_te_gpio)); - dsicm_queue_ulps_work(ddata); ddata->ulps_enabled = false; @@ -290,11 +277,8 @@ static int dsicm_exit_ulps(struct panel_drv_data *ddata) dev_err(&ddata->dsi->dev, "failed to exit ULPS"); r = dsicm_panel_reset(ddata); - if (!r) { - if (ddata->ext_te_gpio) - enable_irq(gpiod_to_irq(ddata->ext_te_gpio)); + if (!r) ddata->ulps_enabled = false; - } dsicm_queue_ulps_work(ddata); @@ -745,43 +729,6 @@ static void dsicm_framedone_cb(int err, void *data) src->ops->dsi.bus_unlock(src); } -static irqreturn_t dsicm_te_isr(int irq, void *data) -{ - struct panel_drv_data *ddata = data; - struct omap_dss_device *src = ddata->src; - int old; - int r; - - old = atomic_cmpxchg(&ddata->do_update, 1, 0); - - if (old) { - cancel_delayed_work(&ddata->te_timeout_work); - - r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, - ddata); - if (r) - goto err; - } - - return IRQ_HANDLED; -err: - dev_err(&ddata->dsi->dev, "start update failed\n"); - src->ops->dsi.bus_unlock(src); - return IRQ_HANDLED; -} - -static void dsicm_te_timeout_work_callback(struct work_struct *work) -{ - struct panel_drv_data *ddata = container_of(work, struct panel_drv_data, - te_timeout_work.work); - struct omap_dss_device *src = ddata->src; - - dev_err(&ddata->dsi->dev, "TE not received for 250ms!\n"); - - atomic_set(&ddata->do_update, 0); - src->ops->dsi.bus_unlock(src); -} - static int dsicm_update(struct omap_dss_device *dssdev, u16 x, u16 y, u16 w, u16 h) { @@ -809,16 +756,10 @@ static int dsicm_update(struct omap_dss_device *dssdev, if (r) goto err; - if (ddata->te_enabled && ddata->ext_te_gpio) { - schedule_delayed_work(&ddata->te_timeout_work, - msecs_to_jiffies(250)); - atomic_set(&ddata->do_update, 1); - } else { - r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, - ddata); - if (r) - goto err; - } + r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, + ddata); + if (r) + goto err; /* note: no bus_unlock here. unlock is src framedone_cb */ mutex_unlock(&ddata->lock); @@ -840,8 +781,7 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) else r = mipi_dsi_dcs_set_tear_off(dsi); - if (!ddata->ext_te_gpio) - src->ops->dsi.enable_te(src, enable); + src->ops->dsi.enable_te(src, enable); /* possible panel bug */ msleep(100); @@ -934,14 +874,6 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi) return err; } - ddata->ext_te_gpio = devm_gpiod_get_optional(&dsi->dev, "te", - GPIOD_IN); - if (IS_ERR(ddata->ext_te_gpio)) { - err = PTR_ERR(ddata->ext_te_gpio); - dev_err(&dsi->dev, "TE gpio request failed: %d", err); - return err; - } - err = of_get_display_timing(node, "panel-timing", &timing); if (!err) { videomode_from_timing(&timing, &ddata->vm); @@ -1026,25 +958,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi) mutex_init(&ddata->lock); - atomic_set(&ddata->do_update, 0); - - if (ddata->ext_te_gpio) { - r = devm_request_irq(dev, gpiod_to_irq(ddata->ext_te_gpio), - dsicm_te_isr, - IRQF_TRIGGER_RISING, - "taal vsync", ddata); - - if (r) { - dev_err(dev, "IRQ request failed\n"); - goto err_reg; - } - - INIT_DEFERRABLE_WORK(&ddata->te_timeout_work, - dsicm_te_timeout_work_callback); - - dev_dbg(dev, "Using GPIO TE\n"); - } - ddata->workqueue = create_singlethread_workqueue("dsicm_wq"); if (!ddata->workqueue) { r = -ENOMEM; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 15298ebb9d69..7c160512c886 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -371,6 +373,11 @@ struct dsi_data { unsigned int update_bytes; #endif + /* external TE GPIO */ + struct gpio_desc *te_gpio; + struct delayed_work te_timeout_work; + atomic_t do_ext_te_update; + bool te_enabled; bool ulps_enabled; @@ -3834,19 +3841,12 @@ static void dsi_framedone_irq_callback(void *data) dsi_handle_framedone(dsi, 0); } -static int dsi_update(struct omap_dss_device *dssdev, int channel, - void (*callback)(int, void *), void *data) +static int _dsi_update(struct dsi_data *dsi) { - struct dsi_data *dsi = to_dsi_data(dssdev); u16 dw, dh; dsi_perf_mark_setup(dsi); - dsi->update_channel = channel; - - dsi->framedone_callback = callback; - dsi->framedone_data = data; - dw = dsi->vm.hactive; dh = dsi->vm.vactive; @@ -3859,6 +3859,26 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel, return 0; } +static int dsi_update(struct omap_dss_device *dssdev, int channel, + void (*callback)(int, void *), void *data) +{ + struct dsi_data *dsi = to_dsi_data(dssdev); + + dsi->update_channel = channel; + dsi->framedone_callback = callback; + dsi->framedone_data = data; + + if (dsi->te_enabled && dsi->te_gpio) { + schedule_delayed_work(&dsi->te_timeout_work, + msecs_to_jiffies(250)); + atomic_set(&dsi->do_ext_te_update, 1); + } else { + _dsi_update(dsi); + } + + return 0; +} + /* Display funcs */ static int dsi_configure_dispc_clocks(struct dsi_data *dsi) @@ -4102,6 +4122,14 @@ static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable) struct dsi_data *dsi = to_dsi_data(dssdev); dsi->te_enabled = enable; + + if (dsi->te_gpio) { + if (enable) + enable_irq(gpiod_to_irq(dsi->te_gpio)); + else + disable_irq(gpiod_to_irq(dsi->te_gpio)); + } + return 0; } @@ -4779,11 +4807,91 @@ static const struct omap_dss_device_ops dsi_ops = { }, }; +static irqreturn_t omap_dsi_te_irq_handler(int irq, void *dev_id) +{ + struct dsi_data *dsi = (struct dsi_data*) dev_id; + int old; + + old = atomic_cmpxchg(&dsi->do_ext_te_update, 1, 0); + if (old) { + cancel_delayed_work(&dsi->te_timeout_work); + _dsi_update(dsi); + } + + return IRQ_HANDLED; +} + +static void omap_dsi_te_timeout_work_callback(struct work_struct *work) +{ + struct dsi_data *dsi = container_of(work, struct dsi_data, + te_timeout_work.work); + int old; + + old = atomic_cmpxchg(&dsi->do_ext_te_update, 1, 0); + if (old) { + dev_err(dsi->dev, "TE not received for 250ms!\n"); + _dsi_update(dsi); + } + + return; +} + +static int omap_dsi_register_te_irq(struct dsi_data *dsi, + struct mipi_dsi_device *client) +{ + int err; + int te_irq; + + dsi->te_gpio = gpiod_get_from_of_node(client->dev.of_node, + "te-gpios", 0, GPIOD_IN, + "dsi-tearing-effect"); + if (IS_ERR(dsi->te_gpio)) { + err = PTR_ERR(dsi->te_gpio); + + if (err == -ENOENT) { + dsi->te_gpio = NULL; + return 0; + } else { + dev_err(dsi->dev, "Could not get TE gpio: %d\n", err); + return err; + } + } + + te_irq = gpiod_to_irq(dsi->te_gpio); + irq_set_status_flags(te_irq, IRQ_NOAUTOEN); + + err = request_threaded_irq(te_irq, omap_dsi_te_irq_handler, NULL, + IRQF_TRIGGER_RISING, "TE", dsi); + if (err) { + dev_err(dsi->dev, "request irq failed with %d\n", err); + gpiod_put(dsi->te_gpio); + return err; + } + + INIT_DEFERRABLE_WORK(&dsi->te_timeout_work, + omap_dsi_te_timeout_work_callback); + + dev_dbg(dsi->dev, "Using GPIO TE\n"); + + return 0; +} + +static void omap_dsi_unregister_te_irq(struct dsi_data *dsi) +{ + if (dsi->te_gpio) { + free_irq(gpiod_to_irq(dsi->te_gpio), dsi); + cancel_delayed_work(&dsi->te_timeout_work); + gpiod_put(dsi->te_gpio); + dsi->te_gpio = NULL; + } +} + int omap_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *client) { struct dsi_data *dsi = host_to_omap(host); unsigned int channel = client->channel; + int r; if (channel > 3) return -EINVAL; @@ -4793,13 +4901,20 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host, return -EBUSY; } - dsi->vc[channel].dest = client; + atomic_set(&dsi->do_ext_te_update, 0); - dsi->pix_fmt = client->format; - if (client->mode_flags & MIPI_DSI_MODE_VIDEO) + if (client->mode_flags & MIPI_DSI_MODE_VIDEO) { dsi->mode = OMAP_DSS_DSI_VIDEO_MODE; - else + } else { + r = omap_dsi_register_te_irq(dsi, client); + if (r) + return r; + dsi->mode = OMAP_DSS_DSI_CMD_MODE; + } + + dsi->vc[channel].dest = client; + dsi->pix_fmt = client->format; return 0; } @@ -4816,6 +4931,7 @@ int omap_dsi_host_detach(struct mipi_dsi_host *host, if (dsi->vc[channel].dest != client) return -EINVAL; + omap_dsi_unregister_te_irq(dsi); dsi->vc[channel].dest = NULL; return 0; } From patchwork Mon Feb 24 23:20:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB041C11D3D for ; Mon, 24 Feb 2020 23:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACC1D2176D for ; Mon, 24 Feb 2020 23:28:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728316AbgBXX2d (ORCPT ); Mon, 24 Feb 2020 18:28:33 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60544 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgBXX2c (ORCPT ); Mon, 24 Feb 2020 18:28:32 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id EE0D62935F4 Received: by earth.universe (Postfix, from userid 1000) id 364BB3C0C9E; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 27/56] drm/omap: dsi: drop custom enable_te() API Date: Tue, 25 Feb 2020 00:20:57 +0100 Message-Id: <20200224232126.3385250-28-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Instead of using the custon enable_te() API, this automatically enables/disables TE core support when a matching packet is send to the panel. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 -- drivers/gpu/drm/omapdrm/dss/dsi.c | 33 ++++++++++++++----- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 -- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 30e48d0de961..e4ffe34324f8 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -772,7 +772,6 @@ static int dsicm_update(struct omap_dss_device *dssdev, static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) { - struct omap_dss_device *src = ddata->src; struct mipi_dsi_device *dsi = ddata->dsi; int r; @@ -781,8 +780,6 @@ static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) else r = mipi_dsi_dcs_set_tear_off(dsi); - src->ops->dsi.enable_te(src, enable); - /* possible panel bug */ msleep(100); diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 7c160512c886..50a567ebfb86 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -4117,10 +4117,8 @@ static void dsi_display_disable(struct omap_dss_device *dssdev, mutex_unlock(&dsi->lock); } -static int dsi_enable_te(struct omap_dss_device *dssdev, bool enable) +static int dsi_enable_te(struct dsi_data *dsi, bool enable) { - struct dsi_data *dsi = to_dsi_data(dssdev); - dsi->te_enabled = enable; if (dsi->te_gpio) { @@ -4730,6 +4728,7 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host, { struct dsi_data *dsi = host_to_omap(host); struct omap_dss_device *dssdev = &dsi->output; + int r; if (NEQV(msg->flags & MIPI_DSI_MSG_USE_LPM, dsi->in_lp_mode)) { dsi_vc_enable_hs(dssdev, msg->channel, @@ -4746,16 +4745,34 @@ static ssize_t omap_dsi_host_transfer(struct mipi_dsi_host *host, case MIPI_DSI_DCS_LONG_WRITE: case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: case MIPI_DSI_NULL_PACKET: - return dsi_vc_write_common(dssdev, msg); + r = dsi_vc_write_common(dssdev, msg); + break; case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: - return dsi_vc_generic_read(dssdev, msg); + r = dsi_vc_generic_read(dssdev, msg); + break; case MIPI_DSI_DCS_READ: - return dsi_vc_dcs_read(dssdev, msg); + r = dsi_vc_dcs_read(dssdev, msg); + break; + default: + r = -EINVAL; + break; } - return -EINVAL; + if (r < 0) + return r; + + if (msg->type == MIPI_DSI_DCS_SHORT_WRITE || + msg->type == MIPI_DSI_DCS_SHORT_WRITE_PARAM) { + u8 cmd = ((u8*) msg->tx_buf)[0]; + if (cmd == MIPI_DCS_SET_TEAR_OFF) + dsi_enable_te(dsi, false); + else if(cmd == MIPI_DCS_SET_TEAR_ON) + dsi_enable_te(dsi, true); + } + + return 0; } static int dsi_get_clocks(struct dsi_data *dsi) @@ -4802,8 +4819,6 @@ static const struct omap_dss_device_ops dsi_ops = { .disable_video_output = dsi_disable_video_output, .update = dsi_update, - - .enable_te = dsi_enable_te, }, }; diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 355aa235c23c..dc41f982a082 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -287,8 +287,6 @@ struct omapdss_dsi_ops { int (*set_config)(struct omap_dss_device *dssdev, const struct omap_dss_dsi_config *cfg); - int (*enable_te)(struct omap_dss_device *dssdev, bool enable); - int (*update)(struct omap_dss_device *dssdev, int channel, void (*callback)(int, void *), void *data); From patchwork Mon Feb 24 23:21:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 395D8C34031 for ; Mon, 24 Feb 2020 23:28:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 188BB222D9 for ; Mon, 24 Feb 2020 23:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgBXX2b (ORCPT ); Mon, 24 Feb 2020 18:28:31 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60484 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728226AbgBXX2b (ORCPT ); Mon, 24 Feb 2020 18:28:31 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 0AA66283B8F Received: by earth.universe (Postfix, from userid 1000) id 477833C0CA1; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 30/56] drm/dsi: add MIPI_DSI_MODE_ULPS_IDLE Date: Tue, 25 Feb 2020 00:21:00 +0100 Message-Id: <20200224232126.3385250-31-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org DSI command mode panels are self-refreshing displays, that can be updated very rarely for static images. For this kind of scenario some panels support, that the DSI bus switches into ULPS mode until the panel needs to be refreshed. This is problematic on some panels, so introduce a flag to signal the DSI host implementation that the panel allows going into ULPS mode. Signed-off-by: Sebastian Reichel --- include/drm/drm_mipi_dsi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 360e6377e84b..f36f89c14b4a 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -132,6 +132,8 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); #define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10) /* transmit data in low power */ #define MIPI_DSI_MODE_LPM BIT(11) +/* allow going into ULPS mode while command mode panel is not updated */ +#define MIPI_DSI_MODE_ULPS_IDLE BIT(12) enum mipi_dsi_pixel_format { MIPI_DSI_FMT_RGB888, From patchwork Mon Feb 24 23:21:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B27FC38C09 for ; Mon, 24 Feb 2020 23:21:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFBE224682 for ; Mon, 24 Feb 2020 23:21:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728529AbgBXXVm (ORCPT ); Mon, 24 Feb 2020 18:21:42 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59906 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbgBXXVl (ORCPT ); Mon, 24 Feb 2020 18:21:41 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id D3F51293AA3 Received: by earth.universe (Postfix, from userid 1000) id 52A033C0CA3; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 32/56] drm/omap: dsi: move panel refresh function to host Date: Tue, 25 Feb 2020 00:21:02 +0100 Message-Id: <20200224232126.3385250-33-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This moves the panel refresh/update function from the panel driver into the DSI host driver to prepare for common drm_panel support. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 68 ------------ drivers/gpu/drm/omapdrm/dss/dsi.c | 101 ++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/omapdss.h | 13 +-- drivers/gpu/drm/omapdrm/omap_crtc.c | 11 +- 4 files changed, 97 insertions(+), 96 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 1e33cf7c1448..5a2a8cee9186 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -177,27 +177,6 @@ static int dsicm_get_id(struct panel_drv_data *ddata, u8 *id1, u8 *id2, u8 *id3) return 0; } -static int dsicm_set_update_window(struct panel_drv_data *ddata, - u16 x, u16 y, u16 w, u16 h) -{ - struct mipi_dsi_device *dsi = ddata->dsi; - int r; - u16 x1 = x; - u16 x2 = x + w - 1; - u16 y1 = y; - u16 y2 = y + h - 1; - - r = mipi_dsi_dcs_set_column_address(dsi, x1, x2); - if (r < 0) - return r; - - r = mipi_dsi_dcs_set_page_address(dsi, y1, y2); - if (r < 0) - return r; - - return 0; -} - static int dsicm_bl_update_status(struct backlight_device *dev) { struct panel_drv_data *ddata = dev_get_drvdata(&dev->dev); @@ -470,48 +449,6 @@ static void dsicm_disable(struct omap_dss_device *dssdev) mutex_unlock(&ddata->lock); } -static void dsicm_framedone_cb(int err, void *data) -{ - struct panel_drv_data *ddata = data; - - dev_dbg(&ddata->dsi->dev, "framedone, err %d\n", err); - mutex_unlock(&ddata->lock); -} - -static int dsicm_update(struct omap_dss_device *dssdev, - u16 x, u16 y, u16 w, u16 h) -{ - struct panel_drv_data *ddata = to_panel_data(dssdev); - struct omap_dss_device *src = ddata->src; - int r; - - dev_dbg(&ddata->dsi->dev, "update %d, %d, %d x %d\n", x, y, w, h); - - mutex_lock(&ddata->lock); - - if (!ddata->enabled) { - r = 0; - goto err; - } - - /* XXX no need to send this every frame, but dsi break if not done */ - r = dsicm_set_update_window(ddata, 0, 0, ddata->vm.hactive, - ddata->vm.vactive); - if (r) - goto err; - - r = src->ops->dsi.update(src, ddata->dsi->channel, dsicm_framedone_cb, - ddata); - if (r) - goto err; - - /* note: no unlock here. unlock is src framedone_cb */ - return 0; -err: - mutex_unlock(&ddata->lock); - return r; -} - static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable) { struct mipi_dsi_device *dsi = ddata->dsi; @@ -572,10 +509,6 @@ static const struct omap_dss_device_ops dsicm_ops = { .check_timings = dsicm_check_timings, }; -static const struct omap_dss_driver dsicm_dss_driver = { - .update = dsicm_update, -}; - static int dsicm_probe_of(struct mipi_dsi_device *dsi) { struct device_node *node = dsi->dev.of_node; @@ -660,7 +593,6 @@ static int dsicm_probe(struct mipi_dsi_device *dsi) dssdev = &ddata->dssdev; dssdev->dev = dev; dssdev->ops = &dsicm_ops; - dssdev->driver = &dsicm_dss_driver; dssdev->type = OMAP_DISPLAY_TYPE_DSI; dssdev->display = true; dssdev->owner = THIS_MODULE; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 12d661ad37ad..b0e796f90fca 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -217,6 +217,9 @@ static void dsi_display_uninit_dispc(struct dsi_data *dsi); static int dsi_vc_send_null(struct dsi_data *dsi, int channel); +static ssize_t _omap_dsi_host_transfer(struct dsi_data *dsi, + const struct mipi_dsi_msg *msg); + /* DSI PLL HSDIV indices */ #define HSDIV_DISPC 0 #define HSDIV_DSI 1 @@ -386,9 +389,6 @@ struct dsi_data { struct delayed_work ulps_work; - void (*framedone_callback)(int, void *); - void *framedone_data; - struct delayed_work framedone_timeout_work; #ifdef DSI_CATCH_MISSING_TE @@ -3809,8 +3809,6 @@ static void dsi_handle_framedone(struct dsi_data *dsi, int error) dsi_set_ulps_auto(dsi, true); dsi_bus_unlock(dsi); - dsi->framedone_callback(error, dsi->framedone_data); - if (!error) dsi_perf_show(dsi, "DISPC"); } @@ -3842,6 +3840,8 @@ static void dsi_framedone_irq_callback(void *data) cancel_delayed_work(&dsi->framedone_timeout_work); + DSSDBG("Framedone received!\n"); + dsi_handle_framedone(dsi, 0); } @@ -3863,17 +3863,69 @@ static int _dsi_update(struct dsi_data *dsi) return 0; } -static int dsi_update(struct omap_dss_device *dssdev, int channel, - void (*callback)(int, void *), void *data) +static int _dsi_update_window(struct dsi_data *dsi, int channel, + int x, int y, int w, int h) +{ + int x1 = x, x2 = (x + w - 1); + int y1 = y, y2 = (y + h - 1); + u8 payloadX[5] = { MIPI_DCS_SET_COLUMN_ADDRESS, + x1 >> 8, x1 & 0xff, x2 >> 8, x2 & 0xff }; + u8 payloadY[5] = { MIPI_DCS_SET_PAGE_ADDRESS, + y1 >> 8, y1 & 0xff, y2 >> 8, y2 & 0xff }; + struct mipi_dsi_msg msgX = { 0 }, msgY = { 0 }; + int ret; + + WARN_ON(!dsi_bus_is_locked(dsi)); + + msgX.type = MIPI_DSI_DCS_LONG_WRITE; + msgX.channel = channel; + msgX.tx_buf = payloadX; + msgX.tx_len = sizeof(payloadX); + + msgY.type = MIPI_DSI_DCS_LONG_WRITE; + msgY.channel = channel; + msgY.tx_buf = payloadY; + msgY.tx_len = sizeof(payloadY); + + ret = _omap_dsi_host_transfer(dsi, &msgX); + if (ret != 0) + return ret; + + return _omap_dsi_host_transfer(dsi, &msgY); +} + +static int dsi_update_channel(struct omap_dss_device *dssdev, int channel) { struct dsi_data *dsi = to_dsi_data(dssdev); + int r; + + if (channel > 3) + return -EINVAL; dsi_bus_lock(dsi); + + if (!dsi->vc[channel].dest) { + r = -ENODEV; + goto err; + } + + if (dsi->vm.hactive == 0 || dsi->vm.vactive == 0) { + r = -EINVAL; + goto err; + } + + DSSDBG("dsi_update_channel: %d", channel); + dsi_set_ulps_auto(dsi, false); + r = _dsi_update_window(dsi, channel, 0, 0, dsi->vm.hactive, + dsi->vm.vactive); + if (r < 0) { + DSSWARN("window update error: %d\n", r); + goto err; + } + dsi->update_channel = channel; - dsi->framedone_callback = callback; - dsi->framedone_data = data; if (dsi->te_enabled && dsi->te_gpio) { schedule_delayed_work(&dsi->te_timeout_work, @@ -3883,6 +3935,24 @@ static int dsi_update(struct omap_dss_device *dssdev, int channel, _dsi_update(dsi); } + return 0; + +err: + dsi_set_ulps_auto(dsi, true); + dsi_bus_unlock(dsi); + return r; +} + +static int dsi_update_all(struct omap_dss_device *dssdev) +{ + int i, r; + + for (i = 0; i < 4; i++) { + r = dsi_update_channel(dssdev, i); + if (r != -ENODEV) + return r; + } + return 0; } @@ -4102,7 +4172,9 @@ static void dsi_display_enable(struct omap_dss_device *dssdev) { struct dsi_data *dsi = to_dsi_data(dssdev); DSSDBG("dsi_display_enable\n"); + dsi_bus_lock(dsi); dsi_display_ulps_enable(dsi); + dsi_bus_unlock(dsi); } static void dsi_display_ulps_disable(struct dsi_data *dsi, @@ -4128,7 +4200,9 @@ static void dsi_display_disable(struct omap_dss_device *dssdev) { struct dsi_data *dsi = to_dsi_data(dssdev); DSSDBG("dsi_display_disable\n"); + dsi_bus_lock(dsi); dsi_display_ulps_disable(dsi, true, false); + dsi_bus_unlock(dsi); } static int dsi_enable_te(struct dsi_data *dsi, bool enable) @@ -4876,7 +4950,7 @@ static const struct omap_dss_device_ops dsi_ops = { .enable_video_output = dsi_enable_video_output, .disable_video_output = dsi_disable_video_output, - .update = dsi_update, + .update = dsi_update_all, }, }; @@ -4974,14 +5048,18 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host, return -EBUSY; } + dsi_bus_lock(dsi); + atomic_set(&dsi->do_ext_te_update, 0); if (client->mode_flags & MIPI_DSI_MODE_VIDEO) { dsi->mode = OMAP_DSS_DSI_VIDEO_MODE; } else { r = omap_dsi_register_te_irq(dsi, client); - if (r) + if (r) { + dsi_bus_unlock(dsi); return r; + } dsi->mode = OMAP_DSS_DSI_CMD_MODE; } @@ -4995,6 +5073,7 @@ int omap_dsi_host_attach(struct mipi_dsi_host *host, dsi->ulps_auto_idle = !!(client->mode_flags & MIPI_DSI_MODE_ULPS_IDLE); dsi_set_ulps_auto(dsi, true); + dsi_bus_unlock(dsi); return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index e2643623b5f2..d7081086c2b1 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -280,13 +280,12 @@ struct omap_dss_writeback_info { }; struct omapdss_dsi_ops { - /* bus configuration */ + int (*update)(struct omap_dss_device *dssdev); + + /* legacy API used by omapdss panels */ int (*set_config)(struct omap_dss_device *dssdev, const struct omap_dss_dsi_config *cfg); - int (*update)(struct omap_dss_device *dssdev, int channel, - void (*callback)(int, void *), void *data); - int (*enable_video_output)(struct omap_dss_device *dssdev, int channel); void (*disable_video_output)(struct omap_dss_device *dssdev, int channel); @@ -350,7 +349,6 @@ struct omap_dss_device { const char *name; - const struct omap_dss_driver *driver; const struct omap_dss_device_ops *ops; unsigned long ops_flags; u32 bus_flags; @@ -371,11 +369,6 @@ struct omap_dss_device { unsigned int of_port; }; -struct omap_dss_driver { - int (*update)(struct omap_dss_device *dssdev, - u16 x, u16 y, u16 w, u16 h); -}; - struct dss_device *omapdss_get_dss(void); void omapdss_set_dss(struct dss_device *dss); static inline bool omapdss_is_initialized(void) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 3f78ce2f85a1..c924d77207fb 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -362,10 +362,8 @@ static void omap_crtc_manual_display_update(struct work_struct *data) { struct omap_crtc *omap_crtc = container_of(data, struct omap_crtc, update_work.work); - struct drm_display_mode *mode = &omap_crtc->pipe->crtc->mode; - struct omap_dss_device *dssdev = omap_crtc->pipe->output->next; + struct omap_dss_device *dssdev = omap_crtc->pipe->output; struct drm_device *dev = omap_crtc->base.dev; - const struct omap_dss_driver *dssdrv; int ret; if (!dssdev) { @@ -373,13 +371,12 @@ static void omap_crtc_manual_display_update(struct work_struct *data) return; } - dssdrv = dssdev->driver; - if (!dssdrv || !dssdrv->update) { - dev_err_once(dev->dev, "missing or incorrect dssdrv!"); + if (dssdev->type != OMAP_DISPLAY_TYPE_DSI || !dssdev->ops->dsi.update) { + dev_err_once(dev->dev, "no DSI update callback found!"); return; } - ret = dssdrv->update(dssdev, 0, 0, mode->hdisplay, mode->vdisplay); + ret = dssdev->ops->dsi.update(dssdev); if (ret < 0) { spin_lock_irq(&dev->event_lock); omap_crtc->pending = false; From patchwork Mon Feb 24 23:21:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 211643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03BCAC38C1B for ; Mon, 24 Feb 2020 23:21:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEF6320732 for ; Mon, 24 Feb 2020 23:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbgBXXVs (ORCPT ); Mon, 24 Feb 2020 18:21:48 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59826 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728515AbgBXXVn (ORCPT ); Mon, 24 Feb 2020 18:21:43 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 4B12C293E8A Received: by earth.universe (Postfix, from userid 1000) id 6582B3C0CA6; Tue, 25 Feb 2020 00:21:31 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Laurent Pinchart , Tomi Valkeinen Cc: Tony Lindgren , Merlijn Wajer , "H. Nikolaus Schaller" , Rob Herring , linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@collabora.com, Sebastian Reichel Subject: [PATCHv2 35/56] drm/omap: dsi: convert to drm_panel Date: Tue, 25 Feb 2020 00:21:05 +0100 Message-Id: <20200224232126.3385250-36-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224232126.3385250-1-sebastian.reichel@collabora.com> References: <20200224232126.3385250-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This converts the DSI module to expect common drm_panel display drivers instead of dssdev based ones. Signed-off-by: Sebastian Reichel --- .../gpu/drm/omapdrm/displays/panel-dsi-cm.c | 210 +++++++----------- drivers/gpu/drm/omapdrm/dss/dsi.c | 133 +++++++++-- .../gpu/drm/omapdrm/dss/omapdss-boot-init.c | 1 - drivers/gpu/drm/omapdrm/dss/omapdss.h | 8 - 4 files changed, 193 insertions(+), 159 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c index 30be9e4ab908..803b7dada343 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c @@ -6,8 +6,6 @@ * Author: Tomi Valkeinen */ -/* #define DEBUG */ - #include #include #include @@ -20,11 +18,14 @@ #include #include +#include +#include +#include +#include