All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: [PATCH 08/15] drm/bridge: anx7625: use struct drm_edid more
Date: Tue, 16 Apr 2024 16:22:22 +0300	[thread overview]
Message-ID: <7b0c0a010bd7c450e648865e85e9c238f65ef138.1713273659.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1713273659.git.jani.nikula@intel.com>

Prefer struct drm_edid based functions over struct edid.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Robert Foss <rfoss@kernel.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 26 +++++++++++++++--------
 drivers/gpu/drm/bridge/analogix/anx7625.h | 10 ++-------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index 9d96d28d6fe8..efee71a450f3 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -464,9 +464,11 @@ static int anx7625_odfc_config(struct anx7625_data *ctx,
  */
 static int anx7625_set_k_value(struct anx7625_data *ctx)
 {
-	struct edid *edid = (struct edid *)ctx->slimport_edid_p.edid_raw_data;
+	struct drm_edid_product_id id;
 
-	if (edid->mfg_id[0] == IVO_MID0 && edid->mfg_id[1] == IVO_MID1)
+	drm_edid_get_product_id(ctx->cached_drm_edid, &id);
+
+	if (be16_to_cpu(id.manufacturer_name) == IVO_MID)
 		return anx7625_reg_write(ctx, ctx->i2c.rx_p1_client,
 					 MIPI_DIGITAL_ADJ_1, 0x3B);
 
@@ -1526,7 +1528,8 @@ static int anx7625_wait_hpd_asserted(struct drm_dp_aux *aux,
 
 static void anx7625_remove_edid(struct anx7625_data *ctx)
 {
-	ctx->slimport_edid_p.edid_block_num = -1;
+	drm_edid_free(ctx->cached_drm_edid);
+	ctx->cached_drm_edid = NULL;
 }
 
 static void anx7625_dp_adjust_swing(struct anx7625_data *ctx)
@@ -1787,27 +1790,32 @@ static ssize_t anx7625_aux_transfer(struct drm_dp_aux *aux,
 static const struct drm_edid *anx7625_edid_read(struct anx7625_data *ctx)
 {
 	struct device *dev = ctx->dev;
-	struct s_edid_data *p_edid = &ctx->slimport_edid_p;
+	u8 *edid_buf;
 	int edid_num;
 
-	if (ctx->slimport_edid_p.edid_block_num > 0)
+	if (ctx->cached_drm_edid)
 		goto out;
 
+	edid_buf = kmalloc(FOUR_BLOCK_SIZE, GFP_KERNEL);
+	if (!edid_buf)
+		return NULL;
+
 	pm_runtime_get_sync(dev);
 	_anx7625_hpd_polling(ctx, 5000 * 100);
-	edid_num = sp_tx_edid_read(ctx, p_edid->edid_raw_data);
+	edid_num = sp_tx_edid_read(ctx, edid_buf);
 	pm_runtime_put_sync(dev);
 
 	if (edid_num < 1) {
 		DRM_DEV_ERROR(dev, "Fail to read EDID: %d\n", edid_num);
+		kfree(edid_buf);
 		return NULL;
 	}
 
-	p_edid->edid_block_num = edid_num;
+	ctx->cached_drm_edid = drm_edid_alloc(edid_buf, FOUR_BLOCK_SIZE);
+	kfree(edid_buf);
 
 out:
-	return drm_edid_alloc(ctx->slimport_edid_p.edid_raw_data,
-			      FOUR_BLOCK_SIZE);
+	return drm_edid_dup(ctx->cached_drm_edid);
 }
 
 static enum drm_connector_status anx7625_sink_detect(struct anx7625_data *ctx)
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h
index 39ed35d33836..eb5580f1ab2f 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.h
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
@@ -286,8 +286,7 @@
 
 #define  MIPI_LANE_CTRL_10               0x0F
 #define  MIPI_DIGITAL_ADJ_1     0x1B
-#define  IVO_MID0               0x26
-#define  IVO_MID1               0xCF
+#define  IVO_MID                0x26CF
 
 #define  MIPI_PLL_M_NUM_23_16   0x1E
 #define  MIPI_PLL_M_NUM_15_8    0x1F
@@ -417,11 +416,6 @@ enum audio_wd_len {
 #define EDID_TRY_CNT	3
 #define SUPPORT_PIXEL_CLOCK	300000
 
-struct s_edid_data {
-	int edid_block_num;
-	u8 edid_raw_data[FOUR_BLOCK_SIZE];
-};
-
 /***************** Display End *****************/
 
 #define MAX_LANES_SUPPORT	4
@@ -466,7 +460,7 @@ struct anx7625_data {
 	struct anx7625_i2c_client i2c;
 	struct i2c_client *last_client;
 	struct timer_list hdcp_timer;
-	struct s_edid_data slimport_edid_p;
+	const struct drm_edid *cached_drm_edid;
 	struct device *codec_dev;
 	hdmi_codec_plugged_cb plugged_cb;
 	struct work_struct work;
-- 
2.39.2


  parent reply	other threads:[~2024-04-16 13:23 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 13:22 [PATCH 00/15] drm: struct drm_edid conversions Jani Nikula
2024-04-16 13:22 ` [PATCH 01/15] drm/panel: simple: switch to struct drm_edid Jani Nikula
2024-04-16 17:41   ` Neil Armstrong
2024-04-16 13:22 ` [PATCH 02/15] drm/panel-samsung-atna33xc20: " Jani Nikula
2024-04-16 17:41   ` Neil Armstrong
2024-04-16 13:22 ` [PATCH 03/15] drm/panel-edp: " Jani Nikula
2024-04-16 17:43   ` Neil Armstrong
2024-04-16 13:22 ` [PATCH 04/15] drm/bridge/analogix/anx6345: " Jani Nikula
2024-04-16 13:22 ` [PATCH 05/15] drm/bridge/analogix/anx78xx: " Jani Nikula
2024-04-16 13:22 ` [PATCH 06/15] drm/sun4i: hdmi: " Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-18 11:51   ` Maxime Ripard
2024-04-18 11:51     ` Maxime Ripard
2024-04-16 13:22 ` [PATCH 07/15] drm/vc4: " Jani Nikula
2024-04-18 11:51   ` Maxime Ripard
2024-04-16 13:22 ` Jani Nikula [this message]
2024-04-16 13:22 ` [PATCH 09/15] drm/gud: " Jani Nikula
2024-04-17 15:26   ` Noralf Trønnes
2024-04-16 13:22 ` [PATCH 10/15] drm/i2c: tda998x: " Jani Nikula
2024-04-16 13:22 ` [PATCH 11/15] drm/bochs: " Jani Nikula
2024-04-16 13:22 ` [PATCH 12/15] drm/virtio: " Jani Nikula
2024-04-16 13:22 ` [PATCH 13/15] drm/rockchip: cdn-dp: " Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-19 10:58   ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-04-16 13:22 ` [PATCH 14/15] drm/rockchip: inno_hdmi: " Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-19 10:58   ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-04-16 13:22 ` [PATCH 15/15] drm/rockchip: rk3066_hdmi: " Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-16 13:22   ` Jani Nikula
2024-04-19 10:58   ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-04-19 10:58     ` Heiko Stuebner
2024-05-07 15:34 ` [PATCH 00/15] drm: struct drm_edid conversions Thomas Zimmermann
2024-05-10 13:28   ` Jani Nikula

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=7b0c0a010bd7c450e648865e85e9c238f65ef138.1713273659.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.