[PATCH 5/6 v2] drm/msm/hdmi: Bring up HDMI connector OFF

Rob Clark robdclark at gmail.com
Sun Sep 1 16:28:38 UTC 2019


On Fri, Aug 23, 2019 at 12:35 AM Linus Walleij <linus.walleij at linaro.org> wrote:
>
> There is elaborate code in the HDMI connector handling to
> leave the connector in the state it was at power-on and
> only touch the GPIOs when the connector .enable() and
> .disable() callbacks are called.
>
> I don't think this is what we normally want, initialize
> the connector as OFF (possibly saving power?) using the
> appropriate GPIO descriptor flags. It will still be
> switched on/off in the enable()/disable() connector
> callback as before, but we can drop some strange surplus
> code.

I'm picking up the earlier patches in this series.. although I won't
have a good way to test on devices which use the hdmi block for a few
weeks (when I complete my move, and get back a bunch of boards that
are in boxes right now) so I'm going to wait on the last two I think.

When we get to dealing with devices with hdmi enabled by bootloader,
we may actually want to preserve the pre-probe state of the GPIOs.
Although maybe not worth worrying about until we can handle DSI
enabled at boot.

BR,
-R

>
> Cc: Rob Clark <robdclark at gmail.com>
> Cc: Sean Paul <sean at poorly.run>
> Cc: linux-arm-msm at vger.kernel.org
> Cc: freedreno at lists.freedesktop.org
> Reviewed-by: Brian Masney <masneyb at onstation.org>
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
> ChangeLog v1->v2:
> - Rebased on v5.3-rc1
> - Collected review tag
> ---
>  drivers/gpu/drm/msm/hdmi/hdmi.c           | 19 ++++++++++++-----
>  drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 25 ++++++-----------------
>  2 files changed, 20 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
> index 355afb936401..5739eec65659 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
> @@ -552,13 +552,22 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
>         for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
>                 const char *name = msm_hdmi_gpio_pdata[i].name;
>                 struct gpio_desc *gpiod;
> +               enum gpiod_flags flags;
>
>                 /*
> -                * We are fetching the GPIO lines "as is" since the connector
> -                * code is enabling and disabling the lines. Until that point
> -                * the power-on default value will be kept.
> +                * Notice the inverse set up here: we initialize the connector
> +                * to OFF state.
>                  */
> -               gpiod = devm_gpiod_get_optional(dev, name, GPIOD_ASIS);
> +               if (msm_hdmi_gpio_pdata[i].output) {
> +                       if (msm_hdmi_gpio_pdata[i].value)
> +                               flags = GPIOD_OUT_LOW;
> +                       else
> +                               flags = GPIOD_OUT_HIGH;
> +               } else {
> +                       flags = GPIOD_IN;
> +               }
> +
> +               gpiod = devm_gpiod_get_optional(dev, name, flags);
>                 /* This will catch e.g. -PROBE_DEFER */
>                 if (IS_ERR(gpiod))
>                         return PTR_ERR(gpiod);
> @@ -572,7 +581,7 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
>                          * in the upstream bindings.
>                          */
>                         if (sscanf(name, "qcom,hdmi-tx-%s", name3))
> -                               gpiod = devm_gpiod_get_optional(dev, name3, GPIOD_ASIS);
> +                               gpiod = devm_gpiod_get_optional(dev, name3, flags);
>                         if (IS_ERR(gpiod))
>                                 return PTR_ERR(gpiod);
>                         if (!gpiod)
> diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> index d0575d4f747d..f006682935e9 100644
> --- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> +++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
> @@ -75,16 +75,9 @@ static int gpio_config(struct hdmi *hdmi, bool on)
>                 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
>                         struct hdmi_gpio_data gpio = config->gpios[i];
>
> -                       if (gpio.gpiod) {
> -                               if (gpio.output) {
> -                                       gpiod_direction_output(gpio.gpiod,
> -                                                              gpio.value);
> -                               } else {
> -                                       gpiod_direction_input(gpio.gpiod);
> -                                       gpiod_set_value_cansleep(gpio.gpiod,
> -                                                                gpio.value);
> -                               }
> -                       }
> +                       /* The value indicates the value for turning things on */
> +                       if (gpio.gpiod)
> +                               gpiod_set_value_cansleep(gpio.gpiod, gpio.value);
>                 }
>
>                 DBG("gpio on");
> @@ -92,16 +85,10 @@ static int gpio_config(struct hdmi *hdmi, bool on)
>                 for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
>                         struct hdmi_gpio_data gpio = config->gpios[i];
>
> -                       if (!gpio.gpiod)
> -                               continue;
> -
> -                       if (gpio.output) {
> -                               int value = gpio.value ? 0 : 1;
> -
> -                               gpiod_set_value_cansleep(gpio.gpiod, value);
> -                       }
> +                       /* The inverse value turns stuff off */
> +                       if (gpio.gpiod && gpio.output)
> +                               gpiod_set_value_cansleep(gpio.gpiod, !gpio.value);
>                 };
> -
>                 DBG("gpio off");
>         }
>
> --
> 2.21.0
>


More information about the dri-devel mailing list