From patchwork Mon Dec 10 16:34:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10721727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89A6D112E for ; Mon, 10 Dec 2018 16:35:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 786C82AB0A for ; Mon, 10 Dec 2018 16:35:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69B8C2A927; Mon, 10 Dec 2018 16:35:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2EF12A927 for ; Mon, 10 Dec 2018 16:34:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727243AbeLJQe6 (ORCPT ); Mon, 10 Dec 2018 11:34:58 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46430 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeLJQe6 (ORCPT ); Mon, 10 Dec 2018 11:34:58 -0500 Received: by mail-ed1-f66.google.com with SMTP id o10so9997931edt.13; Mon, 10 Dec 2018 08:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7QCbV7FTtynMbJ1N5CgZDG9CjfiMGjBfUjHz/Fc8YBU=; b=dEbkOjzXEPDu4ZDriSm4CV87Yu8owSs5l2VNPNn1u/D2fDtC0pifB7Wwm25+cvbitZ ZOcmJpWhJxoZiuHqFEVeLTfsTDWxZgj1NL5IueGlZRtDfbVhvVYxJ5NONsMdLHPqdxVC d0z7eG8oMKDOtlVgFX9LnKedDAOT/zHtaCOAOfkJBw9sGWxLqbMny/L9dewkNMVlgQHR Ou9PeV4fMVGy4hK6AbBtw2bsQjXjfJ3za3PQRwe82ndf6iOToGuEw9ee+m2CYgd7fsjT 8BcWV+QYwK4eddnBNAylOrWZzs9Dst4+TXuRS4Ds5qLK5MX8bbU8Z5KqyDe85lw7ge4q wfew== 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:mime-version :content-transfer-encoding; bh=7QCbV7FTtynMbJ1N5CgZDG9CjfiMGjBfUjHz/Fc8YBU=; b=iCA6mAB+nt8jtEHkEhGn2EEWaU4rROB2PgHlSVk3nPFG43raz1C/SIFfAAxNpI0uaR isIXFHRH8VJmfauPtB5GhYLYQPh9QykkO9Pg9lDy5KnN7Fp1lIyLH63GHOX5aruExkQt oGrzxbLeMakWE5wmc/fU1eo65FGg7djCGnks8RRKzHCWS9qeCuyhS4nqPzEKzfSPQu44 GCVF3eq0zwvJL6LtR9O5TOodKFj0eqfs40hdfXiy8qF6c3G+dP/CANIcBy4UGTpAotV9 Lgis/CPwOumMyetlBy9Q4NMIGEN9BHj9/1nTcNb46XkeJKXaTO9zNVe7Gm1RP/hgIJzH oXTg== X-Gm-Message-State: AA+aEWZy8T9goHVXo0s8hVg1X+K1PrD7qBEoCV5CQ9fIcWzAP2oQ/BRb gQXrXN/es+c4sMyFRSYZ+98= X-Google-Smtp-Source: AFSGD/UoVRab0te4fVTy8qAEle0z8+QG81KWM7SbxGSKH7aAtjWtJNSz/y4fIj9pRb+9IYcZCeLy4w== X-Received: by 2002:a50:cf41:: with SMTP id d1mr12235239edk.242.1544459696800; Mon, 10 Dec 2018 08:34:56 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id n12-v6sm1838088ejl.13.2018.12.10.08.34.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 08:34:56 -0800 (PST) From: Thierry Reding To: Thierry Reding Cc: Hans Verkuil , dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] drm/tegra: Refactor CEC support Date: Mon, 10 Dec 2018 17:34:54 +0100 Message-Id: <20181210163455.13627-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Most of the CEC support code already lives in the "output" library code. Move registration and unregistration to the library code as well to make use of the same code with HDMI on Tegra210 and later via the SOR. Signed-off-by: Thierry Reding Reviewed-by: Hans Verkuil --- drivers/gpu/drm/tegra/drm.h | 2 +- drivers/gpu/drm/tegra/hdmi.c | 9 --------- drivers/gpu/drm/tegra/output.c | 11 +++++++++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index 019862a41cb4..dbc9e11b0aec 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -132,7 +132,7 @@ struct tegra_output { struct drm_panel *panel; struct i2c_adapter *ddc; const struct edid *edid; - struct cec_notifier *notifier; + struct cec_notifier *cec; unsigned int hpd_irq; int hpd_gpio; enum of_gpio_flags hpd_gpio_flags; diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c index 0082468f703c..d19973945614 100644 --- a/drivers/gpu/drm/tegra/hdmi.c +++ b/drivers/gpu/drm/tegra/hdmi.c @@ -22,8 +22,6 @@ #include -#include - #include "hdmi.h" #include "drm.h" #include "dc.h" @@ -1709,10 +1707,6 @@ static int tegra_hdmi_probe(struct platform_device *pdev) return PTR_ERR(hdmi->vdd); } - hdmi->output.notifier = cec_notifier_get(&pdev->dev); - if (hdmi->output.notifier == NULL) - return -ENOMEM; - hdmi->output.dev = &pdev->dev; err = tegra_output_probe(&hdmi->output); @@ -1771,9 +1765,6 @@ static int tegra_hdmi_remove(struct platform_device *pdev) tegra_output_remove(&hdmi->output); - if (hdmi->output.notifier) - cec_notifier_put(hdmi->output.notifier); - return 0; } diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index c662efc7e413..9c2b9dad55c3 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -36,7 +36,7 @@ int tegra_output_connector_get_modes(struct drm_connector *connector) else if (output->ddc) edid = drm_get_edid(connector, output->ddc); - cec_notifier_set_phys_addr_from_edid(output->notifier, edid); + cec_notifier_set_phys_addr_from_edid(output->cec, edid); drm_connector_update_edid_property(connector, edid); if (edid) { @@ -73,7 +73,7 @@ tegra_output_connector_detect(struct drm_connector *connector, bool force) } if (status != connector_status_connected) - cec_notifier_phys_addr_invalidate(output->notifier); + cec_notifier_phys_addr_invalidate(output->cec); return status; } @@ -174,11 +174,18 @@ int tegra_output_probe(struct tegra_output *output) disable_irq(output->hpd_irq); } + output->cec = cec_notifier_get(output->dev); + if (!output->cec) + return -ENOMEM; + return 0; } void tegra_output_remove(struct tegra_output *output) { + if (output->cec) + cec_notifier_put(output->cec); + if (gpio_is_valid(output->hpd_gpio)) { free_irq(output->hpd_irq, output); gpio_free(output->hpd_gpio);