]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/bridge: tc358768: Add atomic_get_input_bus_fmts() implementation
authorFrancesco Dolcini <francesco.dolcini@toradex.com>
Thu, 30 Mar 2023 09:59:41 +0000 (11:59 +0200)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:39 +0000 (17:19 +0200)
BugLink: https://bugs.launchpad.net/bugs/2034469
[ Upstream commit cec5ccef85bd0128cf895612de54a9d21d2015d0 ]

Add atomic_get_input_bus_fmts() implementation, tc358768 has a parallel
RGB input interface with the actual bus format depending on the amount
of parallel input data lines.

Without this change when the tc358768 is used with less than 24bit the
color mapping is completely wrong.

Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Robert Foss <rfoss@kernel.org>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230330095941.428122-7-francesco@dolcini.it
Stable-dep-of: ee18698e212b ("drm/bridge: tc358768: fix TCLK_TRAILCNT computation")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/gpu/drm/bridge/tc358768.c

index 765bdebbd06f917379c4c1102003ea9a9102f19a..8f7efb14ebdc731e461c70ef19b009574114d081 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
+#include <linux/media-bus-format.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
@@ -919,6 +920,44 @@ static void tc358768_bridge_enable(struct drm_bridge *bridge)
        }
 }
 
+#define MAX_INPUT_SEL_FORMATS  1
+
+static u32 *
+tc358768_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
+                                  struct drm_bridge_state *bridge_state,
+                                  struct drm_crtc_state *crtc_state,
+                                  struct drm_connector_state *conn_state,
+                                  u32 output_fmt,
+                                  unsigned int *num_input_fmts)
+{
+       struct tc358768_priv *priv = bridge_to_tc358768(bridge);
+       u32 *input_fmts;
+
+       *num_input_fmts = 0;
+
+       input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
+                            GFP_KERNEL);
+       if (!input_fmts)
+               return NULL;
+
+       switch (priv->pd_lines) {
+       case 16:
+               input_fmts[0] = MEDIA_BUS_FMT_RGB565_1X16;
+               break;
+       case 18:
+               input_fmts[0] = MEDIA_BUS_FMT_RGB666_1X18;
+               break;
+       default:
+       case 24:
+               input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
+               break;
+       };
+
+       *num_input_fmts = MAX_INPUT_SEL_FORMATS;
+
+       return input_fmts;
+}
+
 static const struct drm_bridge_funcs tc358768_bridge_funcs = {
        .attach = tc358768_bridge_attach,
        .mode_valid = tc358768_bridge_mode_valid,
@@ -926,6 +965,11 @@ static const struct drm_bridge_funcs tc358768_bridge_funcs = {
        .enable = tc358768_bridge_enable,
        .disable = tc358768_bridge_disable,
        .post_disable = tc358768_bridge_post_disable,
+
+       .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+       .atomic_reset = drm_atomic_helper_bridge_reset,
+       .atomic_get_input_bus_fmts = tc358768_atomic_get_input_bus_fmts,
 };
 
 static const struct drm_bridge_timings default_tc358768_timings = {