Re: [Intel-gfx] [PATCH v3] drm/i915: Add parsing support for new MIPI blocks in VBT
On Mon, Apr 14, 2014 at 11:00:34AM +0530, Shobhit Kumar wrote: The parser extracts the config block(#52) and sequence(#53) data and store in private data structures. v2: Address review comments by Jani - adjust code for the structure changes for bdb_mipi_config - add boundry and buffer overflow checks as suggested - use kmemdup instead of kmalloc and memcpy v3: More strict check while parsing VBT - Ensure that at anytime we do not go beyond sequence block while parsing - On unknown element fail the whole parsing v4: Style changes and spell check mostly as suggested by Jani Signed-off-by: Shobhit Kumar shobhit.ku...@intel.com Reviewed-by: Jani Nikula jani.nik...@intel.com I didn't spot Jani's r-b tag in earlier mails, was that done off-list? -Daniel --- drivers/gpu/drm/i915/i915_drv.h | 6 ++ drivers/gpu/drm/i915/intel_bios.c | 204 +- drivers/gpu/drm/i915/intel_bios.h | 31 ++ 3 files changed, 236 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 85e362f..1b763aa 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1170,6 +1170,12 @@ struct intel_vbt_data { /* MIPI DSI */ struct { u16 panel_id; + struct mipi_config *config; + struct mipi_pps_data *pps; + u8 seq_version; + u32 size; + u8 *data; + u8 *sequence[MIPI_SEQ_MAX]; } dsi; int crt_ddc_pin; diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index 862ca04..917f5bb 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c @@ -636,19 +636,213 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb) } } +static u8 *goto_next_sequence(u8 *data, int *size) +{ + u16 len; + int tmp = *size; + + if (--tmp 0) + return NULL; + + /* goto first element */ + data++; + while (1) { + switch (*data) { + case MIPI_SEQ_ELEM_SEND_PKT: + /* + * skip by this element payload size + * skip elem id, command flag and data type + */ + if ((tmp = tmp - 5) 0) + return NULL; + + data += 3; + len = *((u16 *)data); + + if ((tmp = tmp - len) 0) + return NULL; + + /* skip by len */ + data = data + 2 + len; + break; + case MIPI_SEQ_ELEM_DELAY: + /* skip by elem id, and delay is 4 bytes */ + if ((tmp = tmp - 5) 0) + return NULL; + + data += 5; + break; + case MIPI_SEQ_ELEM_GPIO: + if ((tmp = tmp - 3) 0) + return NULL; + + data += 3; + break; + default: + DRM_ERROR(Unknown element\n); + return NULL; + } + + /* end of sequence ? */ + if (*data == 0) + break; + } + + /* goto next sequence or end of block byte */ + if (--tmp 0) + return NULL; + + data++; + + /* update amount of data left for the sequence block to be parsed */ + *size = tmp; + return data; +} + static void parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb) { - struct bdb_mipi *mipi; + struct bdb_mipi_config *start; + struct bdb_mipi_sequence *sequence; + struct mipi_config *config; + struct mipi_pps_data *pps; + u8 *data, *seq_data; + int i, panel_id, seq_size; + u16 block_size; + + /* Initialize this to undefined indicating no generic MIPI support */ + dev_priv-vbt.dsi.panel_id = MIPI_DSI_UNDEFINED_PANEL_ID; + + /* Block #40 is already parsed and panel_fixed_mode is + * stored in dev_priv-lfp_lvds_vbt_mode + * resuse this when needed + */ - mipi = find_section(bdb, BDB_MIPI_CONFIG); - if (!mipi) { - DRM_DEBUG_KMS(No MIPI BDB found); + /* Parse #52 for panel index used from panel_type already + * parsed + */ + start = find_section(bdb, BDB_MIPI_CONFIG); + if (!start) { + DRM_DEBUG_KMS(No MIPI config BDB found); return; } - /* XXX: add more info */ + DRM_DEBUG_DRIVER(Found MIPI Config block, panel index = %d\n, + panel_type); + + /* + * get hold of the correct configuration
Re: [Intel-gfx] [PATCH v3] drm/i915: Add parsing support for new MIPI blocks in VBT
On 4/14/2014 12:32 PM, Daniel Vetter wrote: On Mon, Apr 14, 2014 at 11:00:34AM +0530, Shobhit Kumar wrote: The parser extracts the config block(#52) and sequence(#53) data and store in private data structures. v2: Address review comments by Jani - adjust code for the structure changes for bdb_mipi_config - add boundry and buffer overflow checks as suggested - use kmemdup instead of kmalloc and memcpy v3: More strict check while parsing VBT - Ensure that at anytime we do not go beyond sequence block while parsing - On unknown element fail the whole parsing v4: Style changes and spell check mostly as suggested by Jani Signed-off-by: Shobhit Kumar shobhit.ku...@intel.com Reviewed-by: Jani Nikula jani.nik...@intel.com I didn't spot Jani's r-b tag in earlier mails, was that done off-list? Yeah, was reviewed along with the other DSI patchset you merged, sorry about that. But then some patches needed internal review while they were being approved for up-streaming to save time. And this one was related to the other panel driver patches which I published today so got stuck with them. Sorry about that. Regards Shobhit ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm/i915: Add parsing support for new MIPI blocks in VBT
On Mon, Apr 14, 2014 at 01:24:43PM +0530, Kumar, Shobhit wrote: On 4/14/2014 12:32 PM, Daniel Vetter wrote: On Mon, Apr 14, 2014 at 11:00:34AM +0530, Shobhit Kumar wrote: The parser extracts the config block(#52) and sequence(#53) data and store in private data structures. v2: Address review comments by Jani - adjust code for the structure changes for bdb_mipi_config - add boundry and buffer overflow checks as suggested - use kmemdup instead of kmalloc and memcpy v3: More strict check while parsing VBT - Ensure that at anytime we do not go beyond sequence block while parsing - On unknown element fail the whole parsing v4: Style changes and spell check mostly as suggested by Jani Signed-off-by: Shobhit Kumar shobhit.ku...@intel.com Reviewed-by: Jani Nikula jani.nik...@intel.com I didn't spot Jani's r-b tag in earlier mails, was that done off-list? Yeah, was reviewed along with the other DSI patchset you merged, sorry about that. But then some patches needed internal review while they were being approved for up-streaming to save time. And this one was related to the other panel driver patches which I published today so got stuck with them. Sorry about that. Ok, pulled it in. checkpatch complained a few times about assignments in if conditions, and I tend to agree. Can you please follow up with a cleanup patch? Also it looks like assignment operators could be used. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v3] drm/i915: Add parsing support for new MIPI blocks in VBT
On 4/14/2014 2:35 PM, Daniel Vetter wrote: On Mon, Apr 14, 2014 at 01:24:43PM +0530, Kumar, Shobhit wrote: On 4/14/2014 12:32 PM, Daniel Vetter wrote: On Mon, Apr 14, 2014 at 11:00:34AM +0530, Shobhit Kumar wrote: The parser extracts the config block(#52) and sequence(#53) data and store in private data structures. v2: Address review comments by Jani - adjust code for the structure changes for bdb_mipi_config - add boundry and buffer overflow checks as suggested - use kmemdup instead of kmalloc and memcpy v3: More strict check while parsing VBT - Ensure that at anytime we do not go beyond sequence block while parsing - On unknown element fail the whole parsing v4: Style changes and spell check mostly as suggested by Jani Signed-off-by: Shobhit Kumar shobhit.ku...@intel.com Reviewed-by: Jani Nikula jani.nik...@intel.com I didn't spot Jani's r-b tag in earlier mails, was that done off-list? Yeah, was reviewed along with the other DSI patchset you merged, sorry about that. But then some patches needed internal review while they were being approved for up-streaming to save time. And this one was related to the other panel driver patches which I published today so got stuck with them. Sorry about that. Ok, pulled it in. checkpatch complained a few times about assignments in if conditions, and I tend to agree. Can you please follow up with a cleanup patch? Also it looks like assignment operators could be used. -Daniel Ok. Thanks. I should have run checkpatch. Will fix and push a cleanup patch. Regards Shobhit ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH v3] drm/i915: Add parsing support for new MIPI blocks in VBT
The parser extracts the config block(#52) and sequence(#53) data and store in private data structures. v2: Address review comments by Jani - adjust code for the structure changes for bdb_mipi_config - add boundry and buffer overflow checks as suggested - use kmemdup instead of kmalloc and memcpy v3: More strict check while parsing VBT - Ensure that at anytime we do not go beyond sequence block while parsing - On unknown element fail the whole parsing v4: Style changes and spell check mostly as suggested by Jani Signed-off-by: Shobhit Kumar shobhit.ku...@intel.com Reviewed-by: Jani Nikula jani.nik...@intel.com --- drivers/gpu/drm/i915/i915_drv.h | 6 ++ drivers/gpu/drm/i915/intel_bios.c | 204 +- drivers/gpu/drm/i915/intel_bios.h | 31 ++ 3 files changed, 236 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 85e362f..1b763aa 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1170,6 +1170,12 @@ struct intel_vbt_data { /* MIPI DSI */ struct { u16 panel_id; + struct mipi_config *config; + struct mipi_pps_data *pps; + u8 seq_version; + u32 size; + u8 *data; + u8 *sequence[MIPI_SEQ_MAX]; } dsi; int crt_ddc_pin; diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c index 862ca04..917f5bb 100644 --- a/drivers/gpu/drm/i915/intel_bios.c +++ b/drivers/gpu/drm/i915/intel_bios.c @@ -636,19 +636,213 @@ parse_edp(struct drm_i915_private *dev_priv, struct bdb_header *bdb) } } +static u8 *goto_next_sequence(u8 *data, int *size) +{ + u16 len; + int tmp = *size; + + if (--tmp 0) + return NULL; + + /* goto first element */ + data++; + while (1) { + switch (*data) { + case MIPI_SEQ_ELEM_SEND_PKT: + /* +* skip by this element payload size +* skip elem id, command flag and data type +*/ + if ((tmp = tmp - 5) 0) + return NULL; + + data += 3; + len = *((u16 *)data); + + if ((tmp = tmp - len) 0) + return NULL; + + /* skip by len */ + data = data + 2 + len; + break; + case MIPI_SEQ_ELEM_DELAY: + /* skip by elem id, and delay is 4 bytes */ + if ((tmp = tmp - 5) 0) + return NULL; + + data += 5; + break; + case MIPI_SEQ_ELEM_GPIO: + if ((tmp = tmp - 3) 0) + return NULL; + + data += 3; + break; + default: + DRM_ERROR(Unknown element\n); + return NULL; + } + + /* end of sequence ? */ + if (*data == 0) + break; + } + + /* goto next sequence or end of block byte */ + if (--tmp 0) + return NULL; + + data++; + + /* update amount of data left for the sequence block to be parsed */ + *size = tmp; + return data; +} + static void parse_mipi(struct drm_i915_private *dev_priv, struct bdb_header *bdb) { - struct bdb_mipi *mipi; + struct bdb_mipi_config *start; + struct bdb_mipi_sequence *sequence; + struct mipi_config *config; + struct mipi_pps_data *pps; + u8 *data, *seq_data; + int i, panel_id, seq_size; + u16 block_size; + + /* Initialize this to undefined indicating no generic MIPI support */ + dev_priv-vbt.dsi.panel_id = MIPI_DSI_UNDEFINED_PANEL_ID; + + /* Block #40 is already parsed and panel_fixed_mode is +* stored in dev_priv-lfp_lvds_vbt_mode +* resuse this when needed +*/ - mipi = find_section(bdb, BDB_MIPI_CONFIG); - if (!mipi) { - DRM_DEBUG_KMS(No MIPI BDB found); + /* Parse #52 for panel index used from panel_type already +* parsed +*/ + start = find_section(bdb, BDB_MIPI_CONFIG); + if (!start) { + DRM_DEBUG_KMS(No MIPI config BDB found); return; } - /* XXX: add more info */ + DRM_DEBUG_DRIVER(Found MIPI Config block, panel index = %d\n, + panel_type); + + /* +* get hold of the correct configuration block and pps data as per +* the panel_type as index +*/ + config = start-config[panel_type];