From: Daniel Vetter <daniel@ffwll.ch>
To: Alexandru M Stan <amstan@chromium.org>
Cc: David Airlie <airlied@linux.ie>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Archit Taneja <architt@codeaurora.org>,
Andrzej Hajda <a.hajda@samsung.com>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Sean Paul <seanpaul@chromium.org>,
devicetree@vger.kernel.org,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Heiko Stuebner <heiko@sntech.de>,
briannorris@chromium.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, dianders@chromium.org,
linux-rockchip@lists.infradead.org, marcheu@chromium.org,
hoegsberg@chromium.org,
Thierry Escande <thierry.escande@collabora.com>,
Jeffy Chen <jeffy.chen@rock-chips.com>,
Yakir Yang <kuankuan.y@gmail.com>,
Daniel Vetter <daniel.vetter@ffwll.ch>,
Marek Szyprowski <m.szyprowski@samsung.com>,
zain wang <wzz@rock-chips.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [PATCH 2/2] drm/bridge: analogix: Enable EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU
Date: Fri, 16 Mar 2018 09:36:04 +0100 [thread overview]
Message-ID: <20180316083604.GG25297@phenom.ffwll.local> (raw)
In-Reply-To: <20180316025659.217423-3-amstan@chromium.org>
On Thu, Mar 15, 2018 at 07:56:59PM -0700, Alexandru M Stan wrote:
> Configure the DPCD registers for the backlight to respect the pwm frequency
> of the input. We sometimes don't want it to generate its own.
>
> Signed-off-by: Alexandru M Stan <amstan@chromium.org>
I wonder a bit whether we should have some generic infrastructure in the
dp helpers itself to apply quirks like this. It's more-or-less what we
have for EDID quirking.
But then I guess for panels a lot of it is specific to the
bridge/encoder/panel combo and given platform, so probably not much use
for reuse across boards/platforms. External displays would be a different
story. I guess you can count that as an
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
on the overall thing, but pls get bridge folks to review this too.
-Daniel
> ---
>
> drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 48 ++++++++++++++++++++++
> drivers/gpu/drm/bridge/analogix/analogix_dp_core.h | 1 +
> 2 files changed, 49 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 5c52307146c7..b830403be8eb 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -916,6 +916,46 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
> return IRQ_HANDLED;
> }
>
> +static int analogix_dp_backlight_pwm_passthru(struct analogix_dp_device *dp)
> +{
> + u8 value;
> + const u8 expected_cap = DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP |
> + DP_EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU_CAP;
> + int ret = 0;
> +
> + ret = drm_dp_dpcd_readb(&dp->aux, DP_EDP_BACKLIGHT_ADJUSTMENT_CAP,
> + &value);
> + if (ret != 1) {
> + DRM_DEV_ERROR(dp->dev,
> + "backlight PWM passthru: Can't read BACKLIGHT_ADJUSTMENT_CAP\n");
> + return ret;
> + }
> +
> + if ((value & expected_cap) != expected_cap) {
> + DRM_DEV_ERROR(dp->dev,
> + "panel doesn't support backlight PWM passthru, BACKLIGHT_ADJUSTMENT_CAP=0x%02x\n",
> + value);
> + return -1;
> + }
> +
> + ret = drm_dp_dpcd_readb(&dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER,
> + &value);
> + if (ret != 1) {
> + DRM_DEV_ERROR(dp->dev,
> + "backlight PWM passthru: Can't read BACKLIGHT_MODE_SET_REGISTER\n");
> + return ret;
> + }
> +
> + value |= DP_EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU_ENABLE;
> + ret = drm_dp_dpcd_writeb(&dp->aux, DP_EDP_BACKLIGHT_MODE_SET_REGISTER,
> + value);
> + if (ret != 1) {
> + DRM_DEV_ERROR(dp->dev,
> + "backlight PWM passthru: Can't write BACKLIGHT_MODE_SET_REGISTER\n");
> + }
> + return ret;
> +}
> +
> static void analogix_dp_commit(struct analogix_dp_device *dp)
> {
> int ret;
> @@ -954,6 +994,12 @@ static void analogix_dp_commit(struct analogix_dp_device *dp)
> dp->psr_enable = analogix_dp_detect_sink_psr(dp);
> if (dp->psr_enable)
> analogix_dp_enable_sink_psr(dp);
> +
> + if (dp->backlight_pwm_passthru) {
> + if (analogix_dp_backlight_pwm_passthru(dp) != 1)
> + DRM_DEV_ERROR(dp->dev,
> + "Could not enable backlight pwm pin passthru.\n");
> + }
> }
>
> /*
> @@ -1424,6 +1470,8 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
> if (IS_ERR(dp->reg_base))
> return ERR_CAST(dp->reg_base);
>
> + dp->backlight_pwm_passthru =
> + of_property_read_bool(dev->of_node, "backlight-pwm-passthru");
> dp->force_hpd = of_property_read_bool(dev->of_node, "force-hpd");
>
> dp->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0);
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
> index 6a96ef7e6934..aea51413e78e 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
> @@ -171,6 +171,7 @@ struct analogix_dp_device {
> struct phy *phy;
> int dpms_mode;
> int hpd_gpio;
> + bool backlight_pwm_passthru;
> bool force_hpd;
> bool psr_enable;
> bool fast_train_support;
> --
> 2.13.5
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2018-03-16 8:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 2:56 [PATCH 0/2] Add backlight-pwm-passthru in analogix DP driver Alexandru M Stan
2018-03-16 2:56 ` [PATCH 1/2] dt-bindings: analogix-dp: Add backlight-pwm-passthru Alexandru M Stan
2018-03-16 9:26 ` Archit Taneja
2018-03-18 12:52 ` Rob Herring
2018-03-20 14:07 ` Laurent Pinchart
2018-03-16 2:56 ` [PATCH 2/2] drm/bridge: analogix: Enable EDP_BACKLIGHT_FREQ_PWM_PIN_PASSTHRU Alexandru M Stan
2018-03-16 8:36 ` Daniel Vetter [this message]
2018-03-16 16:50 ` [PATCH 0/2] Add backlight-pwm-passthru in analogix DP driver Sean Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180316083604.GG25297@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=amstan@chromium.org \
--cc=architt@codeaurora.org \
--cc=briannorris@chromium.org \
--cc=daniel.vetter@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=enric.balletbo@collabora.com \
--cc=heiko@sntech.de \
--cc=hoegsberg@chromium.org \
--cc=jeffy.chen@rock-chips.com \
--cc=kuankuan.y@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=marcheu@chromium.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=seanpaul@chromium.org \
--cc=thierry.escande@collabora.com \
--cc=wzz@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).