Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp298405ybg; Tue, 28 Jul 2020 06:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1Aieczo3kmvomHTuhlK8IDi7aL5boP0fzjIWAl6m1QAgbkf+nCfMOimlurgWO1vH6DmwX X-Received: by 2002:a05:6402:12d7:: with SMTP id k23mr18837171edx.312.1595942670161; Tue, 28 Jul 2020 06:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595942670; cv=none; d=google.com; s=arc-20160816; b=NBxlayTKP54BsikmVxJWm+JK/I292b31fXb37iIIbLdEgio+2nYhl4VPvOkD7fHH6l bjFDxLGR7jI6Qq2CA85z6vg9bJnPBr3Crq2tOa40G+TzVw+QuomSDOSQW+JjX4xb/aE/ A9nB2tyRWiY7nMBT8Pr6BdC7tuhpyC3U1/DJ8Ce7+AZY2r4n9AY97D4jHcoAcAX8LAFL K+faz1HKWv+aEJEzESC9b+oufpKz/oWbJMyunRQ3cydSs0aGSDyTiehoZ3lqW3L/SgtP RBo6hs4ffntLsr+TuiFPH3bnEecCRixfcQxncpGWgu0KMZNFnw7ONDgpWutmzdiyqmSB 5Ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RVbcnjfZmdkWTayIDxfBVMqVlu5cuT3hIbVqa5TR/1k=; b=ljLJfLCHA3apKqGaCx1Wr+uCDs3LuHEctul2cOAqoXdsUite2d3k+RCz8XKBomnC1O Fq8ttycwUSi5DOc9wNb3QcbQE8iduDvNVIBturZ3TMzp+7xF7yrLuZI6NXWuIT4Qdn7m hLlP5limeRXrtuhk1XUSJkHoS/7DY8b4JaWcFX2XAZ5Yzb1uNGUjm3161rqpefEJtZnD sNyaMvaPVhf03gRmPzCpCVeLY7pN3aUXxIore2VTp6iHNj6IdWyhBr0cdfoPkZQvz3by VRGhXGiQl/8hXff8pF0Vse80XAy5LLJieEzgqBstt9Tbto2ygyAIVUuMh8yY6v6ND0d1 CZWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b="l/a67glz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si6768655eju.192.2020.07.28.06.24.07; Tue, 28 Jul 2020 06:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b="l/a67glz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730080AbgG1NXg (ORCPT + 99 others); Tue, 28 Jul 2020 09:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729433AbgG1NXf (ORCPT ); Tue, 28 Jul 2020 09:23:35 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31C0EC061794 for ; Tue, 28 Jul 2020 06:23:35 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id a5so8309421wrm.6 for ; Tue, 28 Jul 2020 06:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RVbcnjfZmdkWTayIDxfBVMqVlu5cuT3hIbVqa5TR/1k=; b=l/a67glzcc5AQ6/acG9FVfC2RJtuuPIoD5fiBv6VDXxVCxLzRofZr6tYMAwi+RVHqm LGGNIJtTApsfJEtkxt8+co8EYg8e5E96j18GWe26DOsYoViYehCeJJ/1iS5JJYTbd//5 IEHnkwXARfBE2T/UoQK5VCeWULGDKZJogO5bgWkg99ghHE/mD0VbeKmM1lubsgCGG9B6 1AyJ43cy0a2fFoMAzNjN2mfE5sgSwzaDeVq8KfcpD20QumElze+rGxRJAwHC4+0iLN4Y us/t3V0t9pz59c2lhHJ4wpguDVfuP87u6b6FmOac7lDFRT2jzv7X/TiNWfZOkDYf37mR KB3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RVbcnjfZmdkWTayIDxfBVMqVlu5cuT3hIbVqa5TR/1k=; b=fdhb1csUvl5YTjaX0HkS1Se5C3Y1CNluq/8OhRtUxjD0xS4Y5CCf3bLhUuDmO6Y7VX SHHq0eq0/nnvXGv0OlA0nNsBdf9Rj4McScJQBdAt/fAJQLahLQuFPWWN0ui8oRNQx+tE D7ekd5rGsXlH4Og1dkTvmNU1U3cFTiauo7+Chn9qyepD9rmq5i/qI4gFutGG5mzgD3ZC kyXyffIVMMRB6p3RQkWHVOCyxY2YBFlWnwtbkhoUYAEZdgudMx0YqvQ3nU3jqxFXkbCQ LMBxhoOOwLr/RXhl8fal2Cyfr/MSg46NTsCorp0++m8DB4QdzomFzF0w7BDJr2x4cJEE BuBQ== X-Gm-Message-State: AOAM531z0pJ/BPKFRUPOwJhcrcLarbTjf8YORRpUFtWUo6W2i6GkEgV2 ktUBlIfx1HqVUQQKtoe9iUMRAR2EuDnmfb+wC2lc3A== X-Received: by 2002:adf:fe50:: with SMTP id m16mr7606176wrs.27.1595942613862; Tue, 28 Jul 2020 06:23:33 -0700 (PDT) MIME-Version: 1.0 References: <1b459f691ed99dcae2cea07e23ec1f5dd39837be.1594230107.git-series.maxime@cerno.tech> In-Reply-To: <1b459f691ed99dcae2cea07e23ec1f5dd39837be.1594230107.git-series.maxime@cerno.tech> From: Dave Stevenson Date: Tue, 28 Jul 2020 14:23:17 +0100 Message-ID: Subject: Re: [PATCH v4 58/78] drm/vc4: hdmi: Move CEC init to its own function To: Maxime Ripard Cc: Nicolas Saenz Julienne , Eric Anholt , DRI Development , linux-rpi-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, LKML , Tim Gover , Phil Elwell Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime On Wed, 8 Jul 2020 at 18:43, Maxime Ripard wrote: > > The CEC init code was put directly into the bind function, which was quite > inconsistent with how the audio support was done, and would prevent us from > further changes to skip that initialisation entirely. > > Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson > --- > drivers/gpu/drm/vc4/vc4_hdmi.c | 108 +++++++++++++++++++++------------- > 1 file changed, 67 insertions(+), 41 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c > index ef51eedaf75a..8cd08b541c14 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -1171,6 +1171,67 @@ static const struct cec_adap_ops vc4_hdmi_cec_adap_ops = { > .adap_log_addr = vc4_hdmi_cec_adap_log_addr, > .adap_transmit = vc4_hdmi_cec_adap_transmit, > }; > + > +static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) > +{ > + struct cec_connector_info conn_info; > + struct platform_device *pdev = vc4_hdmi->pdev; > + u32 value; > + int ret; > + > + vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops, > + vc4_hdmi, "vc4", > + CEC_CAP_DEFAULTS | > + CEC_CAP_CONNECTOR_INFO, 1); > + ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap); > + if (ret < 0) > + return ret; > + > + cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector); > + cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info); > + > + HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff); > + value = HDMI_READ(HDMI_CEC_CNTRL_1); > + value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK; > + /* > + * Set the logical address to Unregistered and set the clock > + * divider: the hsm_clock rate and this divider setting will > + * give a 40 kHz CEC clock. > + */ > + value |= VC4_HDMI_CEC_ADDR_MASK | > + (4091 << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT); > + HDMI_WRITE(HDMI_CEC_CNTRL_1, value); > + ret = devm_request_threaded_irq(&pdev->dev, platform_get_irq(pdev, 0), > + vc4_cec_irq_handler, > + vc4_cec_irq_handler_thread, 0, > + "vc4 hdmi cec", vc4_hdmi); > + if (ret) > + goto err_delete_cec_adap; > + > + ret = cec_register_adapter(vc4_hdmi->cec_adap, &pdev->dev); > + if (ret < 0) > + goto err_delete_cec_adap; > + > + return 0; > + > +err_delete_cec_adap: > + cec_delete_adapter(vc4_hdmi->cec_adap); > + > + return ret; > +} > + > +static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi) > +{ > + cec_unregister_adapter(vc4_hdmi->cec_adap); > +} > +#else > +static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) > +{ > + return 0; > +} > + > +static void vc4_hdmi_cec_exit(struct vc4_hdmi *vc4_hdmi) {}; > + > #endif > > static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi, > @@ -1250,9 +1311,6 @@ static int vc4_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi) > > static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) > { > -#ifdef CONFIG_DRM_VC4_HDMI_CEC > - struct cec_connector_info conn_info; > -#endif > const struct vc4_hdmi_variant *variant = of_device_get_match_data(dev); > struct platform_device *pdev = to_platform_device(dev); > struct drm_device *drm = dev_get_drvdata(master); > @@ -1332,43 +1390,13 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) > if (ret) > goto err_destroy_encoder; > > -#ifdef CONFIG_DRM_VC4_HDMI_CEC > - vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops, > - vc4_hdmi, "vc4", > - CEC_CAP_DEFAULTS | > - CEC_CAP_CONNECTOR_INFO, 1); > - ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap); > - if (ret < 0) > - goto err_destroy_conn; > - > - cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector); > - cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info); > - > - HDMI_WRITE(HDMI_CEC_CPU_MASK_SET, 0xffffffff); > - value = HDMI_READ(HDMI_CEC_CNTRL_1); > - value &= ~VC4_HDMI_CEC_DIV_CLK_CNT_MASK; > - /* > - * Set the logical address to Unregistered and set the clock > - * divider: the hsm_clock rate and this divider setting will > - * give a 40 kHz CEC clock. > - */ > - value |= VC4_HDMI_CEC_ADDR_MASK | > - (4091 << VC4_HDMI_CEC_DIV_CLK_CNT_SHIFT); > - HDMI_WRITE(HDMI_CEC_CNTRL_1, value); > - ret = devm_request_threaded_irq(dev, platform_get_irq(pdev, 0), > - vc4_cec_irq_handler, > - vc4_cec_irq_handler_thread, 0, > - "vc4 hdmi cec", vc4_hdmi); > + ret = vc4_hdmi_cec_init(vc4_hdmi); > if (ret) > - goto err_delete_cec_adap; > - ret = cec_register_adapter(vc4_hdmi->cec_adap, dev); > - if (ret < 0) > - goto err_delete_cec_adap; > -#endif > + goto err_destroy_conn; > > ret = vc4_hdmi_audio_init(vc4_hdmi); > if (ret) > - goto err_destroy_encoder; > + goto err_free_cec; > > vc4_debugfs_add_file(drm, variant->debugfs_name, > vc4_hdmi_debugfs_regs, > @@ -1376,12 +1404,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) > > return 0; > > -#ifdef CONFIG_DRM_VC4_HDMI_CEC > -err_delete_cec_adap: > - cec_delete_adapter(vc4_hdmi->cec_adap); > +err_free_cec: > + vc4_hdmi_cec_exit(vc4_hdmi); > err_destroy_conn: > vc4_hdmi_connector_destroy(&vc4_hdmi->connector); > -#endif > err_destroy_encoder: > drm_encoder_cleanup(encoder); > err_unprepare_hsm: > @@ -1422,7 +1448,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master, > kfree(vc4_hdmi->hdmi_regset.regs); > kfree(vc4_hdmi->hd_regset.regs); > > - cec_unregister_adapter(vc4_hdmi->cec_adap); > + vc4_hdmi_cec_exit(vc4_hdmi); > vc4_hdmi_connector_destroy(&vc4_hdmi->connector); > drm_encoder_cleanup(&vc4_hdmi->encoder.base.base); > > -- > git-series 0.9.1