From patchwork Mon Jan 30 11:05:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9544817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 988F360417 for ; Mon, 30 Jan 2017 11:05:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7985E2837F for ; Mon, 30 Jan 2017 11:05:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DD8128389; Mon, 30 Jan 2017 11:05:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA3832837F for ; Mon, 30 Jan 2017 11:05:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E8466E3EA; Mon, 30 Jan 2017 11:05:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) by gabe.freedesktop.org (Postfix) with ESMTPS id DBCC26E3E2 for ; Mon, 30 Jan 2017 11:05:27 +0000 (UTC) Received: by mail-wm0-x22f.google.com with SMTP id b65so27421929wmf.0 for ; Mon, 30 Jan 2017 03:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HWkTTqqcFtnZz2ISxGenSPuMQz2f1tjIzZbUEzvISaM=; b=Qcb9iEdJDJDStjVDu9wNKm501Kbkjhyxwyiv3npy0+KOlo7qeMFjprwVaRJJ7E2lWY hEus90FmTcg0heE6Jf9qAhGFhEzhmfkk9UeZk6tFUBggtFCgSCu8TzL4fZvE6W7lqbYY AFkUpQ7p7t7QkJx1XX29slJ+YwYl2tPhL8/LvcsJJTpivYA4wqnidQYliwplvnGIzoSF ZpLp/NPP7xmWbMmdr7CoyzmxutTGhkT/GZdTNSojdYY2LajqqFr7eYYGnM4EbbGgtBvB bpUy5NizpZnONo+azc2GsfDu43RyszdMzWLGRiUrP+mG+ttKb6XbnB7aGtUP1ZA1hOQB H9Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HWkTTqqcFtnZz2ISxGenSPuMQz2f1tjIzZbUEzvISaM=; b=fPwuVn6BsRHM1MeUntuO69YKAjIaIQo1iiSeo8jXyhdGZPDP8cdmuGOBjlMaX+JDpH drt7xdq7oL0O1fke4TfoTLaHi3WYbkyzOVfy2NXO54RoQ+pXsjvl/HdSA/odANX2//SP TW6B68IYhMAP/TmbSX+WWVYYqprh4BG0gS3LPDXwOSDB6e3sdc2SFWH92J0ghx1LLEu2 cfQU+hAeisSCRDUMlmUmLSKgvrKIASDrWJlTctB3b48f/ehopxx1++Wf2RiRHgwhZ8p+ iA2g8cEYinnM1cJmluRc1I7aKbAS5QVHbq6DgEBSes1Z2ztAWiIKIbQU1S/RCdKu/Yr5 /V+Q== X-Gm-Message-State: AIkVDXIcFyjKCV0tzwzOKT/yljokPBAX3WYwHHJSqrAYmIywjcGqO/La+yW51dai0HsM4FD4 X-Received: by 10.28.206.136 with SMTP id e130mr13046207wmg.121.1485774326423; Mon, 30 Jan 2017 03:05:26 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id k195sm18165651wmd.7.2017.01.30.03.05.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Jan 2017 03:05:25 -0800 (PST) From: Neil Armstrong To: dri-devel@lists.freedesktop.org, laurent.pinchart+renesas@ideasonboard.com Subject: [PATCH 4/4] drm: bridge: dw-hdmi: Take input format from plat_data Date: Mon, 30 Jan 2017 12:05:18 +0100 Message-Id: <1485774318-21916-5-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485774318-21916-1-git-send-email-narmstrong@baylibre.com> References: <1485774318-21916-1-git-send-email-narmstrong@baylibre.com> Cc: Jose.Abreu@synopsys.com, linux-amlogic@lists.infradead.org, kieran.bingham@ideasonboard.com, linux-kernel@vger.kernel.org, Neil Armstrong X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some display pipelines can only provide non-RBG input pixels to the HDMI TX Controller, this patch takes the pixel format from the plat_data if provided. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/dw-hdmi.c | 55 ++++++++++++++++++++-------------------- include/drm/bridge/dw_hdmi.h | 14 ++++++++-- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index f75e5f9..f4ba019 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -35,12 +35,6 @@ #define HDMI_EDID_LEN 512 -#define RGB 0 -#define YCBCR444 1 -#define YCBCR422_16BITS 2 -#define YCBCR422_8BITS 3 -#define XVYCC444 4 - enum hdmi_datamap { RGB444_8B = 0x01, RGB444_10B = 0x03, @@ -548,7 +542,7 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi) int color_format = 0; u8 val; - if (hdmi->hdmi_data.enc_in_format == RGB) { + if (hdmi->hdmi_data.enc_in_format == DW_HDMI_ENC_FMT_RGB) { if (hdmi->hdmi_data.enc_color_depth == 8) color_format = 0x01; else if (hdmi->hdmi_data.enc_color_depth == 10) @@ -559,7 +553,7 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi) color_format = 0x07; else return; - } else if (hdmi->hdmi_data.enc_in_format == YCBCR444) { + } else if (hdmi->hdmi_data.enc_in_format == DW_HDMI_ENC_FMT_YCBCR444) { if (hdmi->hdmi_data.enc_color_depth == 8) color_format = 0x09; else if (hdmi->hdmi_data.enc_color_depth == 10) @@ -570,7 +564,8 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi) color_format = 0x0F; else return; - } else if (hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) { + } else if (hdmi->hdmi_data.enc_in_format == + DW_HDMI_ENC_FMT_YCBCR422_8BITS) { if (hdmi->hdmi_data.enc_color_depth == 8) color_format = 0x16; else if (hdmi->hdmi_data.enc_color_depth == 10) @@ -606,20 +601,20 @@ static int is_color_space_conversion(struct dw_hdmi *hdmi) static int is_color_space_decimation(struct dw_hdmi *hdmi) { - if (hdmi->hdmi_data.enc_out_format != YCBCR422_8BITS) + if (hdmi->hdmi_data.enc_out_format != DW_HDMI_ENC_FMT_YCBCR422_8BITS) return 0; - if (hdmi->hdmi_data.enc_in_format == RGB || - hdmi->hdmi_data.enc_in_format == YCBCR444) + if (hdmi->hdmi_data.enc_in_format == DW_HDMI_ENC_FMT_RGB || + hdmi->hdmi_data.enc_in_format == DW_HDMI_ENC_FMT_YCBCR444) return 1; return 0; } static int is_color_space_interpolation(struct dw_hdmi *hdmi) { - if (hdmi->hdmi_data.enc_in_format != YCBCR422_8BITS) + if (hdmi->hdmi_data.enc_in_format != DW_HDMI_ENC_FMT_YCBCR422_8BITS) return 0; - if (hdmi->hdmi_data.enc_out_format == RGB || - hdmi->hdmi_data.enc_out_format == YCBCR444) + if (hdmi->hdmi_data.enc_out_format == DW_HDMI_ENC_FMT_RGB || + hdmi->hdmi_data.enc_out_format == DW_HDMI_ENC_FMT_YCBCR444) return 1; return 0; } @@ -631,13 +626,14 @@ static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) u32 csc_scale = 1; if (is_color_space_conversion(hdmi)) { - if (hdmi->hdmi_data.enc_out_format == RGB) { + if (hdmi->hdmi_data.enc_out_format == DW_HDMI_ENC_FMT_RGB) { if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) csc_coeff = &csc_coeff_rgb_out_eitu601; else csc_coeff = &csc_coeff_rgb_out_eitu709; - } else if (hdmi->hdmi_data.enc_in_format == RGB) { + } else if (hdmi->hdmi_data.enc_in_format == + DW_HDMI_ENC_FMT_RGB) { if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) csc_coeff = &csc_coeff_rgb_in_eitu601; @@ -709,8 +705,8 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; u8 val, vp_conf; - if (hdmi_data->enc_out_format == RGB || - hdmi_data->enc_out_format == YCBCR444) { + if (hdmi_data->enc_out_format == DW_HDMI_ENC_FMT_RGB || + hdmi_data->enc_out_format == DW_HDMI_ENC_FMT_YCBCR444) { if (!hdmi_data->enc_color_depth) { output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; } else if (hdmi_data->enc_color_depth == 8) { @@ -725,7 +721,8 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi) } else { return; } - } else if (hdmi_data->enc_out_format == YCBCR422_8BITS) { + } else if (hdmi_data->enc_out_format == + DW_HDMI_ENC_FMT_YCBCR422_8BITS) { if (!hdmi_data->enc_color_depth || hdmi_data->enc_color_depth == 8) remap_size = HDMI_VP_REMAP_YCC422_16bit; @@ -1101,15 +1098,16 @@ static void hdmi_config_AVI(struct dw_hdmi *hdmi, struct drm_display_mode *mode) /* Initialise info frame from DRM mode */ drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); - if (hdmi->hdmi_data.enc_out_format == YCBCR444) + if (hdmi->hdmi_data.enc_out_format == DW_HDMI_ENC_FMT_YCBCR444) frame.colorspace = HDMI_COLORSPACE_YUV444; - else if (hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) + else if (hdmi->hdmi_data.enc_out_format == + DW_HDMI_ENC_FMT_YCBCR422_8BITS) frame.colorspace = HDMI_COLORSPACE_YUV422; else frame.colorspace = HDMI_COLORSPACE_RGB; /* Set up colorimetry */ - if (hdmi->hdmi_data.enc_out_format == XVYCC444) { + if (hdmi->hdmi_data.enc_out_format == DW_HDMI_ENC_FMT_XVYCC444) { frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) frame.extended_colorimetry = @@ -1117,7 +1115,7 @@ static void hdmi_config_AVI(struct dw_hdmi *hdmi, struct drm_display_mode *mode) else /*hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_709*/ frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; - } else if (hdmi->hdmi_data.enc_out_format != RGB) { + } else if (hdmi->hdmi_data.enc_out_format != DW_HDMI_ENC_FMT_RGB) { frame.colorimetry = hdmi->hdmi_data.colorimetry; frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; } else { /* Carries no data */ @@ -1406,10 +1404,13 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; - /* TODO: Get input format from IPU (via FB driver interface) */ - hdmi->hdmi_data.enc_in_format = RGB; + /* Get input format from plat data or fallback to RGB */ + if (hdmi->plat_data->input_fmt >= 0) + hdmi->hdmi_data.enc_in_format = hdmi->plat_data->input_fmt; + else + hdmi->hdmi_data.enc_in_format = DW_HDMI_ENC_FMT_RGB; - hdmi->hdmi_data.enc_out_format = RGB; + hdmi->hdmi_data.enc_out_format = DW_HDMI_ENC_FMT_RGB; hdmi->hdmi_data.enc_color_depth = 8; hdmi->hdmi_data.pix_repet_factor = 0; diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 5b5dfb6..a4caf8b 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -22,6 +22,14 @@ enum { DW_HDMI_RES_MAX, }; +enum dw_hdmi_color_enc_format { + DW_HDMI_ENC_FMT_RGB = 0, + DW_HDMI_ENC_FMT_YCBCR444, + DW_HDMI_ENC_FMT_YCBCR422_16BITS, + DW_HDMI_ENC_FMT_YCBCR422_8BITS, + DW_HDMI_ENC_FMT_XVYCC444, +}; + enum dw_hdmi_phy_type { DW_HDMI_PHY_DWC_HDMI_TX_PHY = 0x00, DW_HDMI_PHY_DWC_MHL_PHY_HEAC = 0xb2, @@ -61,8 +69,8 @@ struct hdmi_vmode { }; struct hdmi_data_info { - unsigned int enc_in_format; - unsigned int enc_out_format; + enum dw_hdmi_color_enc_format enc_in_format; + enum dw_hdmi_color_enc_format enc_out_format; unsigned int enc_color_depth; unsigned int colorimetry; unsigned int pix_repet_factor; @@ -95,6 +103,8 @@ struct dw_hdmi_plat_data { enum drm_mode_status (*mode_valid)(struct drm_connector *connector, struct drm_display_mode *mode); struct regmap *regm; + + int input_fmt; }; int dw_hdmi_probe(struct platform_device *pdev,