Exemple #1
0
static DFBResult
i830_agp_setup( CoreGraphicsDevice *device,
                I830DriverData *idrv,
                I830DeviceData *idev )
{
     idrv->agpgart = open("/dev/agpgart", O_RDWR);
     if (idrv->agpgart == -1)
          return DFB_IO;
     D_FLAGS_SET( idrv->flags, I830RES_GART );


     if (ioctl(idrv->agpgart, AGPIOC_ACQUIRE)) {
          D_PERROR( "I830/AGP: AGPIOC_ACQUIRE failed!\n" );
          return DFB_IO;
     }
     D_FLAGS_SET( idrv->flags, I830RES_GART_ACQ );


     if (!idev->initialized) {
          agp_setup setup;

          setup.agp_mode = 0;
          if (ioctl(idrv->agpgart, AGPIOC_SETUP, &setup)) {
               D_PERROR( "I830/AGP: AGPIOC_SETUP failed!\n" );
               return DFB_IO;
          }
     
          if (ioctl(idrv->agpgart, AGPIOC_INFO, &idev->info)) {
               D_PERROR( "I830/AGP: AGPIOC_INFO failed!\n" );
               return DFB_IO;
          }
     }


     idrv->aper_base = mmap( NULL, idev->info.aper_size * 1024 * 1024, PROT_WRITE,
                             MAP_SHARED, idrv->agpgart, 0 );
     if (idrv->aper_base == MAP_FAILED) {
          D_PERROR( "I830/AGP: mmap() failed!\n" );
          i830_release_resource( idrv, idev );
          return DFB_IO;
     }
     D_FLAGS_SET( idrv->flags, I830RES_MMAP );


     if (!idev->initialized) {
          u32 base;

          /* We'll attempt to bind at fb_base + fb_len + 1 MB,
          to be safe */
          base = dfb_gfxcard_memory_physical(device, 0) - idev->info.aper_base;
          base += dfb_gfxcard_memory_length();
          base += (1024 * 1024);
     
          idev->lring_mem.pg_count = RINGBUFFER_SIZE/4096;
          idev->lring_mem.type = AGP_NORMAL_MEMORY;
          if (ioctl(idrv->agpgart, AGPIOC_ALLOCATE, &idev->lring_mem)) {
               D_PERROR( "I830/AGP: AGPIOC_ALLOCATE failed!\n" );
               i830_release_resource( idrv, idev );
               return DFB_IO;
          }
          D_FLAGS_SET( idrv->flags, I830RES_LRING_ACQ );
     
          idev->lring_bind.key = idev->lring_mem.key;
          idev->lring_bind.pg_start = base/4096;
          if (ioctl(idrv->agpgart, AGPIOC_BIND, &idev->lring_bind)) {
               D_PERROR( "I830/AGP: AGPIOC_BIND failed!\n" );
               i830_release_resource( idrv, idev );
               return DFB_IO;
          }
          D_FLAGS_SET( idrv->flags, I830RES_LRING_BIND );
     
          idev->ovl_mem.pg_count = 1;
          idev->ovl_mem.type = AGP_PHYSICAL_MEMORY;
          if (ioctl(idrv->agpgart, AGPIOC_ALLOCATE, &idev->ovl_mem)) {
               D_PERROR( "I830/AGP: AGPIOC_ALLOCATE failed!\n" );
               i830_release_resource( idrv, idev );
               return DFB_IO;
          }
          D_FLAGS_SET( idrv->flags, I830RES_OVL_ACQ );
     
          idev->ovl_bind.key = idev->ovl_mem.key;
          idev->ovl_bind.pg_start = (base + RINGBUFFER_SIZE)/4096;
          if (ioctl(idrv->agpgart, AGPIOC_BIND, &idev->ovl_bind)) {
               D_PERROR( "I830/AGP: AGPIOC_BIND failed!\n" );
               i830_release_resource( idrv, idev );
               return DFB_IO;
          }
          D_FLAGS_SET( idrv->flags, I830RES_OVL_BIND );
     }


     if (idrv->flags & I830RES_GART_ACQ) {
          ioctl(idrv->agpgart, AGPIOC_RELEASE);
          idrv->flags &= ~I830RES_GART_ACQ;
     }


     idrv->lring_base   = idrv->aper_base + idev->lring_bind.pg_start * 4096;
     idrv->ovl_base     = idrv->aper_base + idev->ovl_bind.pg_start * 4096;
     idrv->pattern_base = idrv->ovl_base + 1024;

     if (!idev->initialized) {
          memset((void *) idrv->lring_base, 0x00, RINGBUFFER_SIZE);
          memset((void *) idrv->ovl_base, 0xff, 1024);
          memset((void *) idrv->pattern_base, 0xff, 4096 - 1024);
 
          idev->lring1 = 0;//i830_readl(idrv->mmio_base, LP_RING);
          idev->lring2 = 0;//i830_readl(idrv->mmio_base, LP_RING + RING_HEAD);
          idev->lring3 = 0;//i830_readl(idrv->mmio_base, LP_RING + RING_START);
          idev->lring4 = 0;//i830_readl(idrv->mmio_base, LP_RING + RING_LEN);
     }

     idev->initialized = true;

     return DFB_OK;
}
Exemple #2
0
static DFBResult
driver_init_device( CoreGraphicsDevice *device,
                    GraphicsDeviceInfo *device_info,
                    void               *driver_data,
                    void               *device_data )
{
     SH7722DriverData *sdrv = driver_data;
     SH7722DeviceData *sdev = device_data;

     D_DEBUG_AT( SH7722_Driver, "%s()\n", __FUNCTION__ );

     /* FIXME: Add a runtime option / config file. */
     sdev->lcd_format = DSPF_RGB16;

     /* Check format of LCD buffer. */
     switch (sdev->lcd_format) {
          case DSPF_RGB16:
          case DSPF_NV16:
               break;

          default:
               return DFB_UNSUPPORTED;
     }

     if (sdev->sh772x == 7723)
          memset( dfb_gfxcard_memory_virtual(device,0), 0, dfb_gfxcard_memory_length() );

     /*
      * Setup LCD buffer.
      */
#ifdef SH772X_FBDEV_SUPPORT
     { 
     	  struct fb_fix_screeninfo fsi;
     	  struct fb_var_screeninfo vsi;
		  int fbdev;

		  if ((fbdev = open("/dev/fb", O_RDONLY)) < 0) {
			   D_ERROR( "SH7722/Driver: Can't open fbdev to get LCDC info!\n" );
			   return DFB_FAILURE;
		  }

		  if (ioctl(fbdev, FBIOGET_FSCREENINFO, &fsi) < 0) {
			   D_ERROR( "SH7722/Driver: FBIOGET_FSCREEINFO failed.\n" );
			   close(fbdev);
			   return DFB_FAILURE;
		  }

		  if (ioctl(fbdev, FBIOGET_VSCREENINFO, &vsi) < 0) {
			   D_ERROR( "SH7722/Driver: FBIOGET_VSCREEINFO failed.\n" );
			   close(fbdev);
			   return DFB_FAILURE;
		  }

		  sdev->lcd_width  = vsi.xres;
		  sdev->lcd_height = vsi.yres;
		  sdev->lcd_pitch  = fsi.line_length;
		  sdev->lcd_size   = fsi.smem_len;
		  sdev->lcd_offset = 0;
		  sdev->lcd_phys   = fsi.smem_start;
#if 0
		  sdrv->lcd_virt   = mmap(NULL, fsi.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED,
				  				  fbdev, 0);
		  if (sdrv->lcd_virt == MAP_FAILED) {
			   D_PERROR( "SH7722/Driver: mapping fbdev failed.\n" );
			   close(fbdev);
			   return DFB_FAILURE;
		  }

          /* Clear LCD buffer. */
          switch (sdev->lcd_format) {
               case DSPF_RGB16:
                    memset( (void*) sdrv->lcd_virt, 0x00, sdev->lcd_height * sdev->lcd_pitch );
                    break;

               case DSPF_NV16:
                    memset( (void*) sdrv->lcd_virt, 0x10, sdev->lcd_height * sdev->lcd_pitch );
                    memset( (void*) sdrv->lcd_virt + sdev->lcd_height * sdev->lcd_pitch, 0x80, sdev->lcd_height * sdev->lcd_pitch );
                    break;

               default:
                    D_BUG( "unsupported format" );
                    return DFB_BUG;
          }
#endif

		  close(fbdev);
     }     
#else
     sdev->lcd_width  = SH7722_LCD_WIDTH;
     sdev->lcd_height = SH7722_LCD_HEIGHT;
     sdev->lcd_pitch  = (DFB_BYTES_PER_LINE( sdev->lcd_format, sdev->lcd_width ) + 0xf) & ~0xf;
     sdev->lcd_size   = DFB_PLANE_MULTIPLY( sdev->lcd_format, sdev->lcd_height ) * sdev->lcd_pitch;
     sdev->lcd_offset = dfb_gfxcard_reserve_memory( device, sdev->lcd_size );

     if (sdev->lcd_offset < 0) {
          D_ERROR( "SH7722/Driver: Allocating %d bytes for the LCD buffer failed!\n", sdev->lcd_size );
          return DFB_FAILURE;
     }

     sdev->lcd_phys = dfb_gfxcard_memory_physical( device, sdev->lcd_offset );

     /* Get virtual addresses for LCD buffer in master here,
        slaves do it in driver_init_driver(). */
     sdrv->lcd_virt = dfb_gfxcard_memory_virtual( device, sdev->lcd_offset );
#endif

     D_INFO( "SH7722/LCD: Allocated %dx%d %s Buffer (%d bytes) at 0x%08lx (%p)\n",
             sdev->lcd_width, sdev->lcd_height, dfb_pixelformat_name(sdev->lcd_format),
             sdev->lcd_size, sdev->lcd_phys, sdrv->lcd_virt );

     D_ASSERT( ! (sdev->lcd_pitch & 0xf) );
     D_ASSERT( ! (sdev->lcd_phys & 0xf) );

     /*
      * Initialize hardware.
      */

     switch (sdev->sh772x) {
          case 7722:
               /* Reset the drawing engine. */
               sh7722EngineReset( sdrv, sdev );

               /* Fill in the device info. */
               snprintf( device_info->name,   DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH,   "SH7722" );
               snprintf( device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "Renesas" );

               /* Set device limitations. */
               device_info->limits.surface_byteoffset_alignment = 16;
               device_info->limits.surface_bytepitch_alignment  = 8;

               /* Set device capabilities. */
               device_info->caps.flags    = CCF_CLIPPING | CCF_RENDEROPTS;
               device_info->caps.accel    = SH7722_SUPPORTED_DRAWINGFUNCTIONS |
                                            SH7722_SUPPORTED_BLITTINGFUNCTIONS;
               device_info->caps.drawing  = SH7722_SUPPORTED_DRAWINGFLAGS;
               device_info->caps.blitting = SH7722_SUPPORTED_BLITTINGFLAGS;

               /* Change font format for acceleration. */
               if (!dfb_config->software_only) {
                    dfb_config->font_format  = DSPF_ARGB;
                    dfb_config->font_premult = false;
               }
               break;

          case 7723:
               /* Reset the drawing engine. */
               sh7723EngineReset( sdrv, sdev );

               /* Fill in the device info. */
               snprintf( device_info->name,   DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH,   "SH7723" );
               snprintf( device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "Renesas" );

               /* Set device limitations. */
               device_info->limits.surface_byteoffset_alignment = 512;
               device_info->limits.surface_bytepitch_alignment  = 64;

               /* Set device capabilities. */
               device_info->caps.flags    = CCF_CLIPPING | CCF_RENDEROPTS;
               device_info->caps.accel    = SH7723_SUPPORTED_DRAWINGFUNCTIONS | \
                                            SH7723_SUPPORTED_BLITTINGFUNCTIONS;
               device_info->caps.drawing  = SH7723_SUPPORTED_DRAWINGFLAGS;
               device_info->caps.blitting = SH7723_SUPPORTED_BLITTINGFLAGS;

               break;

          default:
               D_BUG( "unexpected device" );
               return DFB_BUG;
     }


     /* Wait for idle BEU. */
     while (SH7722_GETREG32( sdrv, BSTAR ) & 1);

     /* Disable all inputs. */
     SH7722_SETREG32( sdrv, BESTR, 0 );

     /* Disable all multi windows. */
     SH7722_SETREG32( sdrv, BMWCR0, SH7722_GETREG32( sdrv, BMWCR0 ) & ~0xf );

#ifndef SH772X_FBDEV_SUPPORT
     /* Clear LCD buffer. */
     switch (sdev->lcd_format) {
          case DSPF_RGB16:
               memset( (void*) sdrv->lcd_virt, 0x00, sdev->lcd_height * sdev->lcd_pitch );
               break;

          case DSPF_NV16:
               memset( (void*) sdrv->lcd_virt, 0x10, sdev->lcd_height * sdev->lcd_pitch );
               memset( (void*) sdrv->lcd_virt + sdev->lcd_height * sdev->lcd_pitch, 0x80, sdev->lcd_height * sdev->lcd_pitch );
               break;

          default:
               D_BUG( "unsupported format" );
               return DFB_BUG;
     }
#endif

     /*
      * TODO: Make LCD Buffer format and primary BEU format runtime configurable.
      */

     /* Set output pixel format of the BEU. */
     switch (sdev->lcd_format) {
          case DSPF_RGB16:
               SH7722_SETREG32( sdrv, BPKFR, BPKFR_RY_RGB | WPCK_RGB16 );
               break;

          case DSPF_NV16:
               SH7722_SETREG32( sdrv, BPKFR, BPKFR_RY_RGB | BPKFR_TE_ENABLED | CHDS_YCBCR422 );
               SH7722_SETREG32( sdrv, BDACR, sdev->lcd_phys + sdev->lcd_height * sdev->lcd_pitch );
               break;

          default:
               D_BUG( "unsupported format" );
               return DFB_BUG;
     }

     SH7722_SETREG32( sdrv, BPROCR, 0x00000000 );

     /* Have BEU render into LCD buffer. */
     SH7722_SETREG32( sdrv, BBLCR1, MT_MEMORY );
     SH7722_SETREG32( sdrv, BDAYR, sdev->lcd_phys & 0xfffffffc );
     SH7722_SETREG32( sdrv, BDMWR, sdev->lcd_pitch & 0x0003fffc );

#ifndef SH772X_FBDEV_SUPPORT
     /* Setup LCD controller to show the buffer. */
     sh7722_lcd_setup( sdrv, sdev->lcd_width, sdev->lcd_height,
                       sdev->lcd_phys, sdev->lcd_pitch, sdev->lcd_format, false );
#endif

     /* Initialize BEU lock. */
     fusion_skirmish_init( &sdev->beu_lock, "BEU", dfb_core_world(sdrv->core) );

     return DFB_OK;
}
Exemple #3
0
static void
ep9xEngineReset(void *drv, void *dev)
{
     memset((void*)dfb_system_video_memory_virtual(0),0,dfb_gfxcard_memory_length());
}
static DFBResult
stmfbdevInitPool (CoreDFB                    *core,
                  CoreSurfacePool            *pool,
                  void                       *pool_data,
                  void                       *pool_local,
                  void                       *system_data,
                  CoreSurfacePoolDescription *ret_desc)
{
  DFBResult              ret;
  STMfbdevPoolData      * const data  = pool_data;
  STMfbdevPoolLocalData * const local = pool_local;
  STMfbdev              * const stmfbdev = dfb_system_data ();
  unsigned int           video_len;

  D_DEBUG_AT (STMfbdev_Surfaces, "%s()\n", __FUNCTION__);

  D_ASSERT (core != NULL);
  D_MAGIC_ASSERT (pool, CoreSurfacePool);
  D_ASSERT (data != NULL);
  D_ASSERT (local != NULL);
  D_ASSERT (ret_desc != NULL);

  (void) local;

  D_MAGIC_ASSERT (stmfbdev, STMfbdev);
  D_MAGIC_ASSERT (stmfbdev->shared, STMfbdevSharedData);

  D_MAGIC_SET (data, STMfbdevPoolData);

  snprintf (ret_desc->name,
            DFB_SURFACE_POOL_DESC_NAME_LENGTH, "STMfb Memory");

  /* the gfxdriver might have reserved video memory - in which case we have to
     make sure that the reserved memory is not seen/used by the surface
     manager */
  video_len = dfb_gfxcard_memory_length ();
  D_INFO ("BDisp/Surfaces: using %ukB of video memory (%d bytes reserved)!\n",
          video_len / 1024, stmfbdev->shared->fix.smem_len - video_len);
  ret = dfb_surfacemanager_create (core, video_len, &data->manager);

  if (ret)
    return ret;

  data->physical = stmfbdev->shared->fix.smem_start;

  ret_desc->caps              = CSPCAPS_PHYSICAL | CSPCAPS_VIRTUAL;
  ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED;
  ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED;
  ret_desc->types             = (0
                                 | CSTF_LAYER
                                 | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT
                                 | CSTF_SHARED | CSTF_EXTERNAL
                                );
  ret_desc->priority          = CSPP_DEFAULT;
  ret_desc->size              = video_len;

  /* other accelerators */
  ret_desc->access[CSAID_ACCEL0] = CSAF_READ | CSAF_WRITE;
  ret_desc->access[CSAID_ACCEL1] = CSAF_READ | CSAF_WRITE;
  ret_desc->access[CSAID_ACCEL2] = CSAF_READ | CSAF_WRITE;
  ret_desc->access[CSAID_ACCEL3] = CSAF_READ | CSAF_WRITE;
  ret_desc->access[CSAID_ACCEL4] = CSAF_READ | CSAF_WRITE;
  ret_desc->access[CSAID_ACCEL5] = CSAF_READ | CSAF_WRITE;

  /* For hardware layers */
  ret_desc->access[CSAID_LAYER0] = CSAF_READ;
  ret_desc->access[CSAID_LAYER1] = CSAF_READ;
  ret_desc->access[CSAID_LAYER2] = CSAF_READ;
  ret_desc->access[CSAID_LAYER3] = CSAF_READ;
  ret_desc->access[CSAID_LAYER4] = CSAF_READ;
  ret_desc->access[CSAID_LAYER5] = CSAF_READ;
  ret_desc->access[CSAID_LAYER6] = CSAF_READ;
  ret_desc->access[CSAID_LAYER7] = CSAF_READ;
  ret_desc->access[CSAID_LAYER8] = CSAF_READ;
  ret_desc->access[CSAID_LAYER9] = CSAF_READ;
  ret_desc->access[CSAID_LAYER10] = CSAF_READ;
  ret_desc->access[CSAID_LAYER11] = CSAF_READ;
  ret_desc->access[CSAID_LAYER12] = CSAF_READ;
  ret_desc->access[CSAID_LAYER13] = CSAF_READ;
  ret_desc->access[CSAID_LAYER14] = CSAF_READ;
  ret_desc->access[CSAID_LAYER15] = CSAF_READ;

  ret = stmfbdevJoinPool (core, pool, pool_data, pool_local, system_data);
  if (ret)
    {
      stmfbdevDestroyPool (pool, pool_data, pool_local);
      return ret;
    }

  return DFB_OK;
}