From 93b521656ed068c15505314b36159f383c8128f1 Mon Sep 17 00:00:00 2001 From: Sandor Yu Date: Thu, 10 Jan 2013 14:52:06 +0800 Subject: [PATCH] ENGR00239569 Mx6x HDMI Add RGB/YCbCr output select via system file Add RGB/YCbCr output select via system file, the default output is RGB. Signed-off-by: Sandor Yu --- drivers/video/mxc_hdmi.c | 56 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/drivers/video/mxc_hdmi.c b/drivers/video/mxc_hdmi.c index 09b8823d3c15..ddfa0276a905 100644 --- a/drivers/video/mxc_hdmi.c +++ b/drivers/video/mxc_hdmi.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. + * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,6 +148,7 @@ struct hdmi_data_info { unsigned int colorimetry; unsigned int pix_repet_factor; unsigned int hdcp_enable; + unsigned int rgb_out_enable; struct hdmi_vmode video_mode; }; @@ -248,6 +249,43 @@ static ssize_t mxc_hdmi_show_edid(struct device *dev, static DEVICE_ATTR(edid, S_IRUGO, mxc_hdmi_show_edid, NULL); +static ssize_t mxc_hdmi_show_rgb_out_enable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxc_hdmi *hdmi = dev_get_drvdata(dev); + + if (hdmi->hdmi_data.rgb_out_enable == true) + strcpy(buf, "RGB out\n"); + else + strcpy(buf, "YCbCr out\n"); + + return strlen(buf); +} + +static ssize_t mxc_hdmi_store_rgb_out_enable(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct mxc_hdmi *hdmi = dev_get_drvdata(dev); + unsigned long value; + int ret; + + ret = strict_strtoul(buf, 10, &value); + if (ret) + return ret; + + hdmi->hdmi_data.rgb_out_enable = value; + + /* Reconfig HDMI for output color space change */ + mxc_hdmi_setup(hdmi, 0); + + return count; +} + +static DEVICE_ATTR(rgb_out_enable, S_IRUGO | S_IWUSR, + mxc_hdmi_show_rgb_out_enable, + mxc_hdmi_store_rgb_out_enable); + + /*! * this submodule is responsible for the video data synchronization. * for example, for RGB 4:4:4 input, the data map is defined as @@ -1934,6 +1972,15 @@ static void mxc_hdmi_setup(struct mxc_hdmi *hdmi, unsigned long event) hdmi->hdmi_data.enc_out_format = RGB; + /* YCbCr only enabled in HDMI mode */ + if (!hdmi->hdmi_data.video_mode.mDVI && + !hdmi->hdmi_data.rgb_out_enable) { + if (hdmi->edid_cfg.cea_ycbcr444) + hdmi->hdmi_data.enc_out_format = YCBCR444; + else if (hdmi->edid_cfg.cea_ycbcr422) + hdmi->hdmi_data.enc_out_format = YCBCR422_8BITS; + } + /* IPU not support depth color output */ hdmi->hdmi_data.enc_color_depth = 8; hdmi->hdmi_data.pix_repet_factor = 0; @@ -2243,6 +2290,9 @@ static int mxc_hdmi_disp_init(struct mxc_dispdrv_handle *disp, memset(&hdmi->hdmi_data, 0, sizeof(struct hdmi_data_info)); + /* Default HDMI working in RGB mode */ + hdmi->hdmi_data.rgb_out_enable = true; + ret = request_irq(irq, mxc_hdmi_hotplug, IRQF_SHARED, dev_name(&hdmi->pdev->dev), hdmi); if (ret < 0) { @@ -2263,6 +2313,10 @@ static int mxc_hdmi_disp_init(struct mxc_dispdrv_handle *disp, if (ret < 0) dev_warn(&hdmi->pdev->dev, "cound not create sys node for edid\n"); + ret = device_create_file(&hdmi->pdev->dev, &dev_attr_rgb_out_enable); + if (ret < 0) + dev_warn(&hdmi->pdev->dev, + "cound not create sys node for rgb out enable\n"); dev_dbg(&hdmi->pdev->dev, "%s exit\n", __func__); -- 2.39.5