Message ID | 1622390172-31368-1-git-send-email-rajeevny@codeaurora.org |
---|---|
Headers | show |
Series | drm: Support basic DPCD backlight in panel-simple and add a new panel ATNA33XC20 | expand |
On Sun, 30 May 2021 21:26:11 +0530, Rajeev Nandan wrote: > Add Samsung 13.3" FHD eDP AMOLED panel. > > Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org> > Reviewed-by: Douglas Anderson <dianders@chromium.org> > --- > > (no changes since v4) > > Changes in v4: > - New > > Documentation/devicetree/bindings/display/panel/panel-simple.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Acked-by: Rob Herring <robh@kernel.org>
Hi, On Sun, May 30, 2021 at 8:57 AM Rajeev Nandan <rajeevny@codeaurora.org> wrote: > > +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 (brightness > 0) { > + 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; > + } > + } I was trying to figure out if there are any races / locking problems / problems trying to tweak the backlight when the panel is off. I don't _think_ there are. Specifically: 1. Before turning the panel off, drm_panel will call backlight_disable(). That will set BL_CORE_FBBLANK which is not set by any other calls. Then it will call your dp_aux_backlight_update_status(). 2. Once BL_CORE_FBBLANK is set then backlight_get_brightness() will always return 0. This means that a transition from 0 -> non-zero (and enable) will always only happen when the panel is on, which is good. It also means that we'll always transition to 0 (disable the backlight) when the panel turns off. In terms of other races, it looks like the AUX transfer code handles grabbing a mutex around transfers so we should be safe there. So I guess the above is just a long-winded way of saying that this looks right to me. :-) BTW: we should probably make sure that the full set of people identified by `./scripts/get_maintainer.pl -f ./drivers/video/backlight` are CCed on your series. I see Daniel already and I've added the rest. > +/** > + * 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; > + > + bl = devm_kzalloc(panel->dev, sizeof(*bl), GFP_KERNEL); > + if (!bl) > + return -ENOMEM; > + > + bl->aux = aux; > + > + ret = drm_dp_dpcd_read(aux, DP_EDP_DPCD_REV, edp_dpcd, > + EDP_DISPLAY_CTL_CAP_SIZE); > + if (ret < 0) > + return ret; > + > + if (!drm_edp_backlight_supported(edp_dpcd)) { > + DRM_DEV_INFO(panel->dev, "DP AUX backlight is not supported\n"); > + return 0; > + } nit: move this part up above the memory allocation. There's no reason to allocate memory for "bl" if the backlight isn't supported. > @@ -64,8 +65,8 @@ enum drm_panel_orientation; > * the panel. This is the job of the .unprepare() function. > * > * Backlight can be handled automatically if configured using > - * drm_panel_of_backlight(). Then the driver does not need to implement the > - * functionality to enable/disable backlight. > + * drm_panel_of_backlight() or drm_panel_dp_aux_backlight(). Then the driver > + * does not need to implement the functionality to enable/disable backlight. > */ > struct drm_panel_funcs { > /** > @@ -144,8 +145,8 @@ struct drm_panel { > * Backlight device, used to turn on backlight after the call > * to enable(), and to turn off backlight before the call to > * disable(). > - * backlight is set by drm_panel_of_backlight() and drivers > - * shall not assign it. > + * backlight is set by drm_panel_of_backlight()/drm_panel_dp_aux_backlight() > + * and drivers shall not assign it. Slight nit that I would have wrapped the drm_panel_dp_aux_backlight() to the next line just to avoid one really long line followed by a short one. Other than the two nits (ordering of memory allocation and word wrapping in a comment), this looks good to me. Feel free to add my Reviewed-by tag when you fix the nits. NOTE: Even though I have commit access to drm-misc now, I wouldn't feel comfortable merging this to drm-misc myself without review feedback from someone more senior. Obviously we're still blocked on my and Lyude's series landing first, but even assuming those just land as-is we'll need some more adult supervision before this can land. ;-) That being said, I personally think this looks pretty nice now. -Doug > */ > struct backlight_device *backlight; > > @@ -208,11 +209,17 @@ static inline int of_drm_get_panel_orientation(const struct device_node *np, > #if IS_ENABLED(CONFIG_DRM_PANEL) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \ > (IS_MODULE(CONFIG_DRM) && IS_MODULE(CONFIG_BACKLIGHT_CLASS_DEVICE))) > int drm_panel_of_backlight(struct drm_panel *panel); > +int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux); > #else > static inline int drm_panel_of_backlight(struct drm_panel *panel) > { > return 0; > } > +static inline int drm_panel_dp_aux_backlight(struct drm_panel *panel, > + struct drm_dp_aux *aux) > +{ > + return 0; > +} > #endif > > #endif > -- > 2.7.4 >
Hi, On Sun, May 30, 2021 at 8:57 AM Rajeev Nandan <rajeevny@codeaurora.org> wrote: > > Some panels datasheets may specify a delay between the enable GPIO and > the regulator. Support this in panel-simple. > > Signed-off-by: Rajeev Nandan <rajeevny@codeaurora.org> > --- > > Changes in v4: > - New > > Changes in v5: > - Update description (Douglas) > - Warn if "power_to_enable" or "disable_to_power_off" is non-zero and panel->enable_gpio > is NULL (Douglas) > > drivers/gpu/drm/panel/panel-simple.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c > index 047fad5..e3f5b7e 100644 > --- a/drivers/gpu/drm/panel/panel-simple.c > +++ b/drivers/gpu/drm/panel/panel-simple.c > @@ -133,6 +133,22 @@ struct panel_desc { > unsigned int prepare_to_enable; > > /** > + * @delay.power_to_enable: Time for the power to enable the display on. > + * > + * The time (in milliseconds) to wait after powering up the display > + * before asserting its enable pin. > + */ > + unsigned int power_to_enable; > + > + /** > + * @delay.disable_to_power_off: Time for the disable to power the display off. > + * > + * The time (in milliseconds) to wait before powering off the display > + * after deasserting its enable pin. > + */ > + unsigned int disable_to_power_off; > + > + /** > * @delay.enable: Time for the panel to display a valid frame. > * > * The time (in milliseconds) that it takes for the panel to > @@ -347,6 +363,10 @@ static int panel_simple_suspend(struct device *dev) > struct panel_simple *p = dev_get_drvdata(dev); > > gpiod_set_value_cansleep(p->enable_gpio, 0); > + > + if (p->desc->delay.disable_to_power_off) > + msleep(p->desc->delay.disable_to_power_off); > + > regulator_disable(p->supply); > p->unprepared_time = ktime_get(); > > @@ -407,6 +427,9 @@ static int panel_simple_prepare_once(struct panel_simple *p) > return err; > } > > + if (p->desc->delay.power_to_enable) > + msleep(p->desc->delay.power_to_enable); > + > gpiod_set_value_cansleep(p->enable_gpio, 1); > > delay = p->desc->delay.prepare; > @@ -782,6 +805,11 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc, > break; > } > > + if (!panel->enable_gpio && desc->delay.disable_to_power_off) > + dev_warn(dev, "Specify enable_gpio when using disable_to_power_off delay\n"); > + if (!panel->enable_gpio && desc->delay.power_to_enable) > + dev_warn(dev, "Specify enable_gpio when using power_to_enable delay\n"); Last nit is that the warning messages could be a little confusing to someone reading the logs. I guess the target audience of the error message is probably someone doing bringup. That person specified a panel in their device tree and maybe isn't even aware that they're using "disable_to_power_off" or "power_to_enable". Maybe wording instead: Need a delay after disabling panel GPIO, but a GPIO wasn't provided. Need a delay after enabling panel GPIO, but a GPIO wasn't provided. That's definitely getting into nittiness, though and I wouldn't be upset if the patch landed with the existing messages. Thus, with or without the change to the error message: Reviewed-by: Douglas Anderson <dianders@chromium.org>
On 03-06-2021 05:35, Doug Anderson wrote: > Hi, > > On Sun, May 30, 2021 at 8:57 AM Rajeev Nandan <rajeevny@codeaurora.org> > wrote: >> > > Other than the two nits (ordering of memory allocation and word > wrapping in a comment), this looks good to me. Feel free to add my > Reviewed-by tag when you fix the nits. > > NOTE: Even though I have commit access to drm-misc now, I wouldn't > feel comfortable merging this to drm-misc myself without review > feedback from someone more senior. Obviously we're still blocked on my > and Lyude's series landing first, but even assuming those just land > as-is we'll need some more adult supervision before this can land. ;-) > That being said, I personally think this looks pretty nice now. > > > -Doug Thank you, Doug. I'll address the review comments of this patch and another patch (v5 3/5) in the next spin. I'll wait for Lyude to check this series, as she wanted to review it in a few days. Thanks, Rajeev