[v2,3/4] drm/modes: Add a function to clear preferred modes

Message ID 20231102221309.1971910-4-hsinyi@chromium.org
State New
Headers
Series Add a few panels and use correct modes |

Commit Message

Hsin-Yi Wang Nov. 2, 2023, 9:47 p.m. UTC
  Add a function to clear the preferred bit of a connector's existing modes.
This is useful for edp panel to unset the preferred modes read from edid
if the panel has hard-coded modes.

Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
v1->v2:
- fix doc string (reported by kernel test robot).
- split mode and panel patches.
---
 drivers/gpu/drm/drm_modes.c | 16 ++++++++++++++++
 include/drm/drm_modes.h     |  1 +
 2 files changed, 17 insertions(+)
  

Comments

Doug Anderson Nov. 3, 2023, 4:02 p.m. UTC | #1
Hi,

On Thu, Nov 2, 2023 at 3:13 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
>
> Add a function to clear the preferred bit of a connector's existing modes.
> This is useful for edp panel to unset the preferred modes read from edid
> if the panel has hard-coded modes.
>
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> ---
> v1->v2:
> - fix doc string (reported by kernel test robot).
> - split mode and panel patches.
> ---
>  drivers/gpu/drm/drm_modes.c | 16 ++++++++++++++++
>  include/drm/drm_modes.h     |  1 +
>  2 files changed, 17 insertions(+)

This seems fine to me.

Reviewed-by: Douglas Anderson <dianders@chromium.org>

Since it introduces a new API to the core and Hsin-Yi and I work
directly together, I'd probably give this ~2 weeks on the list before
landing so there is adequate time for people to comment. That'll be
right in the middle of Plumbers, though, so it might be more like 3
weeks. If someone non-ChromeOS wants to review and/or apply sooner, I
certainly wouldn't object.
  
Maxime Ripard Nov. 6, 2023, 8:08 a.m. UTC | #2
On Fri, Nov 03, 2023 at 09:02:33AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Thu, Nov 2, 2023 at 3:13 PM Hsin-Yi Wang <hsinyi@chromium.org> wrote:
> >
> > Add a function to clear the preferred bit of a connector's existing modes.
> > This is useful for edp panel to unset the preferred modes read from edid
> > if the panel has hard-coded modes.
> >
> > Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
> > ---
> > v1->v2:
> > - fix doc string (reported by kernel test robot).
> > - split mode and panel patches.
> > ---
> >  drivers/gpu/drm/drm_modes.c | 16 ++++++++++++++++
> >  include/drm/drm_modes.h     |  1 +
> >  2 files changed, 17 insertions(+)
> 
> This seems fine to me.
> 
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
> 
> Since it introduces a new API to the core and Hsin-Yi and I work
> directly together, I'd probably give this ~2 weeks on the list before
> landing so there is adequate time for people to comment. That'll be
> right in the middle of Plumbers, though, so it might be more like 3
> weeks. If someone non-ChromeOS wants to review and/or apply sooner, I
> certainly wouldn't object.

FTR, I just made some review on v1 that still applies to that version.

Maxime
  

Patch

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ac9a406250c5..be3e9e931219 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1933,6 +1933,22 @@  void drm_connector_list_update(struct drm_connector *connector)
 }
 EXPORT_SYMBOL(drm_connector_list_update);
 
+/**
+ * drm_mode_unset_preferred_modes - clear the preferred bit on existing modes.
+ * @connector: the connector to update
+ *
+ * Walk the mode list for connector, clearing the preferred status on existing
+ * modes.
+ */
+void drm_mode_unset_preferred_modes(struct drm_connector *connector)
+{
+	struct drm_display_mode *cur_mode;
+
+	list_for_each_entry(cur_mode, &connector->probed_modes, head)
+		cur_mode->type &= ~DRM_MODE_TYPE_PREFERRED;
+}
+EXPORT_SYMBOL_GPL(drm_mode_unset_preferred_modes);
+
 static int drm_mode_parse_cmdline_bpp(const char *str, char **end_ptr,
 				      struct drm_cmdline_mode *mode)
 {
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index c613f0abe9dc..301817e00a15 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -560,6 +560,7 @@  void drm_mode_prune_invalid(struct drm_device *dev,
 			    struct list_head *mode_list, bool verbose);
 void drm_mode_sort(struct list_head *mode_list);
 void drm_connector_list_update(struct drm_connector *connector);
+void drm_mode_unset_preferred_modes(struct drm_connector *connector);
 
 /* parsing cmdline modes */
 bool