All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com, Deepak M <m.deepak@intel.com>
Subject: [PATCH 04/15] drm/i915/bios: have get_blocksize() support MIPI sequence block v3+
Date: Mon, 21 Dec 2015 15:10:55 +0200	[thread overview]
Message-ID: <e935bd5e119a83dd91214c47e6cd4f6ce8b2a17e.1450702954.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1450702954.git.jani.nikula@intel.com>
In-Reply-To: <cover.1450702954.git.jani.nikula@intel.com>

Have get_blocksize() support the special case of MIPI sequence block v3+
which has a separate field for size. Provide and use abstractions for
getting the blocksize given a pointer to the block "envelope",
i.e. pointer to the block id, and given a pointer to the block payload
data.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 91540ab15e0b..7393596df37d 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -58,6 +58,22 @@
 
 static int panel_type;
 
+/* Get BDB block size given a pointer to Block ID. */
+static u32 _get_blocksize(const u8 *block_base)
+{
+	/* The MIPI Sequence Block v3+ has a separate size field. */
+	if (*block_base == BDB_MIPI_SEQUENCE && *(block_base + 3) >= 3)
+		return *((const u32 *)(block_base + 4));
+	else
+		return *((const u16 *)(block_base + 1));
+}
+
+/* Get BDB block size give a pointer to data after Block ID and Block Size. */
+static u32 get_blocksize(const void *block_data)
+{
+	return _get_blocksize(block_data - 3);
+}
+
 static const void *
 find_section(const void *_bdb, int section_id)
 {
@@ -74,14 +90,8 @@ find_section(const void *_bdb, int section_id)
 	/* walk the sections looking for section_id */
 	while (index + 3 < total) {
 		current_id = *(base + index);
-		index++;
-
-		current_size = *((const u16 *)(base + index));
-		index += 2;
-
-		/* The MIPI Sequence Block v3+ has a separate size field. */
-		if (current_id == BDB_MIPI_SEQUENCE && *(base + index) >= 3)
-			current_size = *((const u32 *)(base + index + 1));
+		current_size = _get_blocksize(base + index);
+		index += 3;
 
 		if (index + current_size > total)
 			return NULL;
@@ -95,16 +105,6 @@ find_section(const void *_bdb, int section_id)
 	return NULL;
 }
 
-static u16
-get_blocksize(const void *p)
-{
-	u16 *block_ptr, block_size;
-
-	block_ptr = (u16 *)((char *)p - 2);
-	block_size = *block_ptr;
-	return block_size;
-}
-
 static void
 fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
 			const struct lvds_dvo_timing *dvo_timing)
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-12-21 13:11 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-21 13:10 [PATCH 00/15] drm/i915/bios: mipi sequence block v3, etc Jani Nikula
2015-12-21 13:10 ` [PATCH 01/15] drm/i915/bios: add proper documentation for the Video BIOS Table (VBT) Jani Nikula
2015-12-22 12:40   ` Jani Nikula
2015-12-21 13:10 ` [PATCH 02/15] drm/i915/bios: fix header define name for intel_bios.h Jani Nikula
2016-01-05 10:41   ` Daniel Vetter
2015-12-21 13:10 ` [PATCH 03/15] drm/i915/bios: split the MIPI DSI VBT block parsing to two Jani Nikula
2016-01-05 10:43   ` Daniel Vetter
2015-12-21 13:10 ` Jani Nikula [this message]
2016-01-05 10:45   ` [PATCH 04/15] drm/i915/bios: have get_blocksize() support MIPI sequence block v3+ Daniel Vetter
2016-01-05 13:01     ` Jani Nikula
2015-12-21 13:10 ` [PATCH 05/15] drm/i915/bios: abstract finding the panel sequence block Jani Nikula
2016-01-05 10:53   ` Daniel Vetter
2016-01-05 12:45     ` Jani Nikula
2016-01-05 13:59       ` Daniel Vetter
2016-01-05 13:50   ` [PATCH v2] " Jani Nikula
2015-12-21 13:10 ` [PATCH 06/15] drm/i915/bios: rewrite sequence block parsing Jani Nikula
2016-01-05 14:12   ` Daniel Vetter
2015-12-21 13:10 ` [PATCH 07/15] drm/i915/dsi: be defensive about out of bounds sequence id Jani Nikula
2016-01-05 14:12   ` Daniel Vetter
2015-12-21 13:10 ` [PATCH 08/15] drm/i915/dsi: be defensive about out of bounds operation byte Jani Nikula
2016-01-05 14:15   ` Daniel Vetter
2016-01-05 14:44     ` Jani Nikula
2015-12-21 13:11 ` [PATCH 09/15] drm/i915/bios: interpret the i2c element Jani Nikula
2016-01-05 19:21   ` Ville Syrjälä
2016-01-07  9:31     ` Jani Nikula
2016-01-07 14:16       ` Ville Syrjälä
2016-01-11 12:46         ` Jani Nikula
2016-01-11 16:01           ` Ville Syrjälä
2015-12-21 13:11 ` [PATCH 10/15] drm/i915/bios: add sequences for MIPI sequence block v2 Jani Nikula
2016-01-07 14:39   ` Ville Syrjälä
2016-01-07 14:54     ` Jani Nikula
2016-01-07 15:07       ` Ville Syrjälä
2015-12-21 13:11 ` [PATCH 11/15] drm/i915: Adding the parsing logic for the i2c element Jani Nikula
2016-01-07 15:05   ` Ville Syrjälä
2016-01-11 12:49     ` Jani Nikula
2016-01-11 13:31       ` Jani Nikula
2016-01-11 16:08         ` Ville Syrjälä
2016-01-11 13:29   ` [REPLACEMENT PATCH 11/15] drm/i915: skip the i2c element in the generic VBT DSI driver Jani Nikula
2016-01-11 15:56     ` Ville Syrjälä
2015-12-21 13:11 ` [PATCH 12/15] drm/i915/bios: add defines for v3 sequence block Jani Nikula
2016-01-07 15:27   ` Ville Syrjälä
2015-12-21 13:11 ` [PATCH 13/15] drm/i915/bios: add support for MIPI sequence block v3 Jani Nikula
2016-01-05 15:01   ` [PATCH v2] " Jani Nikula
2016-01-08 11:44     ` Ville Syrjälä
2016-01-11 13:15     ` [PATCH v3] " Jani Nikula
2016-01-11 15:51       ` Ville Syrjälä
2015-12-21 13:11 ` [PATCH 14/15] drm/i915/dsi: skip unknown elements for sequence block v3+ Jani Nikula
2016-01-05 14:19   ` Daniel Vetter
2016-01-05 14:54     ` Jani Nikula
2016-01-05 15:06   ` [PATCH v2] " Jani Nikula
2015-12-21 13:11 ` [PATCH 15/15] drm/i915/dsi: reduce tedious repetition Jani Nikula
2016-01-05 14:25   ` Daniel Vetter
2015-12-21 13:27 ` ✗ warning: Fi.CI.BAT Patchwork
2015-12-22  8:40 ` [PATCH 00/15] drm/i915/bios: mipi sequence block v3, etc Jani Nikula
2016-01-05 15:08 ` [PATCH] drm/i915/dsi: add debug printing of the new sequence block names Jani Nikula
2016-01-08 11:46   ` Ville Syrjälä
2016-01-05 16:01 ` ✗ failure: Fi.CI.BAT Patchwork
2016-01-11 13:30 ` [PATCH v5] drm/i915: Adding the parsing logic for the i2c element Jani Nikula
2016-01-11 13:32   ` Jani Nikula
2016-01-11 17:26     ` Jani Nikula
2016-01-11 13:30 ` ✗ failure: Fi.CI.BAT Patchwork
2016-01-11 14:01 ` Patchwork

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=e935bd5e119a83dd91214c47e6cd4f6ce8b2a17e.1450702954.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=m.deepak@intel.com \
    /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.