From patchwork Tue Sep 22 07:55:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 7236161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D7AD6BEEC1 for ; Tue, 22 Sep 2015 07:58:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C942F2070D for ; Tue, 22 Sep 2015 07:58:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C85F02070C for ; Tue, 22 Sep 2015 07:58:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeIR8-0003h2-BG; Tue, 22 Sep 2015 07:56:26 +0000 Received: from lucky1.263xmail.com ([211.157.147.130]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZeIR5-0003V9-E0; Tue, 22 Sep 2015 07:56:24 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.230]) by lucky1.263xmail.com (Postfix) with SMTP id 5C40E1E552D; Tue, 22 Sep 2015 15:55:59 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 04D8B485; Tue, 22 Sep 2015 15:55:54 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: inki.dae@samsung.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 3107213MGYF; Tue, 22 Sep 2015 15:55:59 +0800 (CST) From: Yakir Yang To: Inki Dae , Andrzej Hajda , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Jingoo Han , Heiko Stuebner , Mark Yao , Thierry Reding , joe@perches.com, Krzysztof Kozlowski , Rob Herring Subject: [PATCH v5 12/17] drm: rockchip: vop: add bpc and color mode setting Date: Tue, 22 Sep 2015 15:55:51 +0800 Message-Id: <1442908551-7232-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442906428-2609-1-git-send-email-ykk@rock-chips.com> References: <1442906428-2609-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150922_005623_858500_259236F9 X-CRM114-Status: GOOD ( 16.88 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , djkurtz@chromium.org, dianders@chromium.org, Yakir Yang , Gustavo Padovan , linux-samsung-soc@vger.kernel.org, Russell King , Kishon Vijay Abraham I , linux-rockchip@lists.infradead.org, Kukjin Kim , robherring2@gmail.com, devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Mark Yao , Sean Paul , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, emil.l.velikov@gmail.com, linux-kernel@vger.kernel.org, Kumar Gala , ajaynumb@gmail.com, Andy Yan MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mark Yao Add bpc and color mode setting in rockchip_drm_vop driver, so connector could try to use the edid drm_display_info to config vop output mode. Signed-off-by: Mark Yao Signed-off-by: Yakir Yang --- Changes in v5: - Fix compiled error (Heiko) - Using the connector display info message to configure eDP driver input video mode, but hard code CRTC video output mode to RGBaaa. Changes in v4: None Changes in v3: None Changes in v2: None drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 25 +++++++++++++++---- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 32 ++++++++++++++++++++++--- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index 2c82a9a..3990951 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -180,14 +180,29 @@ static void rockchip_dp_drm_encoder_mode_set(struct drm_encoder *encoder, static void rockchip_dp_drm_encoder_prepare(struct drm_encoder *encoder) { struct rockchip_dp_device *dp = to_dp(encoder); + struct drm_connector *cn = &dp->connector; + int ret = -1; u32 val; - int ret; - ret = rockchip_drm_crtc_mode_config(encoder->crtc, - DRM_MODE_CONNECTOR_eDP, - ROCKCHIP_OUT_MODE_AAAA); + /* + * FIXME(Yakir): driver should configure the CRTC output video + * mode with the display information which indicated the monitor + * support colorimetry. + * + * But don't know why the CRTC driver seems could only output the + * RGBaaa rightly. For example, if connect the "innolux,n116bge" + * eDP screen, EDID would indicated that screen only accepted the + * 6bpc mode. But if I configure CRTC to RGB666 output, then eDP + * screen would show a blue picture (RGB888 show a green picture). + * But if I configure CTRC to RGBaaa, and eDP driver still keep + * RGB666 input video mode, then screen would works prefect. + */ + if (cn->display_info.color_formats & DRM_COLOR_FORMAT_RGB444) + ret = rockchip_drm_crtc_mode_config(encoder->crtc, + DRM_MODE_CONNECTOR_eDP, + 10, DRM_COLOR_FORMAT_RGB444); if (ret < 0) { - dev_err(dp->dev, "Could not set crtc mode config: %d.\n", ret); + dev_err(dp->dev, "Could not set crtc mode config (%d)\n", ret); return; } diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index 80d6fc8..428a3c1 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -215,7 +215,7 @@ static void dw_hdmi_rockchip_encoder_commit(struct drm_encoder *encoder) static void dw_hdmi_rockchip_encoder_prepare(struct drm_encoder *encoder) { rockchip_drm_crtc_mode_config(encoder->crtc, DRM_MODE_CONNECTOR_HDMIA, - ROCKCHIP_OUT_MODE_AAAA); + 10, DRM_COLOR_FORMAT_RGB444); } static struct drm_encoder_helper_funcs dw_hdmi_rockchip_encoder_helper_funcs = { diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index dc4e5f0..ef1d7fb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -59,7 +59,7 @@ void rockchip_unregister_crtc_funcs(struct drm_device *dev, int pipe); int rockchip_drm_encoder_get_mux_id(struct device_node *node, struct drm_encoder *encoder); int rockchip_drm_crtc_mode_config(struct drm_crtc *crtc, int connector_type, - int out_mode); + int bpc, int color); int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, struct device *dev); void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 5d8ae5e..9ef4a1f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1062,14 +1062,40 @@ static const struct drm_plane_funcs vop_plane_funcs = { int rockchip_drm_crtc_mode_config(struct drm_crtc *crtc, int connector_type, - int out_mode) + int bpc, int color) { struct vop *vop = to_vop(crtc); + /* + * RK3288 vop only support RGB Color output. + */ + if (color != DRM_COLOR_FORMAT_RGB444) { + DRM_ERROR("Only support output RGB444, not support%d\n", + color); + return -EINVAL; + } + vop->connector_type = connector_type; - vop->connector_out_mode = out_mode; - return 0; + /* + * Fixme: I don't know how to describe the ROCKCHIP_OUT_MODE_P565's + * bpc, 5 or 6? + */ + if (bpc >= 10) { + bpc = 10; + vop->connector_out_mode = ROCKCHIP_OUT_MODE_AAAA; + } else if (bpc >= 8) { + bpc = 8; + vop->connector_out_mode = ROCKCHIP_OUT_MODE_P888; + } else if (bpc >= 6) { + bpc = 6; + vop->connector_out_mode = ROCKCHIP_OUT_MODE_P666; + } else { + DRM_ERROR("unsupport bpc %d\n", bpc); + return -EINVAL; + } + + return bpc; } EXPORT_SYMBOL_GPL(rockchip_drm_crtc_mode_config);