⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmp.c

📁 epson 13506 driver code
💻 C
📖 第 1 页 / 共 4 页
字号:
          "\n    4    | LCD & TV     ---"
          "\n    5    | LCD          CRT"
          "\n    6    | LCD          TV");
}

/*-------------------------------------------------------------------------*/

void ShowActiveDisplaySurface(void)
{
   /*
   ** "Display Surface: 0=LCD, 1=CRT"
   */
   printf("Display Surface: 0=");

   switch (CalcDisplaySurfaceCombination())
      {
      case SURFACE_LCD0_CRTTV1:
         printf("LCD, 1=CRT/TV\n");
         break;

      case SURFACE_LCD0:
         printf("LCD\n");
         break;

      case SURFACE_CRTTV0:
         printf("CRT/TV\n");
         break;

      case SURFACE_LCDCRTTV0:
         printf("LCD and CRT/TV\n");
         break;

      default:
         printf("NONE\n");
         break;
      }
}

/*-----------------------------------------------------------------------*/

int GetSurfaceDisplayMode(int surface)
{
   unsigned regDisplayMode;

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   switch (CalcDisplaySurfaceCombination())
      {
      case SURFACE_NONE:
         return 0;
         break;

      case SURFACE_LCD0:
         if (surface == 0)
            return LCD;
         break;

      case SURFACE_CRTTV0:
         if (surface == 0)
            return regDisplayMode & (CRT | TV);
         break;

      case SURFACE_LCD0_CRTTV1:
         if (surface == 0)
            return LCD;
         else if (surface == 1)
            return regDisplayMode & (CRT | TV);
         break;

      case SURFACE_LCDCRTTV0:
         if (surface == 0)
            return regDisplayMode & (LCD | CRT | TV);
         break;
      }

   return 0;
}

/*-----------------------------------------------------------------------*/

int CalcDisplaySurfaceCombination(void)
{
   unsigned regDisplayMode;

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   if ((regDisplayMode & LCD) && !(regDisplayMode & (CRT | TV)))
      return SURFACE_LCD0;
   else if (!(regDisplayMode & LCD) && (regDisplayMode & (CRT | TV)))
      return SURFACE_CRTTV0;
   else if ((regDisplayMode & LCD) && (regDisplayMode & (CRT | TV)))
      {
      if (CommonMemoryBlockForAllDisplays)
         return SURFACE_LCDCRTTV0;
      else if ((SurfaceDisplayMode[0] & LCD) && (SurfaceDisplayMode[1] & (CRT | TV)))
         return SURFACE_LCD0_CRTTV1;
      else
         return SURFACE_LCDCRTTV0;
      }

   return SURFACE_NONE;
}

/*-----------------------------------------------------------------------*/

int GetActiveSurfaceNumber(void)
{
   int CurrentDisplayMode;

   CurrentDisplayMode = seGetSurfaceDisplayMode();

   switch (CalcDisplaySurfaceCombination())
      {
      case SURFACE_NONE:
         break;

      case SURFACE_LCD0:
         if (CurrentDisplayMode & LCD)
            return 0;
         break;

      case SURFACE_CRTTV0:
         if (CurrentDisplayMode & (CRT | TV))
            return 0;
         break;

      case SURFACE_LCD0_CRTTV1:
         if (CurrentDisplayMode & LCD)
            return 0;
         else if (CurrentDisplayMode & (CRT | TV))
            return 1;
         break;

      case SURFACE_LCDCRTTV0:
         if (CurrentDisplayMode & (LCD | CRT | TV))
            return 0;
         break;
      }

   return -1;
}

/*-----------------------------------------------------------------------*/

int GetSurfaceNumber(unsigned DisplayMode)
{
   switch (CalcDisplaySurfaceCombination())
      {
      case SURFACE_NONE:
         break;

      case SURFACE_LCD0:
         if (DisplayMode & LCD)
            return 0;
         break;

      case SURFACE_CRTTV0:
         if (DisplayMode & (CRT | TV))
            return 0;
         break;

      case SURFACE_LCD0_CRTTV1:
         if (DisplayMode & LCD)
            return 0;
         else if (DisplayMode & (CRT | TV))
            return 1;
         break;

      case SURFACE_LCDCRTTV0:
         if (DisplayMode & LCD)
            return 0;
         else if (DisplayMode & (CRT | TV))
            return 1;
         break;
      }

   return -1;
}

/*-----------------------------------------------------------------------*/

void SetActiveSurfaceNumber(int surface)
{
   unsigned regDisplayMode;

   ActiveSurfaceNumber = surface;

   regDisplayMode = seReadRegByte(REG_DISPLAY_MODE);

   switch (CalcDisplaySurfaceCombination())
      {
      case SURFACE_NONE:
         break;

      case SURFACE_LCD0:
         if (surface == 0)
            seSetLcdAsActiveSurface();
         break;

      case SURFACE_CRTTV0:
         if (surface == 0)
            {
            if (regDisplayMode & TV)
               seSetTvAsActiveSurface();
            else
               seSetCrtAsActiveSurface();
            }
         break;

      case SURFACE_LCD0_CRTTV1:
         if (surface == 0)
            seSetLcdAsActiveSurface();
         else if (surface == 1)
            {
            if (regDisplayMode & TV)
               seSetTvAsActiveSurface();
            else
               seSetCrtAsActiveSurface();
            }
         break;

      case SURFACE_LCDCRTTV0:
         if (surface == 0)
            seSetLcdAsActiveSurface();
         else if (surface == 1)
            {
            if (regDisplayMode & TV)
               seSetTvAsActiveSurface();
            else
               seSetCrtAsActiveSurface();
            }
         break;
      }
}

/*-----------------------------------------------------------------------*/

void DisplayLcdOrientation(void)
   {
   printf("LCD Orientation: ");

   switch (LcdOrientation)
      {
      case LANDSCAPE:
      default:
         printf("LANDSCAPE");
         break;

      case ROTATE90:
         printf("SWIVELVIEW 90 DEGREES");
         break;

      case ROTATE180:
         printf("SWIVELVIEW 180 DEGREES");
         break;

      case ROTATE270:
         printf("SWIVELVIEW 270 DEGREES");
         break;
      }

   printf("\n");
   }

/*-------------------------------------------------------------------------*/

void ExitBadConfiguration(unsigned DisplayMode)
{
   char str[10];

   if (DisplayMode & LCD)
      strcpy(str, "LCD");
   else if (DisplayMode & CRT)
      strcpy(str, "CRT");
   else if (DisplayMode & TV)
      strcpy(str, "TV");
   else
      return;
      
   printf("\nERROR: Program not configured for %s.", str);
   printf("\n       Run 13506CFG and configure for %s.\n", str);

   seLcdDisplayEnable(FALSE);
   seCrtDisplayEnable(FALSE);
   seTvDisplayEnable(FALSE);
   exit(1);
}

/*-------------------------------------------------------------------------*/

void CheckLcdOrientationForLandscape(void)
{
   if (seGetLcdOrientation() != LANDSCAPE)
      {
      printf("\nWARNING: LCD must be in landscape mode.\n");
      LcdOrientation = LANDSCAPE;
      seWriteRegByte(REG_DISPLAY_MODE, seReadRegByte(REG_DISPLAY_MODE) & ~0x40);
      seWriteRegByte(REG_LCD_DISPLAY_MODE, seReadRegByte(REG_LCD_DISPLAY_MODE) & ~0x10);
      }
}

/*-------------------------------------------------------------------------*/

void CheckBmpCount(int count)
{
   if (BmpCount > count)
      {
      printf("\nWARNING: Only %d BMP image", count);

      if (count > 1)
         printf("s");

      printf(" can be used in selected mode.\n");
      BmpCount = count;
      }
}

/*-------------------------------------------------------------------------*/

int main(int argc, char *argv[])
{
   int i, surface;
   int iDisplay = -1;
   unsigned regLcdDisplayMode, regDisplayMode;
   unsigned LcdBitsPerPixel = 0;
   unsigned CrtTvBitsPerPixel = 0;
   unsigned width1, height1;
   unsigned width2, height2;
   unsigned val;
   unsigned DisplayMode = 0;

   char *szCrtTvInLandscapeMode = "\nWARNING: CRT/TV only available in LANDSCAPE mode.\n";
   char *szForcingLandscapeMode = "\nWARNING: LCD and CRT/TV use same surface; forcing LCD to LANDSCAPE mode.\n";

   /* Initialize some global variables */
   gbInitRegisters = TRUE;
   gbImgCompress = FALSE;
   NumberOfSurfaces = 0;
   ActiveSurfaceNumber = 0;

   CommonMemoryBlockForAllDisplays = FALSE;

   LcdOrientation = LANDSCAPE;
   BmpCount = 0;
   
   /* Initialize all the globals that are assocaited with surfaces */
   for (surface = 0; surface < MAX_DISP_SURFACE; surface++)
   {
      nBitsPerPixel[surface] = 0;
      Orientation[surface] = LANDSCAPE;
      SurfaceDisplayMode[surface] = 0;   /* indicates which display is attached to which surface */
      filename[surface] = NULL;
   }
   
   VerboseMode = FALSE;
   
   if ( (argc>8) || (argc<2) )
   {
      PrintUsage();
      return FAIL;
   }
   
   /*
   ** Parse the command line.
   */
   for (i = 1; i < argc; ++i)
   {
      strlwr(argv[i]);

      if ( !strcmpi(argv[i],"/?") || !strcmpi(argv[i],"-?") )
      {
         PrintUsage();
         return SUCCEED;
      }
      else if (!strncmp(argv[i], "ds=", 3))
      {
         if (argv[i][3] == '?')
         {
            DisplaySurfaceHelp();
            exit(0);
         }
         
         iDisplay = atoi(&argv[i][3]);
         
         if ((iDisplay < 0) || (iDisplay > 8))
         {
            iDisplay = -1;
            printf("\nERROR: Invalid display surface number.\n");
         }
      }
      else if ( !strcmpi(argv[i],"/r90") || !strcmpi(argv[i],"-r90") )
      {
         LcdOrientation |= ROTATE90;
      }
      else if ( !strcmpi(argv[i],"/r180") || !strcmpi(argv[i],"-r180") )
      {
         LcdOrientation |= ROTATE180;
      }
      else if ( !strcmpi(argv[i],"/r270") || !strcmpi(argv[i],"-r270") )
      {
         LcdOrientation |= ROTATE270;
      }
      else if ( !strcmpi(argv[i],"/v") || !strcmpi(argv[i],"-v") )
      {
         VerboseMode = TRUE;
      }
      else if (!strcmpi(argv[i], "/noinit") || !strcmpi(argv[i], "-noinit"))
      {
         gbInitRegisters = FALSE;
      }
      else
      {
         if ( BmpCount >= 2 )
         {
            PrintUsage();  /* cannot take more than two .BMP files */
            return FAIL;
         }

         filename[BmpCount] = argv[i];
         ++BmpCount;
      }
   }
   
   if ( BmpCount == 0 )
   {
      PrintUsage();  /* no bmp file specified in cmdline argument */
      return FAIL;
   }
   

   switch (seRegisterDevice(&HalInfo))
   {
   case ERR_OK:
      break;
      
#ifdef INTEL_W32
   case ERR_PCI_DRIVER_NOT_FOUND:
      printf("ERROR: PCI driver not found.\n");
      return 1;
      
   case ERR_PCI_BRIDGE_ADAPTER_NOT_FOUND:
      printf("ERROR: PCI bridge adapter not found.\n");
      return 1;
#endif

   case ERR_UNKNOWN_DEVICE:
      printf("ERROR: Could not detect S1D13506.\n");
      return 1;
      
   default:
      printf("ERROR: Could not map memory from evaluation board to host platform.\n");
      return 1;
   }
   

   if (gbInitRegisters)
      {
      switch (iDisplay)
         {
         case 0:
            DisplayMode = LCD;
            break;

         case 1:
            DisplayMode = CRT;
            break;

         case 2:
            DisplayMode = TV;
            break;

         case 3:
         case 5:
            DisplayMode = LCD | CRT;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -