diff options
author | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2008-02-18 14:32:32 +0800 |
---|---|---|
committer | Jesse Barnes <jbarnes@hobbes.virtuousgeek.org> | 2008-02-22 11:50:01 -0800 |
commit | 866ae8873613a51ca09973f77aa1ea62477b54a1 (patch) | |
tree | 711b22196aed407f23644e2bbfe5972b306f93c0 | |
parent | 945ec2b2516b6508857ee5cd136e59accbc6ebe7 (diff) |
Add DMI info for i830 quirks
Linux kernel has CONFIG_DMIID to export dmi info
through sysfs.
-rw-r--r-- | src/i830_quirks.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/i830_quirks.c b/src/i830_quirks.c index 5e638310..de213c84 100644 --- a/src/i830_quirks.c +++ b/src/i830_quirks.c @@ -32,6 +32,9 @@ #define SUBSYS_ANY (~0) +#define DMIID_DIR "/sys/class/dmi/id/" +#define DMIID_FILE(x) (DMIID_DIR # x) + typedef struct { int chipType; int subsysVendor; @@ -39,6 +42,122 @@ typedef struct { void (*hook)(I830Ptr); } i830_quirk, *i830_quirk_ptr; +enum i830_dmi_data_t { + bios_vendor, + bios_version, + bios_date, + sys_vendor, + product_name, + product_version, + product_serial, + product_uuid, + board_vendor, + board_name, + board_version, + board_serial, + board_asset_tag, + chassis_vendor, + chassis_type, + chassis_version, + chassis_serial, + chassis_asset_tag, + dmi_data_max, +}; + +static char *i830_dmi_data[dmi_data_max]; + +#define I830_DMI_FIELD_FUNC(field) \ +static void i830_dmi_store_##field(void) \ +{\ + FILE *f = NULL;\ + f = fopen(DMIID_FILE(field), "r");\ + if (f == NULL) { i830_dmi_data[field] = NULL; return;}\ + fread(i830_dmi_data[field], 64, 1, f);\ + fclose(f);\ +} + +I830_DMI_FIELD_FUNC(bios_vendor); +I830_DMI_FIELD_FUNC(bios_version); +I830_DMI_FIELD_FUNC(bios_date); +I830_DMI_FIELD_FUNC(sys_vendor); +I830_DMI_FIELD_FUNC(product_name); +I830_DMI_FIELD_FUNC(product_version); +I830_DMI_FIELD_FUNC(product_serial); +I830_DMI_FIELD_FUNC(product_uuid); +I830_DMI_FIELD_FUNC(board_vendor); +I830_DMI_FIELD_FUNC(board_name); +I830_DMI_FIELD_FUNC(board_version); +I830_DMI_FIELD_FUNC(board_serial); +I830_DMI_FIELD_FUNC(board_asset_tag); +I830_DMI_FIELD_FUNC(chassis_vendor); +I830_DMI_FIELD_FUNC(chassis_type); +I830_DMI_FIELD_FUNC(chassis_version); +I830_DMI_FIELD_FUNC(chassis_serial); +I830_DMI_FIELD_FUNC(chassis_asset_tag); + +static int i830_dmi_scan(void) +{ + int i; + + for (i = 0; i < dmi_data_max; i++) { + i830_dmi_data[i] = xcalloc(64, sizeof(char)); + if (!i830_dmi_data[i]) { + int j; + for (j = 0; j < i; j++) + xfree(i830_dmi_data[j]); + return -1; + } + } + + i830_dmi_store_bios_vendor(); + i830_dmi_store_bios_version(); + i830_dmi_store_bios_date(); + i830_dmi_store_sys_vendor(); + i830_dmi_store_product_name(); + i830_dmi_store_product_version(); + i830_dmi_store_product_serial(); + i830_dmi_store_product_uuid(); + i830_dmi_store_board_vendor(); + i830_dmi_store_board_name(); + i830_dmi_store_board_version(); + i830_dmi_store_board_serial(); + i830_dmi_store_board_asset_tag(); + i830_dmi_store_chassis_vendor(); + i830_dmi_store_chassis_type(); + i830_dmi_store_chassis_version(); + i830_dmi_store_chassis_serial(); + i830_dmi_store_chassis_asset_tag(); + + return 0; +} + +#define DMIID_DUMP(field) \ + ErrorF("\t" # field ": %s", i830_dmi_data[field] ?\ + i830_dmi_data[field] : "unknown") + +static void i830_dmi_dump(void) +{ + ErrorF("i830_dmi_dump:\n"); + DMIID_DUMP(bios_vendor); + DMIID_DUMP(bios_version); + DMIID_DUMP(bios_date); + DMIID_DUMP(sys_vendor); + DMIID_DUMP(product_name); + DMIID_DUMP(product_version); + DMIID_DUMP(product_serial); + DMIID_DUMP(product_uuid); + DMIID_DUMP(board_vendor); + DMIID_DUMP(board_name); + DMIID_DUMP(board_version); + DMIID_DUMP(board_serial); + DMIID_DUMP(board_asset_tag); + DMIID_DUMP(chassis_vendor); + DMIID_DUMP(chassis_type); + DMIID_DUMP(chassis_version); + DMIID_DUMP(chassis_serial); + DMIID_DUMP(chassis_asset_tag); +} + static void quirk_pipea_force (I830Ptr pI830) { pI830->quirk_flag |= QUIRK_PIPEA_FORCE; @@ -110,6 +229,12 @@ void i830_fixup_devices(ScrnInfoPtr scrn) { I830Ptr pI830 = I830PTR(scrn); i830_quirk_ptr p = i830_quirk_list; + int i, ret; + + ret = i830_dmi_scan(); + + if (0) + i830_dmi_dump(); while (p && p->chipType != 0) { if (DEVICE_ID(pI830->PciInfo) == p->chipType && @@ -119,4 +244,9 @@ void i830_fixup_devices(ScrnInfoPtr scrn) p->hook(pI830); ++p; } + + if (!ret) { + for (i = 0; i < dmi_data_max; i++) + xfree(i830_dmi_data[i]); + } } |