Set default for "MacModel" option based on hw.product.

ok matthieu@, oga@
This commit is contained in:
kettenis 2009-04-30 11:13:24 +00:00
parent 0538471631
commit 8ac4487426

View File

@ -2521,6 +2521,11 @@ static void RADEONSetupGenericConnectors(ScrnInfoPtr pScrn)
#if defined(__powerpc__)
#ifdef __OpenBSD__
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
/*
* Returns RADEONMacModel or 0 based on lines 'detected as' and 'machine'
* in /proc/cpuinfo (on Linux) */
@ -2610,6 +2615,72 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
#endif /* __linux */
#ifdef __OpenBSD__
char model[32];
int mib[2];
size_t len;
mib[0] = CTL_HW;
mib[1] = HW_PRODUCT;
len = sizeof(model);
if (sysctl(mib, 2, model, &len, NULL, 0) >= 0) {
if (strcmp(model, "PowerBook5,1") == 0 ||
strcmp(model, "PowerBook5,2") == 0 ||
strcmp(model, "PowerBook5,3") == 0 ||
strcmp(model, "PowerBook5,4") == 0 ||
strcmp(model, "PowerBook5,5") == 0) {
ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* single link */
info->ext_tmds_chip = RADEON_SIL_164; /* works on 5,2 */
}
if (strcmp(model, "PowerBook5,6") == 0) {
ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* dual or single link */
}
if (strcmp(model, "PowerBook5,7") ||
strcmp(model, "PowerBook5,8") == 0 ||
strcmp(model, "PowerBook5,9") == 0) {
ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* dual link */
info->ext_tmds_chip = RADEON_SIL_1178; /* guess */
}
if (strcmp(model, "PowerBook3,3") == 0) {
ret = RADEON_MAC_POWERBOOK_VGA; /* vga rather than dvi */
}
if (strcmp(model, "PowerMac10,1") == 0) {
ret = RADEON_MAC_MINI_INTERNAL; /* internal tmds */
}
if (strcmp(model, "PowerMac10,2") == 0) {
ret = RADEON_MAC_MINI_EXTERNAL; /* external tmds */
}
if (strcmp(model, "PowerBook2,1") == 0 ||
strcmp(model, "PowerBook2,2") == 0 ||
strcmp(model, "PowerBook4,1") == 0 ||
strcmp(model, "PowerBook4,2") == 0 ||
strcmp(model, "PowerBook4,3") == 0 ||
strcmp(model, "PowerBook6,3") == 0 ||
strcmp(model, "PowerBook6,5") == 0 ||
strcmp(model, "PowerBook6,7") == 0) {
ret = RADEON_MAC_IBOOK;
}
if (strcmp(model, "PowerBook1,1") == 0 ||
strcmp(model, "PowerBook3,1") == 0 ||
strcmp(model, "PowerBook3,2") == 0 ||
strcmp(model, "PowerBook3,4") == 0 ||
strcmp(model, "PowerBook3,5") == 0) {
ret = RADEON_MAC_POWERBOOK_INTERNAL;
}
if (strcmp(model, "PowerMac12,1") == 0) {
ret = RADEON_MAC_IMAC_G5_ISIGHT;
}
}
#endif /* __OpenBSD__ */
if (ret) {
xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Detected %s.\n",
ret == RADEON_MAC_POWERBOOK_EXTERNAL ? "PowerBook with external DVI" :