Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8844223ybi; Wed, 10 Jul 2019 00:16:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzox26RDvoWlqNn44sEvTL6imaBYaRUqkaRnOBq11rhJgZOfeY8IRC29O/7Xy9DgOdoCQtM X-Received: by 2002:a63:8ac3:: with SMTP id y186mr2734905pgd.13.1562742973183; Wed, 10 Jul 2019 00:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562742973; cv=none; d=google.com; s=arc-20160816; b=D+Kuhf3EF3QVEGmOXyrrTfaaYdJHDtUqt8Lui858bbloiffOhl7R//OrnWvh6d2qju fnJKYfmjpRQTL2y2FhTiT6eHtQmxpTZ43ENhMz+aDkv5aisW8HBVaB4rorBAysHIeJVZ tnI3Q3IYEydR7P9WKeq59BZVxleLvVRulmh6FV20Y4JqNaQeuAXiiX0jVCKWl5g6/kUc 9d0VgtpsSWA1liralY513Ayfh+74r4N1O8Ki1nh4i2kw7PX5CGrs167YmV6Tv7dVo9Dh QD8Bd/xuIyKO/77qMKlEkH5O3qrPkBDjEYUZl6SQJQHlSvc7AK+0lYmRCuhtFkYpDjwe URFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cCvW1ogs/lTm73TtJzo66QSUw2j4h+OYuX2M2HCPPOg=; b=JoYsSGKRgU2/4t45MNTqT98UOpb/9koWI45kZx6vhBg+36V3GPf6jz+YFxxJctutbC /2/NVlaGfWjKo9ySF4SByr6HJWKibJuo0GSLAjvStRrqh1hqg4SKU+5Ra6JoKMYe58QV /PPAGEkcthBjXpxALclnSEydPFNsuQTKkJiRuPQ8hIRmR/fAFlaVPxPJrB1LbWNVbHtg L7QbDqzddo7QiKaDqfSCPl7GQ1rkg1vtdmNFhg5aHqfJ+kp1nST4AqG/5F5mSn/xoifb briCEyt1IOF1vmMSMiGGQJQi/cW5XJvw+DxD00g4Dwni/V/22snwP+NacifHRPNN0eTd OZUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Y62o3+/K"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b123si1568366pfa.14.2019.07.10.00.15.57; Wed, 10 Jul 2019 00:16:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Y62o3+/K"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbfGJHI1 (ORCPT + 99 others); Wed, 10 Jul 2019 03:08:27 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43150 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfGJHI1 (ORCPT ); Wed, 10 Jul 2019 03:08:27 -0400 Received: by mail-pg1-f193.google.com with SMTP id f25so752058pgv.10 for ; Wed, 10 Jul 2019 00:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cCvW1ogs/lTm73TtJzo66QSUw2j4h+OYuX2M2HCPPOg=; b=Y62o3+/K7I0CJx/JJA7oL5mmokKI12T+OpoAueo3EaQsxnlFKh9D9x8p0vtZ6RgZjF sj2E1ecgK749DWhXuEWt5u5UcjCOzbSDX79v0yRmu0Yzxb8M9FQEZzjt0regbofbHgZr VPWXrcRfBm46ama49cSnvvqWl7G3OHY0s8+IE= 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:mime-version:content-transfer-encoding; bh=cCvW1ogs/lTm73TtJzo66QSUw2j4h+OYuX2M2HCPPOg=; b=QTLLlqmuiOKv+0hbPZv5uEWuBgpF2AWu2KxLe5lMt4T2A5V9Ugu5n9iz7PoizT26tY 9PUo3TmsDC+GCTselGj+bh5a9WOjshsWdP/ttqxBM3+SOn4q9u5pQKH+iip/t6SecEYj z40WKowWCiPDgVfaqJDXpKjtbombxG6Kf3MKR8CD5ub/40jC9Vl6XiJ1vVKqkoluqYAM oWm+1GAB+KIr0UwThnTfbKMsuvYd2bGd/jMNAVdwI6P2DqyZwAEBDbzmuA11nEz3WY1Y fwUJGmv4nC0kSlkwSohQpfHcK4QLthiBe3K7qcgfcQQCEp+hDH5O9doMMfpdfmB2G3qB GSKw== X-Gm-Message-State: APjAAAWFhbqcQ+uekpoIwQBWYVFiqcRfrSa/mjolXsPPKTf/TNh8MK+F JjlDJLM2/pWBQTyNdK8sHIjRB+Htdkw= X-Received: by 2002:a63:5610:: with SMTP id k16mr35557003pgb.335.1562742506079; Wed, 10 Jul 2019 00:08:26 -0700 (PDT) Received: from localhost ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id s7sm1000140pjn.28.2019.07.10.00.08.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jul 2019 00:08:25 -0700 (PDT) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Cc: Hans Verkuil , Mark Brown , Liam Girdwood , Takashi Iwai , Jaroslav Kysela , Russell King , Andrzej Hajda , Laurent Pinchart , David Airlie , Daniel Vetter , Heiko Stuebner , dianders@chromium.org, dgreid@chromium.org, tzungbi@chromium.org, alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Cheng-Yi Chiang Subject: [PATCH v2 1/4] ASoC: hdmi-codec: Add an op to set callback function for plug event Date: Wed, 10 Jul 2019 15:07:48 +0800 Message-Id: <20190710070751.260061-2-cychiang@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190710070751.260061-1-cychiang@chromium.org> References: <20190710070751.260061-1-cychiang@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add an op in hdmi_codec_ops so codec driver can register callback function to handle plug event. Driver in DRM can use this callback function to report connector status. Signed-off-by: Cheng-Yi Chiang --- include/sound/hdmi-codec.h | 16 +++++++++++++ sound/soc/codecs/hdmi-codec.c | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 7fea496f1f34..9a8661680256 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -47,6 +47,9 @@ struct hdmi_codec_params { int channels; }; +typedef void (*hdmi_codec_plugged_cb)(struct device *dev, + bool plugged); + struct hdmi_codec_pdata; struct hdmi_codec_ops { /* @@ -88,6 +91,13 @@ struct hdmi_codec_ops { */ int (*get_dai_id)(struct snd_soc_component *comment, struct device_node *endpoint); + + /* + * Hook callback function to handle connector plug event. + * Optional + */ + int (*hook_plugged_cb)(struct device *dev, void *data, + hdmi_codec_plugged_cb fn); }; /* HDMI codec initalization data */ @@ -99,6 +109,12 @@ struct hdmi_codec_pdata { void *data; }; +struct snd_soc_component; +struct snd_soc_jack; + +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack); + #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" #endif /* __HDMI_CODEC_H__ */ diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 0bf1c8cad108..32bf7441be5c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -274,6 +275,8 @@ struct hdmi_codec_priv { struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; struct mutex lock; + struct snd_soc_jack *jack; + unsigned int jack_status; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -663,6 +666,48 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) return 0; } +static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp, + unsigned int jack_status) +{ + if (hcp->jack && jack_status != hcp->jack_status) { + snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT); + hcp->jack_status = jack_status; + } +} + +static void plugged_cb(struct device *dev, bool plugged) +{ + struct hdmi_codec_priv *hcp = dev_get_drvdata(dev); + + if (plugged) + hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); + else + hdmi_codec_jack_report(hcp, 0); +} + +/** + * hdmi_codec_set_jack_detect - register HDMI plugged callback + * @component: the hdmi-codec instance + * @jack: ASoC jack to report (dis)connection events on + */ +int hdmi_codec_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *jack) +{ + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + int ret = -EOPNOTSUPP; + + if (hcp->hcd.ops->hook_plugged_cb) { + hcp->jack = jack; + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent, + hcp->hcd.data, + plugged_cb); + if (ret) + hcp->jack = NULL; + } + return ret; +} +EXPORT_SYMBOL_GPL(hdmi_codec_set_jack_detect); + static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) { struct hdmi_codec_daifmt *cf = dai->playback_dma_data; -- 2.22.0.410.gd8fdbe21b5-goog