From patchwork Tue May 13 18:26:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 30126 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CA12020369 for ; Tue, 13 May 2014 18:27:26 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id ar20sf3393584iec.0 for ; Tue, 13 May 2014 11:27:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:subject:date :message-id:in-reply-to:references:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=HNtTi6T32/gO8fBVOUUVDDOwXBt/1Ve06T4VdKbsKnA=; b=WealTWI8wlbuiC6wfKJ89rU52Yv0UACt0l4YsDKCV2R6fBMc6vRxGBm0wh18aRTLN7 /3upydqV2SGYPePDqIlhLYehFuJ5NthaatCzKrt5KCvXwR4AuvFpoOwj852L5BkuXIy6 6PZ96y7xe9Msya+cY04SehLim0xgrqNoQbNkjq93oB+be/Yr61Ec0TKP+IQLF3mq0w6e bl4Gi5sXuokLusgDZEg5q+uctx0ZZKLOTpPlIiwyjwX2AjcKfVqPJglBcgPjJAycyzGF GnxQiu3+ojRxkAN0287513fEOYpAVv4Ohb4YpDzxXDibYKVr2oVWnTnA9LgGcsbzAyNk QHiQ== X-Gm-Message-State: ALoCoQm+zIVqLtNWiENI4vbJWBgqaTaYE0P9k8Gf8v68szy+gi0pIkNAW6c3UdMfseboH8fBSOpf X-Received: by 10.50.73.132 with SMTP id l4mr14886471igv.5.1400005646353; Tue, 13 May 2014 11:27:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.131 with SMTP id d3ls2116648qge.52.gmail; Tue, 13 May 2014 11:27:26 -0700 (PDT) X-Received: by 10.58.188.115 with SMTP id fz19mr13127vec.40.1400005646233; Tue, 13 May 2014 11:27:26 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id xo2si2780526vec.170.2014.05.13.11.27.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 11:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id hy4so1003999vcb.11 for ; Tue, 13 May 2014 11:27:26 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr5475917vcb.18.1400005646130; Tue, 13 May 2014 11:27:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp172976vcb; Tue, 13 May 2014 11:27:25 -0700 (PDT) X-Received: by 10.68.190.136 with SMTP id gq8mr7061225pbc.21.1400005645190; Tue, 13 May 2014 11:27:25 -0700 (PDT) Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id ta6si14092899pab.54.2014.05.13.11.27.24 for ; Tue, 13 May 2014 11:27:25 -0700 (PDT) Received-SPF: none (google.com: dri-devel-bounces@lists.freedesktop.org does not designate permitted sender hosts) client-ip=131.252.210.177; Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE41F7A00A; Tue, 13 May 2014 11:27:23 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BB7C6EBB2 for ; Tue, 13 May 2014 11:27:21 -0700 (PDT) Received: by mail-wi0-f181.google.com with SMTP id n15so1116585wiw.8 for ; Tue, 13 May 2014 11:27:20 -0700 (PDT) X-Received: by 10.180.76.179 with SMTP id l19mr8762045wiw.43.1400005640840; Tue, 13 May 2014 11:27:20 -0700 (PDT) Received: from lmenx321.lme.st.com (lya72-2-88-175-155-153.fbx.proxad.net. [88.175.155.153]) by mx.google.com with ESMTPSA id f7sm23191631wjy.24.2014.05.13.11.27.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 11:27:20 -0700 (PDT) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH v2 15/19] drm: sti: add debug to TVout Date: Tue, 13 May 2014 20:26:24 +0200 Message-Id: <1400005588-3974-16-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400005588-3974-1-git-send-email-benjamin.gaignard@linaro.org> References: <1400005588-3974-1-git-send-email-benjamin.gaignard@linaro.org> Cc: Fabien Dessenne , Benjamin Gaignard X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: benjamin.gaignard@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Use debugfs to dump information about TVout Signed-off-by: Benjamin Gaignard Signed-off-by: Vincent Abriou Signed-off-by: Fabien Dessenne --- drivers/gpu/drm/sti/sti_tvout.c | 181 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/drivers/gpu/drm/sti/sti_tvout.c b/drivers/gpu/drm/sti/sti_tvout.c index 7c61ba1..95251c3 100644 --- a/drivers/gpu/drm/sti/sti_tvout.c +++ b/drivers/gpu/drm/sti/sti_tvout.c @@ -18,6 +18,7 @@ #include "sti_tvout.h" #include "sti_hdmi.h" #include "sti_hda.h" +#include "sti_drm_drv.h" /* glue regsiters */ #define TVO_CSC_MAIN_M0 0x000 @@ -605,6 +606,186 @@ void sti_tvout_disable(struct sti_tvout *tvout, connector->stop(connector); } +/* + * Debugfs + */ +#define TVOUT_DBG_DUMP(reg) seq_printf(m, "\n %-25s 0x%08X", #reg, \ + readl(tvout->regs + reg)) +#define TVOUT_CONNECTOR_NAME_MAX_LENGHT 10 +#define MAX_STRING_LENGTH 55 + +static int sti_tvout_dbg_type_to_connector_name(enum sti_tvout_connector_type + type, char *name) +{ + switch (type) { + case STI_TVOUT_CONNECTOR_HDMI: + snprintf(name, TVOUT_CONNECTOR_NAME_MAX_LENGHT, "HDMI"); + break; + case STI_TVOUT_CONNECTOR_HDA: + snprintf(name, TVOUT_CONNECTOR_NAME_MAX_LENGHT, "HD Analog"); + break; + default: + return -1; + } + + return 0; +} + +static void tvout_dbg_vip(struct seq_file *m, int val) +{ + int r, g, b, tmp, mask; + char str[MAX_STRING_LENGTH]; + static const char *const reorder[] = { "Y_G", "Cb_B", "Cr_R" }; + static const char *const clipping[] = { "No", "EAV/SAV", + "Limited range RGB/Y", "Limited range Cb/Cr", + "decided by register" }; + static const char *const round[] = { "8-bit", "10-bit", "12-bit" }; + static const char *const input_sel[] = { "Main (color matrix enabled)", + "Main (color matrix by-passed)", "", "", "", "", "", "", + "Aux (color matrix enabled)", "Aux (color matrix by-passed)", + "", "", "", "", "", "Force value" + }; + + seq_puts(m, "\t"); + + mask = TVO_VIP_REORDER_MASK << TVO_VIP_REORDER_R_SHIFT; + r = (val & mask) >> TVO_VIP_REORDER_R_SHIFT; + mask = TVO_VIP_REORDER_MASK << TVO_VIP_REORDER_G_SHIFT; + g = (val & mask) >> TVO_VIP_REORDER_G_SHIFT; + mask = TVO_VIP_REORDER_MASK << TVO_VIP_REORDER_B_SHIFT; + b = (val & mask) >> TVO_VIP_REORDER_B_SHIFT; + snprintf(str, MAX_STRING_LENGTH, "Reorder: %s->%s %s->%s %s->%s", + reorder[r], reorder[TVO_VIP_REORDER_CR_R_SEL], + reorder[g], reorder[TVO_VIP_REORDER_Y_G_SEL], + reorder[b], reorder[TVO_VIP_REORDER_CB_B_SEL]); + seq_printf(m, "%-55s", str); + + mask = TVO_VIP_CLIP_MASK << TVO_VIP_CLIP_SHIFT; + tmp = (val & mask) >> TVO_VIP_CLIP_SHIFT; + snprintf(str, MAX_STRING_LENGTH, "Clipping: %s", clipping[tmp]); + seq_printf(m, "%-55s", str); + + seq_printf(m, "\n%-40s", ""); + + mask = TVO_VIP_RND_MASK << TVO_VIP_RND_SHIFT; + tmp = (val & mask) >> TVO_VIP_RND_SHIFT; + snprintf(str, MAX_STRING_LENGTH, + "Round: input data rounded to %s per component", round[tmp]); + seq_printf(m, "%-55s", str); + + tmp = (val & TVO_VIP_SEL_INPUT_MASK); + snprintf(str, MAX_STRING_LENGTH, "Input selection: %s", input_sel[tmp]); + seq_printf(m, "%-55s", str); +} + +static void tvout_dbg_hd_dac_cfg(struct seq_file *m, int val) +{ + seq_puts(m, "\t HD DAC "); + seq_puts(m, val & 1 ? "disabled" : "enabled"); +} + +static int tvout_dbg_show(struct seq_file *m, + enum sti_tvout_connector_type type) +{ + struct drm_info_node *node = (struct drm_info_node *)m->private; + struct drm_device *dev = node->minor->dev; + struct sti_drm_private *dev_priv = dev->dev_private; + struct sti_tvout *tvout = dev_priv->tvout; + struct sti_tvout_connector *connector = tvout->connector[type]; + char name[TVOUT_CONNECTOR_NAME_MAX_LENGHT]; + int ret; + + if (!connector) + return -1; + + if (!connector->is_enabled) + return -1; + + ret = mutex_lock_interruptible(&dev->struct_mutex); + if (ret) + return ret; + + if (tvout == NULL) { + seq_puts(m, "No tvout available"); + goto out; + } + + ret = sti_tvout_dbg_type_to_connector_name(type, name); + if (ret) { + seq_puts(m, "No connector!"); + goto out; + } + + seq_printf(m, "\n%s connector: ", name); + seq_printf(m, "\nTVOUT: (virt base addr = 0x%p)", tvout->regs); + if (connector->is_enabled(connector)) { + if (connector->main_path) { + seq_puts(m, "\n Connected to the main path"); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M0); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M1); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M2); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M3); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M4); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M5); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M6); + TVOUT_DBG_DUMP(TVO_CSC_MAIN_M7); + TVOUT_DBG_DUMP(TVO_MAIN_IN_VID_FORMAT); + } else { + seq_puts(m, "\n Connected to the auxiliary path"); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M0); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M2); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M3); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M4); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M5); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M6); + TVOUT_DBG_DUMP(TVO_CSC_AUX_M7); + TVOUT_DBG_DUMP(TVO_AUX_IN_VID_FORMAT); + } + } else + seq_puts(m, " Disabled"); + + switch (type) { + case STI_TVOUT_CONNECTOR_HDMI: + TVOUT_DBG_DUMP(TVO_VIP_HDMI); + tvout_dbg_vip(m, readl(tvout->regs + TVO_VIP_HDMI)); + TVOUT_DBG_DUMP(TVO_HDMI_FORCE_COLOR_0); + TVOUT_DBG_DUMP(TVO_HDMI_FORCE_COLOR_1); + TVOUT_DBG_DUMP(TVO_HDMI_CLIP_VALUE_B_CB); + TVOUT_DBG_DUMP(TVO_HDMI_CLIP_VALUE_Y_G); + TVOUT_DBG_DUMP(TVO_HDMI_CLIP_VALUE_R_CR); + TVOUT_DBG_DUMP(TVO_HDMI_SYNC_SEL); + TVOUT_DBG_DUMP(TVO_HDMI_DFV_OBS); + break; + case STI_TVOUT_CONNECTOR_HDA: + TVOUT_DBG_DUMP(TVO_VIP_HDF); + tvout_dbg_vip(m, readl(tvout->regs + TVO_VIP_HDF)); + TVOUT_DBG_DUMP(TVO_HD_SYNC_SEL); + TVOUT_DBG_DUMP(TVO_HD_DAC_CFG_OFF); + tvout_dbg_hd_dac_cfg(m, + readl(tvout->regs + TVO_HD_DAC_CFG_OFF)); + break; + default: + goto out; + } + + if (connector->dbg_show) + connector->dbg_show(connector, m); +out: + seq_puts(m, "\n\n"); + mutex_unlock(&dev->struct_mutex); + return 0; +} + +int sti_tvout_hdmi_dbg_show(struct seq_file *m, void *arg) +{ + return tvout_dbg_show(m, STI_TVOUT_CONNECTOR_HDMI); +} + +int sti_tvout_hda_dbg_show(struct seq_file *m, void *arg) +{ + return tvout_dbg_show(m, STI_TVOUT_CONNECTOR_HDA); +} + static int sti_tvout_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev);