From patchwork Tue Mar 19 10:41:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 160546 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp3711772jad; Tue, 19 Mar 2019 03:42:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbuPD4KPAxRhbD49rkIqqnPQc6Z5QrmLzI3ovEzlANml0jIYk1jlX6o42CHZk81m4lHtTK X-Received: by 2002:a63:e70c:: with SMTP id b12mr1187981pgi.399.1552992151241; Tue, 19 Mar 2019 03:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552992151; cv=none; d=google.com; s=arc-20160816; b=VygfSYYJ2QSzGxKu/RGdPcAPadHZ8ajLYWbC/q/HEU0zcxWW/+Gkd1jo8ipv69kLU0 uVv/Oq79rGBTiQuUeB7eMM+ZT+OTvtAVvo81QnzwCNSElW4yY+quCOhF4Vot3VJGjUOm ApFlrDJKsLubVy/6p0HZ1ZUtJk48B9PR7ZdQwmpAJaibQCOc6wBUp6J6q59XdO/8bDCc 5d70W7jr3R6iZJOjasIh+J24kH40sUuoGw1YsddRGbD+bT5vY6g83UPEG9tsg0Q0jK2L 3Plem56AVez3q7gH0prhvc4oByaNRTHVgNejwD99tHvcwiVD9b69A/60zun9/mYFLprM 7/Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=Hv1h+BfzvI1oWsQh2RO9CytCRIEsYOdQchhZdQUCpq0=; b=WeK/Oic+UwIcS6Hxfse4zDvLimG60fIRNLBwVKlIX1E4/af0ScKVWg25YajbvKMJ9h qv8EIsvPNGa0b3mRF0QLxuxdZ7rqnPYQbf+2+Lsc6dzUlJErUFiAbwWA4XRL1jTWsT5L N6vqd3cjeRM5jHPu+3pioWIaUy5FlfFRbj20pVJnkQZyCwuaISxFx6+IRN/dSl4Eo1cL kkTj1+LMnpDRgFHwY2YlcPQ0re8qp8pT9Kldalqe5pB5pdMF3JUeSq/SLbezfRetTWuB HPWh9UovSWt0x8aFEQkx7D0MHegjh0xSvPhOnlFh6MzhChzTLFo2AsjBgPKyskAJevwU l0zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id d90si12142555pld.97.2019.03.19.03.42.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Mar 2019 03:42:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27E2689A77; Tue, 19 Mar 2019 10:42:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8AA2E89A77 for ; Tue, 19 Mar 2019 10:42:26 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x2JAgNwJ076729; Tue, 19 Mar 2019 05:42:23 -0500 Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x2JAgN1V114249 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Mar 2019 05:42:23 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Tue, 19 Mar 2019 05:42:20 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5 via Frontend Transport; Tue, 19 Mar 2019 05:42:20 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x2JAfxlR019091; Tue, 19 Mar 2019 05:42:18 -0500 From: Tomi Valkeinen To: Andrzej Hajda , Laurent Pinchart , , Lucas Stach , Andrey Gusakov , Philipp Zabel , Jyri Sarha , Peter Ujfalusi , Benoit Parrot Subject: [PATCH 08/21] drm/bridge: tc358767: split stream enable/disable Date: Tue, 19 Mar 2019 12:41:01 +0200 Message-ID: <20190319104114.12077-9-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190319104114.12077-1-tomi.valkeinen@ti.com> References: <20190319104114.12077-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1552992143; bh=PnSO1l6z1S3hCWKpcIwDRiqEMT/ph/ydsP2ETMbtxLc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YF7RD8cGn3NaClT4mxTEajoIja3ouZ4ozXFIyi7QDroPCrFmdLvUwmD9Nvh/kgQHd wUrrZTyhtyh2dck5QxGbz5CErPQjBNUIjY4cWmNH1yFD/Z+sc+tOQXKUAHe2NNEA5/ E3fbWgbw01r56u/9/tfWad6xUAaBpyIFX3jk+wSs= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It is nicer to have enable/disable functions instead of set(bool enable) style function. Split tc_main_link_stream into tc_stream_enable and tc_stream_disable. Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/bridge/tc358767.c | 81 +++++++++++++++++-------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 86b272422281..bfc673bd5986 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -1013,47 +1013,56 @@ static int tc_main_link_setup(struct tc_data *tc) return ret; } -static int tc_main_link_stream(struct tc_data *tc, int state) +static int tc_stream_enable(struct tc_data *tc) { int ret; u32 value; - dev_dbg(tc->dev, "stream: %d\n", state); + dev_dbg(tc->dev, "stream enable\n"); - if (state) { - ret = tc_set_video_mode(tc, tc->mode); - if (ret) - goto err; + ret = tc_set_video_mode(tc, tc->mode); + if (ret) + goto err; - /* Set M/N */ - ret = tc_stream_clock_calc(tc); - if (ret) - goto err; + /* Set M/N */ + ret = tc_stream_clock_calc(tc); + if (ret) + goto err; - value = VID_MN_GEN | DP_EN; - if (tc->link.base.capabilities & DP_LINK_CAP_ENHANCED_FRAMING) - value |= EF_EN; - tc_write(DP0CTL, value); - /* - * VID_EN assertion should be delayed by at least N * LSCLK - * cycles from the time VID_MN_GEN is enabled in order to - * generate stable values for VID_M. LSCLK is 270 MHz or - * 162 MHz, VID_N is set to 32768 in tc_stream_clock_calc(), - * so a delay of at least 203 us should suffice. - */ - usleep_range(500, 1000); - value |= VID_EN; - tc_write(DP0CTL, value); - /* Set input interface */ - value = DP0_AUDSRC_NO_INPUT; - if (tc_test_pattern) - value |= DP0_VIDSRC_COLOR_BAR; - else - value |= DP0_VIDSRC_DPI_RX; - tc_write(SYSCTRL, value); - } else { - tc_write(DP0CTL, 0); - } + value = VID_MN_GEN | DP_EN; + if (tc->link.base.capabilities & DP_LINK_CAP_ENHANCED_FRAMING) + value |= EF_EN; + tc_write(DP0CTL, value); + /* + * VID_EN assertion should be delayed by at least N * LSCLK + * cycles from the time VID_MN_GEN is enabled in order to + * generate stable values for VID_M. LSCLK is 270 MHz or + * 162 MHz, VID_N is set to 32768 in tc_stream_clock_calc(), + * so a delay of at least 203 us should suffice. + */ + usleep_range(500, 1000); + value |= VID_EN; + tc_write(DP0CTL, value); + /* Set input interface */ + value = DP0_AUDSRC_NO_INPUT; + if (tc_test_pattern) + value |= DP0_VIDSRC_COLOR_BAR; + else + value |= DP0_VIDSRC_DPI_RX; + tc_write(SYSCTRL, value); + + return 0; +err: + return ret; +} + +static int tc_stream_disable(struct tc_data *tc) +{ + int ret; + + dev_dbg(tc->dev, "stream disable\n"); + + tc_write(DP0CTL, 0); return 0; err: @@ -1078,7 +1087,7 @@ static void tc_bridge_enable(struct drm_bridge *bridge) return; } - ret = tc_main_link_stream(tc, 1); + ret = tc_stream_enable(tc); if (ret < 0) { dev_err(tc->dev, "main link stream start error: %d\n", ret); return; @@ -1094,7 +1103,7 @@ static void tc_bridge_disable(struct drm_bridge *bridge) drm_panel_disable(tc->panel); - ret = tc_main_link_stream(tc, 0); + ret = tc_stream_disable(tc); if (ret < 0) dev_err(tc->dev, "main link stream stop error: %d\n", ret); }