ctrldesc.c 4.27 KB
#include <stdio.h>

int Input = -1;

void usage(void)
{
    fprintf(stderr, "usage: ctrldesc -i register \n");
    exit(1);
}

void ParseArguments(int argc, char **argv)
{
    int c;
    extern char *optarg;
    extern int optind;
    char *ofile = NULL;

    while ((c = getopt(argc, argv, "i:")) != EOF)
	switch (c)
	    {
	    case 'i':
		Input = strtol(optarg, (char **)NULL, 0);
		break;
	    case '?':
	    default:
		usage();
		break;		
	    }    

    if (Input < 0) usage();
}

void ParseMode(void)
{
    /* Yes, I know this is disgusting */

    printf("\n");

    printf("Input mode -> 0x%.8x \n", Input);

    switch ((Input & (0x3 << 0)) >> 0)
	{
	case 0:
	    printf("blank (no data, no sync) \n");
	    break;
	case 1:
	    printf("reserved \n");
	    break;
	case 2:
	    printf("5/5/5/3 (18 bit) \n");
	    break;
	case 3:
	    printf("8/8/8/8 (32 bit) \n");
	    break;
	default:
	    printf("!!!ERROR in size \n");
	    break;
	}

    switch ((Input & (0x3 << 12)) >> 12)
	{
	case 0:
	    printf("pixel advance turned off \n");
	    break;
	case 1:
	    printf("!!!ERROR, unknown setting for bits 12-13 -> 01 \n");
	    break;
	case 2:
	    printf("!!!ERROR, unknown setting for bits 12-13 -> 10 \n");
	    break;
	case 3:
	    printf("pixel advancing turned on \n");	    
	    break;
	default:
	    printf("!!!ERROR in pixel advance setting \n");
	    break;
	}

    switch ((Input & (0x3 << 8)) >> 8)
	{
	case 0:
	    printf("aa & resamp (always fetch extra lines) \n");
	    break;
	case 1:
	    printf("aa & resamp (fetch extra lines if needed) \n");
	    break;
	case 2:
	    printf("resamp only (treat as all fully covered) \n");
	    break;
	case 3:
	    printf("neither (replicate pixels, no interpolate) \n");
	    break;
	default:
	    printf("!!!ERROR in aa mode \n");
	    break;
	}
	    
    switch ((Input & (0x1 << 2)) >> 2)
	{
	case 0:
	    printf("gamma_dither_enable\t-> off \n");
	    break;
	case 1:
	    printf("gamma_dither_enable\t-> on \n");
	    break;
	default:
	    printf("!!!Error in gamma_dither_enable \n");
	    break;
	}

    switch ((Input & (0x1 << 3)) >> 3)
	{
	case 0:
	    printf("gamma_enable\t\t-> off \n");
	    break;
	case 1:
	    printf("gamma_enable\t\t-> on \n");
	    break;
	default:
	    printf("!!!ERROR in gamma_enable \n");
	    break;
	}

    switch ((Input & (0x1 << 4)) >> 4)
	{
	case 0:
	    printf("divot_enable\t\t-> off \n");
	    break;
	case 1:
	    printf("divot_enable\t\t-> on \n");
	    break;
	default:
	    printf("!!!ERROR in divot_enable \n");
	    break;
	}

    switch ((Input & (0x1 << 5)) >> 5)
	{
	case 0:
	    printf("vbus_clock_enable\t-> off \n");
	    break;
	case 1:
	    printf("vbus_clock_enable\t-> on \n");
	    break;
	default:
	    printf("!!!ERROR in vbus_clock_enable \n");
	    break;
	}
    switch ((Input & (0x1 << 6)) >> 6)
	{
	case 0:
	    printf("serrate\t\t\t-> off \n");
	    break;
	case 1:
	    printf("serrate\t\t\t-> on \n");
	    break;
	default:
	    printf("!!!ERROR in serrate \n");
	    break;
	}
    switch ((Input & (0x1 << 7)) >> 7)
	{
	case 0:
	    printf("test_mode\t\t-> off \n");
	    break;
	case 1:
	    printf("test_mode\t\t-> on \n");
	    break;
	default:
	    printf("!!!ERROR in test_mode \n");
	    break;
	}

    switch ((Input & (0x01 << 10)) >> 10)
	{
	case 0:
	    break;
	default:
	    printf("!!!ERROR, unknown setting for bit 10 -> %d \n", 
		   (Input & (0x01 << 10)) >> 10);
	    break;
	}
    
    switch ((Input & (0x1 << 11)) >> 11)
        {
	    case 0:
	      printf("kill_we\t\t\t-> off \n");
	      break;
	    case 1:
	      printf("kill_we\t\t\t-> on \n");
	      break;
	}

    switch ((Input & (0x03 << 14)) >> 14)
	{
	case 0:
	    break;
	default:
	    printf("!!!ERROR, unknown setting for bits 14-15 -> %d \n", 
		   (Input & (0x03 << 14)) >> 14);
	    break;
	}

    switch ((Input & (0x1 << 16)) >> 16)
       {
	case 0:
	    printf("undither\t\t-> off \n");
	    break;
	case 1:
	    printf("undither\t\t-> on \n");
	    break;
       default:
	   printf("!!!ERROR in undither \n");
	   break;
	}    

    switch ((Input & (0x3fff << 17)) >> 17)
	{
	case 0:
	    break;
	default:
	    printf("!!!ERROR, unknown setting for bits 17-31 -> %d \n", 
		   (Input & (0x3fff << 17)) >> 17);
	    break;
	}

    printf("\n");
}

main(int argc, char **argv)
{
    ParseArguments(argc, argv);
    ParseMode();
}