The size of general definition block varies on different platform/machines.
In such case the number of child device is also different.
And it will be better to get the number of child device in general definition
block dynamically.
The number of child device can be calculated by the following formula:
(block_size - block_header_size) /
sizeof( struct child_device_config)
Signed-off-by: Zhao Yakui <[email protected]>
---
src/bios_reader/bios_reader.c | 4 +++-
src/i830_bios.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
Index: xf86-video-intel/src/bios_reader/bios_reader.c
===================================================================
--- xf86-video-intel.orig/src/bios_reader/bios_reader.c 2009-05-25
16:42:08.000000000 +0800
+++ xf86-video-intel/src/bios_reader/bios_reader.c 2009-05-27
14:13:45.000000000 +0800
@@ -170,6 +170,7 @@
struct child_device_config *child;
int i;
char child_id[11];
+ int child_device_num;
block = find_section(BDB_GENERAL_DEFINITIONS);
@@ -188,7 +189,8 @@
printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1],
defs->boot_display[0]);
printf("\tTV data block present: %s\n", YESNO(tv_present));
- for (i = 0; i < 4; i++) {
+ child_device_num = (block->size - sizeof(*defs)) / sizeof(*child);
+ for (i = 0; i < child_device_num; i++) {
child = &defs->devices[i];
if (!child->device_type) {
printf("\tChild device %d not present\n", i);
Index: xf86-video-intel/src/i830_bios.h
===================================================================
--- xf86-video-intel.orig/src/i830_bios.h 2009-05-25 16:54:09.000000000
+0800
+++ xf86-video-intel/src/i830_bios.h 2009-05-26 11:27:32.000000000 +0800
@@ -228,7 +228,7 @@
* TV and LVDS are missing, so be careful when interpreting
* [4] and [5].
*/
- struct child_device_config devices[6];
+ struct child_device_config devices[0];
/* may be another device block here on some platforms */
} __attribute__((packed));
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel