From patchwork Tue Oct 22 11:45:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11205867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50ED6112C for ; Wed, 23 Oct 2019 08:09:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3975821906 for ; Wed, 23 Oct 2019 08:09:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3975821906 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D434D6E993; Wed, 23 Oct 2019 08:09:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB5156E5EF for ; Tue, 22 Oct 2019 11:47:10 +0000 (UTC) Received: by mail-pf1-x44a.google.com with SMTP id s137so13149109pfs.18 for ; Tue, 22 Oct 2019 04:47:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=s0s8xkCRDoETkGIRm0ElT2FwVj33VJZ3cTstMqIB3IM=; b=PctaBWaKknA+KETFy66WHEyi89kwSrN5M2hnsldAFC62+H19wMHBFzyR+8ppwaH7RL L+ljySJZq77V3pQl3EiPHRgP25Ct4pGLlTGUNkDC5yF8YD1zH4R54+SElFhg2BG7hzsG JsdYxEZDQ6IPPKtCf5jO2TnxS1oYFtb9HrChO6qOUn4HlTOUfxaOlAvaiottI+LrUXCv lltGcsBJyGEmTGW5IA5znCSA8ps75nmzgZDQVuxkNEOcGpLzVEMgfqO+AjDGYLUkp+2D QJLhZWP4T2zmau6Qo8z2fhcvK6XKDbOEyfBqQ5ENqilU4pzttKK31DRJw+JugvU3cDtX u8rw== X-Gm-Message-State: APjAAAXEZWqs2zv5Xr9HlmytQvrJoFHKxgzTAogrU232loRUQnYyBCBw niLMVKVOIcXHnv+yQtVaQFklAZcug4Zk X-Google-Smtp-Source: APXvYqy9VizXIvEY2o6/3SHowrevaAyupW9XltTdBSGcXmWEmoUxzrtIaUakSyVtkK+jhJd4Wuu1Vf6Qx09o X-Received: by 2002:a63:8f41:: with SMTP id r1mr3124518pgn.83.1571744829991; Tue, 22 Oct 2019 04:47:09 -0700 (PDT) Date: Tue, 22 Oct 2019 19:45:04 +0800 In-Reply-To: <20191022114505.196852-1-tzungbi@google.com> Message-Id: <20191022193301.5.I8247fd099947a7a67ac86479b9972ea98272f547@changeid> Mime-Version: 1.0 References: <20191022114505.196852-1-tzungbi@google.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog Subject: [PATCH 5/6] drm: bridge: it6505: report connector status From: Tzung-Bi Shih To: broonie@kernel.org, robh+dt@kernel.org, narmstrong@baylibre.com X-Mailman-Approved-At: Wed, 23 Oct 2019 08:09:38 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=s0s8xkCRDoETkGIRm0ElT2FwVj33VJZ3cTstMqIB3IM=; b=I0acZyZn7Xa5n4obt1qg6joAIwyf9eiBWk/mW3Nlwg9fcmVvcxkuhvFIyFjP6M92dr QdJzMn7/AX2f9zcQntoB5Zkse6Pu+SHBIjb00x3UrLLdWyJg6s2YtB6Fu8qunSioqb/2 Gycr9cOufMmEc1mn0DSCnsqeWMDvVDc+hZAs/QE9Hp5twycxtJjudehRrb6hEYsFYlXK b6yZtGFAEbG3wzWfdNZ4BbfoJEL6PWqgncjY6r2NSDEh+PAPI6wEZdcKJV8BsAcfVWWV Bup7DNuh9H23t+2obXziuAUtbntup0JtzB239+cUjg0vNJvV5MsMM7DfaO8j6ficqge6 lF7A== 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: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, cychiang@google.com, jonas@kwiboo.se, allen.chen@ite.com.tw, jernej.skrabec@siol.net, dri-devel@lists.freedesktop.org, Laurent.pinchart@ideasonboard.com, tzungbi@google.com, dgreid@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When a connector connected or disconnected, report the jack status. Signed-off-by: Tzung-Bi Shih --- drivers/gpu/drm/bridge/ite-it6505.c | 39 +++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c index 1d19184d2056..645d7947acc2 100644 --- a/drivers/gpu/drm/bridge/ite-it6505.c +++ b/drivers/gpu/drm/bridge/ite-it6505.c @@ -180,6 +180,10 @@ struct it6505 { bool powered; /* it6505 driver hold option */ unsigned int drv_hold; + + hdmi_codec_plugged_cb plugged_cb; + struct device *codec_dev; + enum drm_connector_status last_connector_status; }; static const struct regmap_range it6505_bridge_volatile_ranges[] = { @@ -882,15 +886,31 @@ static const struct drm_connector_helper_funcs it6505_connector_helper_funcs = { .get_modes = it6505_get_modes, }; +static void it6505_update_plugged_status(struct it6505 *it6505, + enum drm_connector_status status) +{ + if (it6505->plugged_cb && it6505->codec_dev) + it6505->plugged_cb(it6505->codec_dev, + status == connector_status_connected); +} + static enum drm_connector_status it6505_detect(struct drm_connector *connector, bool force) { struct it6505 *it6505 = connector_to_it6505(connector); + enum drm_connector_status status; if (gpiod_get_value(it6505->pdata.gpiod_hpd)) - return connector_status_disconnected; + status = connector_status_disconnected; + else + status = connector_status_connected; + + if (status != it6505->last_connector_status) { + it6505->last_connector_status = status; + it6505_update_plugged_status(it6505, status); + } - return connector_status_connected; + return status; } static const struct drm_connector_funcs it6505_connector_funcs = { @@ -1341,10 +1361,23 @@ static void it6505_audio_shutdown(struct device *dev, void *data) it6505->en_audio = 0; } +static int it6505_audio_hook_plugged_cb(struct device *dev, void *data, + hdmi_codec_plugged_cb fn, + struct device *codec_dev) +{ + struct it6505 *it6505 = data; + + it6505->plugged_cb = fn; + it6505->codec_dev = codec_dev; + it6505_update_plugged_status(it6505, it6505->last_connector_status); + return 0; +} + static const struct hdmi_codec_ops it6505_audio_codec_ops = { .hw_params = it6505_audio_hw_params, .trigger = it6505_audio_trigger, .audio_shutdown = it6505_audio_shutdown, + .hook_plugged_cb = it6505_audio_hook_plugged_cb, }; static int it6505_register_audio_driver(struct device *dev) @@ -1354,6 +1387,7 @@ static int it6505_register_audio_driver(struct device *dev) .ops = &it6505_audio_codec_ops, .max_i2s_channels = 8, .i2s = 1, + .data = it6505, }; struct platform_device *pdev; @@ -1364,6 +1398,7 @@ static int it6505_register_audio_driver(struct device *dev) return PTR_ERR(pdev); INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio); + it6505->last_connector_status = connector_status_disconnected; DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME); return 0;