linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Rajeev Nandan <rajeevny@codeaurora.org>,
	dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	freedreno@lists.freedesktop.org, devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, thierry.reding@gmail.com,
	sam@ravnborg.org, robdclark@gmail.com, dianders@chromium.org,
	lyude@redhat.com, jani.nikula@intel.com, robh@kernel.org,
	laurent.pinchart@ideasonboard.com, a.hajda@samsung.com,
	daniel.thompson@linaro.org, hoegsberg@chromium.org,
	abhinavk@codeaurora.org, seanpaul@chromium.org,
	kalyan_t@codeaurora.org, mkrishn@codeaurora.org,
	lee.jones@linaro.org, jingoohan1@gmail.com,
	linux-fbdev@vger.kernel.org
Subject: Re: [v8 1/6] drm/panel: add basic DP AUX backlight support
Date: Mon, 12 Jul 2021 11:45:12 +0200	[thread overview]
Message-ID: <00e95983-c7de-1091-d295-9d544f37687c@suse.de> (raw)
In-Reply-To: <7f8562df-7e1f-dcfb-1c58-f1edd9dcc606@suse.de>


[-- Attachment #1.1: Type: text/plain, Size: 5696 bytes --]

Hi

Am 12.07.21 um 11:41 schrieb Thomas Zimmermann:
> 
> 
> Am 26.06.21 um 18:51 schrieb Rajeev Nandan:
>> Some panels support backlight control over DP AUX channel using
>> VESA's standard backlight control interface.
>> Using new DRM eDP backlight helpers, add support to create and
>> register a backlight for those panels in drm_panel to simplify
>> the panel drivers.
>>
>> The panel driver with access to "struct drm_dp_aux" can create and
>> register a backlight device using following code snippet in its
>> probe() function:
>>
>>     err = drm_panel_dp_aux_backlight(panel, aux);
>>     if (err)
>>         return err;
>>
>> Then drm_panel will handle backlight_(enable|disable) calls
>> similar to the case when drm_panel_of_backlight() is used.
>>
>> Currently, we are not supporting one feature where the source
>> device can combine the backlight brightness levels set through
>> DP AUX and the BL_PWM_DIM eDP connector pin. Since it's not
>> required for the basic backlight controls, it can be added later.
>>
>> Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org>
>> Reviewed-by: Douglas Anderson <dianders@chromium.org>
>> Reviewed-by: Lyude Paul <lyude@redhat.com>
>> ---
>>
>> Changes in v5:
>> - New
>>
>> Changes in v6:
>> - Fixed ordering of memory allocation (Douglas)
>> - Updated word wrapping in a comment (Douglas)
>>
>> Changes in v8:
>> - Now using backlight_is_blank() to get the backlight blank status 
>> (Sam Ravnborg)
>>
>>   drivers/gpu/drm/drm_panel.c | 108 
>> ++++++++++++++++++++++++++++++++++++++++++++
>>   include/drm/drm_panel.h     |  15 ++++--
>>   2 files changed, 119 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
>> index f634371..4fa1e3b 100644
>> --- a/drivers/gpu/drm/drm_panel.c
>> +++ b/drivers/gpu/drm/drm_panel.c
>> @@ -26,12 +26,20 @@
>>   #include <linux/module.h>
>>   #include <drm/drm_crtc.h>
>> +#include <drm/drm_dp_helper.h>
>>   #include <drm/drm_panel.h>
>>   #include <drm/drm_print.h>
>>   static DEFINE_MUTEX(panel_lock);
>>   static LIST_HEAD(panel_list);
>> +struct dp_aux_backlight {
>> +    struct backlight_device *base;
>> +    struct drm_dp_aux *aux;
>> +    struct drm_edp_backlight_info info;
>> +    bool enabled;
>> +};
>> +
>>   /**
>>    * DOC: drm panel
>>    *
>> @@ -342,6 +350,106 @@ int drm_panel_of_backlight(struct drm_panel *panel)
>>       return 0;
>>   }
>>   EXPORT_SYMBOL(drm_panel_of_backlight);
>> +
>> +static int dp_aux_backlight_update_status(struct backlight_device *bd)
>> +{
>> +    struct dp_aux_backlight *bl = bl_get_data(bd);
>> +    u16 brightness = backlight_get_brightness(bd);
>> +    int ret = 0;
>> +
>> +    if (!backlight_is_blank(bd)) {
>> +        if (!bl->enabled) {
>> +            drm_edp_backlight_enable(bl->aux, &bl->info, brightness);
>> +            bl->enabled = true;
>> +            return 0;
>> +        }
>> +        ret = drm_edp_backlight_set_level(bl->aux, &bl->info, 
>> brightness);
>> +    } else {
>> +        if (bl->enabled) {
>> +            drm_edp_backlight_disable(bl->aux, &bl->info);
>> +            bl->enabled = false;
>> +        }
>> +    }
>> +
>> +    return ret;
>> +}
>> +
>> +static const struct backlight_ops dp_aux_bl_ops = {
>> +    .update_status = dp_aux_backlight_update_status,
>> +};
>> +
>> +/**
>> + * drm_panel_dp_aux_backlight - create and use DP AUX backlight
>> + * @panel: DRM panel
>> + * @aux: The DP AUX channel to use
>> + *
>> + * Use this function to create and handle backlight if your panel
>> + * supports backlight control over DP AUX channel using DPCD
>> + * registers as per VESA's standard backlight control interface.
>> + *
>> + * When the panel is enabled backlight will be enabled after a
>> + * successful call to &drm_panel_funcs.enable()
>> + *
>> + * When the panel is disabled backlight will be disabled before the
>> + * call to &drm_panel_funcs.disable().
>> + *
>> + * A typical implementation for a panel driver supporting backlight
>> + * control over DP AUX will call this function at probe time.
>> + * Backlight will then be handled transparently without requiring
>> + * any intervention from the driver.
>> + *
>> + * drm_panel_dp_aux_backlight() must be called after the call to 
>> drm_panel_init().
>> + *
>> + * Return: 0 on success or a negative error code on failure.
>> + */
>> +int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct 
>> drm_dp_aux *aux)
>> +{
>> +    struct dp_aux_backlight *bl;
>> +    struct backlight_properties props = { 0 };
>> +    u16 current_level;
>> +    u8 current_mode;
>> +    u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
>> +    int ret;
>> +
>> +    if (!panel || !panel->dev || !aux)
>> +        return -EINVAL;
>> +
>> +    ret = drm_dp_dpcd_read(aux, DP_EDP_DPCD_REV, edp_dpcd,
>> +                   EDP_DISPLAY_CTL_CAP_SIZE);
> 
> This creates a cyclic dependency between drm_kms_helper-ko and drm.ko. 
> drm_panel.c is in the latter, while drm_dp_dpcd_read() in 
> drm_dp_helper.c is in the former. Please fix.

FYI, build DRM as modules and the error shows up during make module_install.

Best regards
Thomas


-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

  reply	other threads:[~2021-07-12  9:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-26 16:51 [v8 0/6] drm: Support basic DPCD backlight in panel-simple and add a new panel ATNA33XC20 Rajeev Nandan
2021-06-26 16:51 ` [v8 1/6] drm/panel: add basic DP AUX backlight support Rajeev Nandan
2021-07-12  9:41   ` Thomas Zimmermann
2021-07-12  9:45     ` Thomas Zimmermann [this message]
2021-07-12 13:39     ` Doug Anderson
2021-07-12 15:03       ` Doug Anderson
2021-06-26 16:51 ` [v8 2/6] drm/panel-simple: Support DP AUX backlight Rajeev Nandan
2021-06-26 16:51 ` [v8 3/6] drm/panel-simple: Support for delays between GPIO & regulator Rajeev Nandan
2021-06-26 16:51 ` [v8 4/6] drm/panel-simple: Update validation warnings for eDP panel description Rajeev Nandan
2021-06-27 18:18   ` Laurent Pinchart
2021-06-28 12:16     ` rajeevny
2021-06-28 13:33       ` Laurent Pinchart
2021-06-28 15:34         ` Doug Anderson
2021-06-28 16:25           ` Laurent Pinchart
2021-06-26 16:51 ` [v8 5/6] dt-bindings: display: simple: Add Samsung ATNA33XC20 Rajeev Nandan
2021-06-26 16:51 ` [v8 6/6] drm/panel-simple: " Rajeev Nandan
2021-07-09 13:54 ` [v8 0/6] drm: Support basic DPCD backlight in panel-simple and add a new panel ATNA33XC20 Doug Anderson
2021-07-09 20:40   ` Ville Syrjälä
2021-07-09 22:31     ` Doug Anderson

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=00e95983-c7de-1091-d295-9d544f37687c@suse.de \
    --to=tzimmermann@suse.de \
    --cc=a.hajda@samsung.com \
    --cc=abhinavk@codeaurora.org \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=hoegsberg@chromium.org \
    --cc=jani.nikula@intel.com \
    --cc=jingoohan1@gmail.com \
    --cc=kalyan_t@codeaurora.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=mkrishn@codeaurora.org \
    --cc=rajeevny@codeaurora.org \
    --cc=robdclark@gmail.com \
    --cc=robh@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=seanpaul@chromium.org \
    --cc=thierry.reding@gmail.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).