diff mbox series

[2/2] drm/bridge: chipone-icn6211: Add mode_set API

Message ID 20211119145325.1775046-2-jagan@amarulasolutions.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/bridge: chipone-icn6211: Switch to atomic operations | expand

Commit Message

Jagan Teki Nov. 19, 2021, 2:53 p.m. UTC
Get the display mode settings via mode_set bridge
function instead of explicitly de-reference.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/bridge/chipone-icn6211.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Robert Foss Jan. 4, 2022, 1:28 p.m. UTC | #1
On Fri, 19 Nov 2021 at 15:53, Jagan Teki <jagan@amarulasolutions.com> wrote:
>
> Get the display mode settings via mode_set bridge
> function instead of explicitly de-reference.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
>  drivers/gpu/drm/bridge/chipone-icn6211.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/chipone-icn6211.c b/drivers/gpu/drm/bridge/chipone-icn6211.c
> index 77b3e2c29461..e8f36dca56b3 100644
> --- a/drivers/gpu/drm/bridge/chipone-icn6211.c
> +++ b/drivers/gpu/drm/bridge/chipone-icn6211.c
> @@ -31,6 +31,7 @@
>  struct chipone {
>         struct device *dev;
>         struct drm_bridge bridge;
> +       struct drm_display_mode mode;
>         struct drm_bridge *panel_bridge;
>         struct gpio_desc *enable_gpio;
>         struct regulator *vdd1;
> @@ -43,11 +44,6 @@ static inline struct chipone *bridge_to_chipone(struct drm_bridge *bridge)
>         return container_of(bridge, struct chipone, bridge);
>  }
>
> -static struct drm_display_mode *bridge_to_mode(struct drm_bridge *bridge)
> -{
> -       return &bridge->encoder->crtc->state->adjusted_mode;
> -}
> -
>  static inline int chipone_dsi_write(struct chipone *icn,  const void *seq,
>                                     size_t len)
>  {
> @@ -66,7 +62,7 @@ static void chipone_atomic_enable(struct drm_bridge *bridge,
>                                   struct drm_bridge_state *old_bridge_state)
>  {
>         struct chipone *icn = bridge_to_chipone(bridge);
> -       struct drm_display_mode *mode = bridge_to_mode(bridge);
> +       struct drm_display_mode *mode = &icn->mode;
>
>         ICN6211_DSI(icn, 0x7a, 0xc1);
>
> @@ -165,6 +161,15 @@ static void chipone_atomic_post_disable(struct drm_bridge *bridge,
>         gpiod_set_value(icn->enable_gpio, 0);
>  }
>
> +static void chipone_mode_set(struct drm_bridge *bridge,
> +                            const struct drm_display_mode *mode,
> +                            const struct drm_display_mode *adjusted_mode)
> +{
> +       struct chipone *icn = bridge_to_chipone(bridge);
> +
> +       drm_mode_copy(&icn->mode, adjusted_mode);
> +}
> +
>  static int chipone_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags)
>  {
>         struct chipone *icn = bridge_to_chipone(bridge);
> @@ -179,6 +184,7 @@ static const struct drm_bridge_funcs chipone_bridge_funcs = {
>         .atomic_pre_enable      = chipone_atomic_pre_enable,
>         .atomic_enable          = chipone_atomic_enable,
>         .atomic_post_disable    = chipone_atomic_post_disable,
> +       .mode_set               = chipone_mode_set,
>         .attach                 = chipone_attach,
>  };
>
> --
> 2.25.1
>

Reviewed-by: Robert Foss <robert.foss@linaro.org>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/chipone-icn6211.c b/drivers/gpu/drm/bridge/chipone-icn6211.c
index 77b3e2c29461..e8f36dca56b3 100644
--- a/drivers/gpu/drm/bridge/chipone-icn6211.c
+++ b/drivers/gpu/drm/bridge/chipone-icn6211.c
@@ -31,6 +31,7 @@ 
 struct chipone {
 	struct device *dev;
 	struct drm_bridge bridge;
+	struct drm_display_mode mode;
 	struct drm_bridge *panel_bridge;
 	struct gpio_desc *enable_gpio;
 	struct regulator *vdd1;
@@ -43,11 +44,6 @@  static inline struct chipone *bridge_to_chipone(struct drm_bridge *bridge)
 	return container_of(bridge, struct chipone, bridge);
 }
 
-static struct drm_display_mode *bridge_to_mode(struct drm_bridge *bridge)
-{
-	return &bridge->encoder->crtc->state->adjusted_mode;
-}
-
 static inline int chipone_dsi_write(struct chipone *icn,  const void *seq,
 				    size_t len)
 {
@@ -66,7 +62,7 @@  static void chipone_atomic_enable(struct drm_bridge *bridge,
 				  struct drm_bridge_state *old_bridge_state)
 {
 	struct chipone *icn = bridge_to_chipone(bridge);
-	struct drm_display_mode *mode = bridge_to_mode(bridge);
+	struct drm_display_mode *mode = &icn->mode;
 
 	ICN6211_DSI(icn, 0x7a, 0xc1);
 
@@ -165,6 +161,15 @@  static void chipone_atomic_post_disable(struct drm_bridge *bridge,
 	gpiod_set_value(icn->enable_gpio, 0);
 }
 
+static void chipone_mode_set(struct drm_bridge *bridge,
+			     const struct drm_display_mode *mode,
+			     const struct drm_display_mode *adjusted_mode)
+{
+	struct chipone *icn = bridge_to_chipone(bridge);
+
+	drm_mode_copy(&icn->mode, adjusted_mode);
+}
+
 static int chipone_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags)
 {
 	struct chipone *icn = bridge_to_chipone(bridge);
@@ -179,6 +184,7 @@  static const struct drm_bridge_funcs chipone_bridge_funcs = {
 	.atomic_pre_enable	= chipone_atomic_pre_enable,
 	.atomic_enable		= chipone_atomic_enable,
 	.atomic_post_disable	= chipone_atomic_post_disable,
+	.mode_set		= chipone_mode_set,
 	.attach			= chipone_attach,
 };