| 3219 | | void print_ddcmon(const sensors_chip_name *name) |
| 3220 | | { |
| 3221 | | char *label; |
| 3222 | | double a, b, c; |
| 3223 | | int valid, i; |
| 3224 | | |
| 3225 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_MAN_ID, &label, &valid) |
| 3226 | | && !sensors_get_feature(*name, SENSORS_DDCMON_MAN_ID, &a)) { |
| 3227 | | if (valid) { |
| 3228 | | i = (int) a; |
| 3229 | | print_label(label, 24); |
| 3230 | | printf("%c%c%c\n", |
| 3231 | | ((i >> 10) & 0x1f) + 'A' - 1, ((i >> 5) & 0x1f) + 'A' - 1, |
| 3232 | | (i & 0x1f) + 'A' - 1); |
| 3233 | | } |
| 3234 | | } else |
| 3235 | | printf("ERROR: data 1\n"); |
| 3236 | | free(label); |
| 3237 | | |
| 3238 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_PROD_ID, &label, &valid) |
| 3239 | | && !sensors_get_feature(*name, SENSORS_DDCMON_PROD_ID, &a)) { |
| 3240 | | if (valid) { |
| 3241 | | i = (int) a; |
| 3242 | | print_label(label, 24); |
| 3243 | | printf("0x%04X\n", i); |
| 3244 | | } |
| 3245 | | } else |
| 3246 | | printf("ERROR: data 2\n"); |
| 3247 | | free(label); |
| 3248 | | |
| 3249 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_SERIAL, &label,&valid) && |
| 3250 | | !sensors_get_feature(*name, SENSORS_DDCMON_SERIAL, &a)) { |
| 3251 | | if (valid) { |
| 3252 | | print_label(label, 24); |
| 3253 | | printf("%d\n", (int) a); |
| 3254 | | } |
| 3255 | | } else |
| 3256 | | printf("ERROR: data 3\n"); |
| 3257 | | free(label); |
| 3258 | | |
| 3259 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_YEAR, &label, &valid) |
| 3260 | | && !sensors_get_feature(*name, SENSORS_DDCMON_YEAR, &a) |
| 3261 | | && !sensors_get_feature(*name, SENSORS_DDCMON_WEEK, &b)) { |
| 3262 | | if (valid) { |
| 3263 | | print_label(label, 24); |
| 3264 | | printf("%d-W%d\n", (int) a, (int) b); |
| 3265 | | } |
| 3266 | | } else |
| 3267 | | printf("ERROR: data 4\n"); |
| 3268 | | free(label); |
| 3269 | | |
| 3270 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_EDID_VER, &label, &valid) |
| 3271 | | && !sensors_get_feature(*name, SENSORS_DDCMON_EDID_VER, &a) |
| 3272 | | && !sensors_get_feature(*name, SENSORS_DDCMON_EDID_REV, &b)) { |
| 3273 | | if (valid) { |
| 3274 | | print_label(label, 24); |
| 3275 | | printf("%d.%d\n", (int) a, (int) b); |
| 3276 | | } |
| 3277 | | } else |
| 3278 | | printf("ERROR: data 5\n"); |
| 3279 | | free(label); |
| 3280 | | |
| 3281 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_VERSIZE, &label,&valid) && |
| 3282 | | !sensors_get_feature(*name, SENSORS_DDCMON_VERSIZE, &a) && |
| 3283 | | !sensors_get_feature(*name, SENSORS_DDCMON_HORSIZE, &b)) { |
| 3284 | | if (valid) { |
| 3285 | | print_label(label, 24); |
| 3286 | | printf("%dx%d\n", (int) a, (int) b); |
| 3287 | | } |
| 3288 | | } else |
| 3289 | | printf("ERROR: data 6\n"); |
| 3290 | | free(label); |
| 3291 | | |
| 3292 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_GAMMA, &label, &valid) |
| 3293 | | && !sensors_get_feature(*name, SENSORS_DDCMON_GAMMA, &a)) { |
| 3294 | | if (valid) { |
| 3295 | | print_label(label, 24); |
| 3296 | | printf("%.02f\n", a); |
| 3297 | | } |
| 3298 | | } else |
| 3299 | | printf("ERROR: data 7\n"); |
| 3300 | | free(label); |
| 3301 | | |
| 3302 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_DPMS, &label, &valid) |
| 3303 | | && !sensors_get_feature(*name, SENSORS_DDCMON_DPMS, &a)) { |
| 3304 | | if (valid) { |
| 3305 | | i = (int) a; |
| 3306 | | print_label(label, 24); |
| 3307 | | if (i & 0xe0) { |
| 3308 | | printf("%s%s%s%s%s\n", |
| 3309 | | i & 0x20 ? "Active Off" : "", |
| 3310 | | (i & 0x40) && (i & 0x20) ? ", ": "", |
| 3311 | | i & 0x40 ? "Suspend" : "", |
| 3312 | | (i & 0x80) && (i & 0x60) ? ", ": "", |
| 3313 | | i & 0x80 ? "Standby" : ""); |
| 3314 | | } else { |
| 3315 | | printf("None supported\n"); |
| 3316 | | } |
| 3317 | | } |
| 3318 | | } else |
| 3319 | | printf("ERROR: data 8\n"); |
| 3320 | | free(label); |
| 3321 | | |
| 3322 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_TIMINGS, &label,&valid) && |
| 3323 | | !sensors_get_feature(*name, SENSORS_DDCMON_TIMINGS, &a)) { |
| 3324 | | if (valid) { |
| 3325 | | i = (int) a; |
| 3326 | | if (i & 0x03) { /* 720x400 */ |
| 3327 | | print_label(label, 24); |
| 3328 | | printf("720x400 @ %s%s%s Hz\n", |
| 3329 | | i & 0x01 ? "70" : "", |
| 3330 | | (i & 0x02) && (i & 0x01) ? "/" : "", |
| 3331 | | i & 0x02 ? "88" : ""); |
| 3332 | | } |
| 3333 | | if (i & 0x3c) { /* 640x480 */ |
| 3334 | | print_label(label, 24); |
| 3335 | | printf("640x480 @ %s%s%s%s%s%s%s Hz\n", |
| 3336 | | i & 0x04 ? "60" : "", |
| 3337 | | (i & 0x08) && (i & 0x04) ? "/" : "", |
| 3338 | | i & 0x08 ? "67" : "", |
| 3339 | | (i & 0x10) && (i & 0x0c) ? "/" : "", |
| 3340 | | i & 0x10 ? "72" : "", |
| 3341 | | (i & 0x20) && (i & 0x1c) ? "/" : "", |
| 3342 | | i & 0x20 ? "75" : ""); |
| 3343 | | } |
| 3344 | | i >>= 6; |
| 3345 | | if (i & 0x0f) { /* 800x600 */ |
| 3346 | | print_label(label, 24); |
| 3347 | | printf("800x600 @ %s%s%s%s%s%s%s Hz\n", |
| 3348 | | i & 0x01 ? "56" : "", |
| 3349 | | (i & 0x02) && (i & 0x01) ? "/" : "", |
| 3350 | | i & 0x02 ? "60" : "", |
| 3351 | | (i & 0x04) && (i & 0x03) ? "/" : "", |
| 3352 | | i & 0x04 ? "72" : "", |
| 3353 | | (i & 0x08) && (i & 0x07) ? "/" : "", |
| 3354 | | i & 0x08 ? "75" : ""); |
| 3355 | | } |
| 3356 | | if (i & 0x10) { /* 832x624 */ |
| 3357 | | print_label(label, 24); |
| 3358 | | printf("832x624 @ 75 Hz\n"); |
| 3359 | | } |
| 3360 | | i >>= 5; |
| 3361 | | if (i & 0x0f) { /* 1024x768 */ |
| 3362 | | print_label(label, 24); |
| 3363 | | printf("1024x768 @ %s%s%s%s%s%s%s Hz\n", |
| 3364 | | i & 0x01 ? "87i" : "", |
| 3365 | | (i & 0x02) && (i & 0x01) ? "/" : "", |
| 3366 | | i & 0x02 ? "60" : "", |
| 3367 | | (i & 0x04) && (i & 0x03) ? "/" : "", |
| 3368 | | i & 0x04 ? "70" : "", |
| 3369 | | (i & 0x08) && (i & 0x07) ? "/" : "", |
| 3370 | | i & 0x08 ? "75" : ""); |
| 3371 | | } |
| 3372 | | if (i & 0x100) { /* 1152x870 */ |
| 3373 | | print_label(label, 24); |
| 3374 | | printf("1152x870 @ 75 Hz\n"); |
| 3375 | | } |
| 3376 | | if (i & 0x10) { /* 1280x1024 */ |
| 3377 | | print_label(label, 24); |
| 3378 | | printf("1280x1024 @ 75 Hz\n"); |
| 3379 | | } |
| 3380 | | } |
| 3381 | | } else |
| 3382 | | printf("ERROR: data 9\n"); |
| 3383 | | free(label); |
| 3384 | | |
| 3385 | | for(i = 0; i < 8; i++) { |
| 3386 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_TIMING1_HOR + i * 3, &label, &valid) |
| 3387 | | && !sensors_get_feature(*name, SENSORS_DDCMON_TIMING1_HOR + i * 3, &a) |
| 3388 | | && !sensors_get_feature(*name, SENSORS_DDCMON_TIMING1_VER + i * 3, &b) |
| 3389 | | && !sensors_get_feature(*name, SENSORS_DDCMON_TIMING1_REF + i * 3, &c)) { |
| 3390 | | if (valid && ((int) a) != 0) { |
| 3391 | | print_label(label, 24); |
| 3392 | | printf("%dx%d @ %d Hz\n", (int) a, (int) b, (int) c); |
| 3393 | | } |
| 3394 | | } else |
| 3395 | | printf("ERROR: data 10-%d\n", i+1); |
| 3396 | | free(label); |
| 3397 | | } |
| 3398 | | |
| 3399 | | |
| 3400 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_VERSYNCMIN, &label,&valid) && |
| 3401 | | !sensors_get_feature(*name, SENSORS_DDCMON_VERSYNCMIN, &a) && |
| 3402 | | !sensors_get_feature(*name, SENSORS_DDCMON_VERSYNCMAX, &b)) { |
| 3403 | | if (valid && ((int) a) != 0) { |
| 3404 | | print_label(label, 24); |
| 3405 | | printf("%d-%d\n", (int) a, (int) b); |
| 3406 | | } |
| 3407 | | } else |
| 3408 | | printf("ERROR: data 11\n"); |
| 3409 | | free(label); |
| 3410 | | |
| 3411 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_HORSYNCMIN, &label,&valid) && |
| 3412 | | !sensors_get_feature(*name, SENSORS_DDCMON_HORSYNCMIN, &a) && |
| 3413 | | !sensors_get_feature(*name, SENSORS_DDCMON_HORSYNCMAX, &b)) { |
| 3414 | | if (valid && ((int) a) != 0) { |
| 3415 | | print_label(label, 24); |
| 3416 | | printf("%d-%d\n", (int) a, (int) b); |
| 3417 | | } |
| 3418 | | } else |
| 3419 | | printf("ERROR: data 12\n"); |
| 3420 | | free(label); |
| 3421 | | |
| 3422 | | if (!sensors_get_label_and_valid(*name, SENSORS_DDCMON_MAXCLOCK, &label, &valid) |
| 3423 | | && !sensors_get_feature(*name, SENSORS_DDCMON_MAXCLOCK, &a)) { |
| 3424 | | if (valid && ((int) a) != 0) { |
| 3425 | | print_label(label, 24); |
| 3426 | | printf("%d\n", (int) a); |
| 3427 | | } |
| 3428 | | } else |
| 3429 | | printf("ERROR: data 13\n"); |
| 3430 | | free(label); |
| 3431 | | |
| 3432 | | printf("Note that the ddcmon driver is deprecated and will be deleted soon.\n"); |
| 3433 | | printf("Please use the eeprom driver and the ddcmon and/or decode-edid.pl\n" |
| 3434 | | "scripts instead.\n"); |
| 3435 | | } |
| 3436 | | |
| 3437 | | /* |
| 3438 | | * (Khali, 2003-07-17) Almost entierly rewritten. Reindented for clarity, |
| 3439 | | * simplified at some places, added support for EDID EEPROMs (well, |
| 3440 | | * redirection more than support). |
| 3441 | | * (Khali, 2003-08-09) Rewrote Sony Vaio EEPROMs detection, and move it |
| 3442 | | * to the top. This should prevent such EEPROMs from being accidentally |
| 3443 | | * detected as valid memory modules. |
| 3444 | | * (Khali, 2004-02-23) Add support for Shuttle EEPROMs, which contain |
| 3445 | | * MAC ethernet addresses. |
| 3446 | | */ |
| 3447 | | void print_eeprom(const sensors_chip_name *name) |
| 3448 | | { |
| 3449 | | char *label; |
| 3450 | | double a, b, c, d; |
| 3451 | | int valid, i, type; |
| 3452 | | |
| 3453 | | /* handle Sony Vaio EEPROMs first */ |
| 3454 | | if (name->addr == 0x57) { |
| 3455 | | char buffer[33]; |
| 3456 | | |
| 3457 | | /* first make sure it is a Sony Vaio EEPROM */ |
| 3458 | | if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_NAME, &label, &valid) |
| 3459 | | && valid) { |
| 3460 | | for (i = 0; i < 4; i++) |
| 3461 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a)) |
| 3462 | | buffer[i] = (char) a; |
| 3463 | | if (strncmp(buffer, "PCG-", 4) == 0 |
| 3464 | | || strncmp(buffer, "VGN-", 4) == 0) { |
| 3465 | | /* must be a real Sony Vaio EEPROM */ |
| 3466 | | memset(buffer + 4, '\0', 29); |
| 3467 | | for (a = 1; i < 32 && a != 0; i++) /* stop at first zero */ |
| 3468 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_NAME+i, &a) |
| 3469 | | && a != 0) |
| 3470 | | buffer[i] = (char) a; |
| 3471 | | print_label(label, 24); |
| 3472 | | printf("%s\n", buffer); |
| 3473 | | free(label); |
| 3474 | | |
| 3475 | | memset(buffer, '\0', i); |
| 3476 | | if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_VAIO_SERIAL, &label, &valid) |
| 3477 | | && valid) { |
| 3478 | | for (i = 0, a = 1; i < 32 && a != 0; i++) /* stop at first zero */ |
| 3479 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_VAIO_SERIAL+i, &a) |
| 3480 | | && a != 0) |
| 3481 | | buffer[i] = (char) a; |
| 3482 | | print_label(label, 24); |
| 3483 | | printf("%s\n", buffer); |
| 3484 | | } else |
| 3485 | | printf("ERROR: data Vaio 3\n"); |
| 3486 | | free(label); |
| 3487 | | |
| 3488 | | printf("Note that eeprom support will be dropped from " |
| 3489 | | "libsensors soon.\nPlease use the decode-vaio.pl " |
| 3490 | | "script instead.\n"); |
| 3491 | | return; |
| 3492 | | } |
| 3493 | | } else |
| 3494 | | printf("ERROR: data Vaio 2\n"); |
| 3495 | | free(label); |
| 3496 | | } |
| 3497 | | |
| 3498 | | /* then Shuttle EEPROMs */ |
| 3499 | | if (name->addr == 0x53) { |
| 3500 | | unsigned char buffer[6]; |
| 3501 | | |
| 3502 | | /* first make sure it is a Shuttle EEPROM */ |
| 3503 | | if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_SHUTTLE, &label, &valid) |
| 3504 | | && valid) { |
| 3505 | | for (i = 0; i < 3; i++) |
| 3506 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_SHUTTLE+i, &a)) |
| 3507 | | buffer[i] = (unsigned char) a; |
| 3508 | | if (buffer[0] == 0x00 |
| 3509 | | && buffer[1] == 0x30 |
| 3510 | | && buffer[2] == 0x1b) |
| 3511 | | { |
| 3512 | | /* must be a real Shuttle EEPROM */ |
| 3513 | | for (i = 4; i < 6; i++) |
| 3514 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_SHUTTLE+i, &a)) |
| 3515 | | buffer[i] = (unsigned char) a; |
| 3516 | | |
| 3517 | | print_label(label, 24); |
| 3518 | | printf("%02X:%02X:%02X:%02X:%02X:%02X\n", buffer[0], |
| 3519 | | buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); |
| 3520 | | free(label); |
| 3521 | | |
| 3522 | | return; |
| 3523 | | } |
| 3524 | | } else |
| 3525 | | printf("ERROR: data Shuttle\n"); |
| 3526 | | free(label); |
| 3527 | | } |
| 3528 | | |
| 3529 | | if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_TYPE, &label, &valid) |
| 3530 | | && !sensors_get_feature(*name, SENSORS_EEPROM_TYPE, &a)) { |
| 3531 | | if (valid) { |
| 3532 | | type = (int) a; |
| 3533 | | switch (type) { |
| 3534 | | case 1: |
| 3535 | | print_label(label, 24); |
| 3536 | | printf("DRDRAM RIMM\n"); |
| 3537 | | break; |
| 3538 | | case 2: |
| 3539 | | print_label(label, 24); |
| 3540 | | printf("EDO\n"); |
| 3541 | | break; |
| 3542 | | case 4: |
| 3543 | | print_label(label, 24); |
| 3544 | | printf("SDR SDRAM DIMM\n"); |
| 3545 | | break; |
| 3546 | | case 7: |
| 3547 | | print_label(label, 24); |
| 3548 | | printf("DDR SDRAM DIMM\n"); |
| 3549 | | break; |
| 3550 | | case 8: |
| 3551 | | print_label(label, 24); |
| 3552 | | printf("DDR2 SDRAM DIMM\n"); |
| 3553 | | break; |
| 3554 | | case 17: |
| 3555 | | print_label(label, 24); |
| 3556 | | printf("RAMBUS RIMM\n"); |
| 3557 | | break; |
| 3558 | | case 255: /* EDID EEPROM? */ |
| 3559 | | break; |
| 3560 | | default: |
| 3561 | | printf("Unknown EEPROM type (%d)\n", type); |
| 3562 | | free(label); |
| 3563 | | return; |
| 3564 | | } |
| 3565 | | } else { |
| 3566 | | free(label); |
| 3567 | | return; |
| 3568 | | } |
| 3569 | | } else { |
| 3570 | | free(label); |
| 3571 | | printf("Memory type: Unavailable\n"); |
| 3572 | | return; |
| 3573 | | } |
| 3574 | | free(label); |
| 3575 | | |
| 3576 | | if (type == 255) { /* EDID EEPROM */ |
| 3577 | | /* make sure it is an EDID EEPROM */ |
| 3578 | | if (!sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) |
| 3579 | | && !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) |
| 3580 | | && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) |
| 3581 | | && !sensors_get_feature(*name, SENSORS_EEPROM_EDID_HEADER, &d)) { |
| 3582 | | if (((int) a) != 255 || ((int) b) != 255 || ((int) c) != 255 |
| 3583 | | || ((int) d) != 0) |
| 3584 | | printf("Unknown EEPROM type (255).\n"); |
| 3585 | | else if (name->addr == 0x50) |
| 3586 | | /* must be an EDID EEPROM */ |
| 3587 | | printf("Use the ddcmon and/or decode-edid.pl scripts.\n"); |
| 3588 | | } else |
| 3589 | | printf("ERROR: data EDID\n"); |
| 3590 | | return; |
| 3591 | | } |
| 3592 | | |
| 3593 | | /* regular memory chips */ |
| 3594 | | if (!sensors_get_label_and_valid(*name, SENSORS_EEPROM_ROWADDR, &label, &valid) |
| 3595 | | && !sensors_get_feature(*name, SENSORS_EEPROM_ROWADDR, &a) |
| 3596 | | && !sensors_get_feature(*name, SENSORS_EEPROM_COLADDR, &b) |
| 3597 | | && !sensors_get_feature(*name, SENSORS_EEPROM_NUMROWS, &c) |
| 3598 | | && !sensors_get_feature(*name, SENSORS_EEPROM_BANKS, &d) |
| 3599 | | && valid) { |
| 3600 | | int k = 0; /* multiplier, 0 if invalid */ |
| 3601 | | print_label(label, 24); |
| 3602 | | if (type == 17) { /* RAMBUS */ |
| 3603 | | i = (((int) a) & 0x0f) + (((int) a) >> 4) + (((int) c) & 0x07) - 13; |
| 3604 | | k = 1; |
| 3605 | | } else if (type == 1) { /* DRDRAM */ |
| 3606 | | i = (((int) b) & 0x0f) + (((int) b) >> 4) + (((int) c) & 0x07) - 13; |
| 3607 | | k = 1; |
| 3608 | | } else if (type == 8) { /* DDR2 */ |
| 3609 | | i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17; |
| 3610 | | k = ((((int) c) & 0x7) + 1) * ((int) d); |
| 3611 | | } else { /* SDRAM */ |
| 3612 | | i = (((int) a) & 0x0f) + (((int) b) & 0x0f) - 17; |
| 3613 | | if (((int) c) <= 8 && ((int) d) <= 8) |
| 3614 | | k = ((int) c) * ((int) d); |
| 3615 | | } |
| 3616 | | if(i > 0 && i <= 12 && k > 0) |
| 3617 | | printf("%d\n", (1 << i) * k); |
| 3618 | | else |
| 3619 | | printf("invalid (%d %d %d %d)\n", |
| 3620 | | (int) a, (int) b, (int) c, (int) d); |
| 3621 | | } else |
| 3622 | | printf("ERROR: data 2\n"); |
| 3623 | | free(label); |
| 3624 | | |
| 3625 | | printf("Note that eeprom support will be dropped from " |
| 3626 | | "libsensors soon.\nPlease use the decode-dimms.pl " |
| 3627 | | "script instead.\n"); |
| 3628 | | } |
| 3629 | | |