static DFBResult driver_init_device( GraphicsDevice *device, GraphicsDeviceInfo *device_info, void *driver_data, void *device_data ) { ATI128DriverData *adrv = (ATI128DriverData*) driver_data; ATI128DeviceData *adev = (ATI128DeviceData*) device_data; volatile __u8 *mmio = adrv->mmio_base; /* fill device info */ snprintf( device_info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Rage 128" ); snprintf( device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "ATI" ); device_info->caps.flags = CCF_CLIPPING; device_info->caps.accel = ATI128_SUPPORTED_DRAWINGFUNCTIONS | ATI128_SUPPORTED_BLITTINGFUNCTIONS; device_info->caps.drawing = ATI128_SUPPORTED_DRAWINGFLAGS; device_info->caps.blitting = ATI128_SUPPORTED_BLITTINGFLAGS; device_info->limits.surface_byteoffset_alignment = 32 * 4; device_info->limits.surface_pixelpitch_alignment = 32; /* initialize card */ ati128_waitfifo( adrv, adev, 6 ); ati128_out32( mmio, DP_GUI_MASTER_CNTL, GMC_SRC_PITCH_OFFSET_DEFAULT | GMC_DST_PITCH_OFFSET_DEFAULT | GMC_SRC_CLIP_DEFAULT | GMC_DST_CLIP_DEFAULT | GMC_BRUSH_SOLIDCOLOR | GMC_SRC_DSTCOLOR | GMC_BYTE_ORDER_MSB_TO_LSB | GMC_DP_CONVERSION_TEMP_6500 | ROP3_PATCOPY | GMC_DP_SRC_RECT | GMC_3D_FCN_EN_CLR | GMC_DST_CLR_CMP_FCN_CLEAR | GMC_AUX_CLIP_CLEAR | GMC_WRITE_MASK_SET); ati128_out32( mmio, SCALE_3D_CNTL, 0x00000000 ); ati128_out32( mmio, TEX_CNTL, 0x00000000 ); /* reserve 32bit pixel for fake texture at end of framebuffer */ adev->ATI_fake_texture_src = dfb_gfxcard_reserve_memory( device, 4*32 ); return DFB_OK; }
DFBResult savage3d_init_device( CoreGraphicsDevice *device, GraphicsDeviceInfo *device_info, void *driver_data, void *device_data ) { SavageDriverData *sdrv = (SavageDriverData*) driver_data; volatile u8 *mmio = sdrv->mmio_base; unsigned long cobIndex; /* size index */ unsigned long cobSize; /* size in bytes */ unsigned long cobOffset; /* offset in frame buffer */ /* fill device info */ snprintf( device_info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Savage3D Series" ); snprintf( device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "S3" ); device_info->caps.flags = CCF_CLIPPING; device_info->caps.accel = SAVAGE3D_DRAWING_FUNCTIONS | SAVAGE3D_BLITTING_FUNCTIONS; device_info->caps.drawing = SAVAGE3D_DRAWING_FLAGS; device_info->caps.blitting = SAVAGE3D_BLITTING_FLAGS; device_info->limits.surface_byteoffset_alignment = 2048; device_info->limits.surface_pixelpitch_alignment = 32; cobIndex = 7; cobSize = 0x400 << cobIndex; cobOffset = dfb_gfxcard_reserve_memory( device, cobSize ); /* savage_out32( 0x8504, 0x00008000 ); */ /* Disable BCI */ savage_out32( mmio, 0x48C18, savage_in32( mmio, 0x48C18 ) & 0x3FF0); /* Setup BCI command overflow buffer */ savage_out32( mmio, 0x48C14, (cobOffset >> 11) | (cobIndex << 29)); /* Program shadow status update. */ savage_out32( mmio, 0x48C10, 0x78207220); savage_out32( mmio, 0x48C0C, 0); /* Enable BCI and command overflow buffer */ savage_out32( mmio, 0x48C18, savage_in32( mmio, 0x48C18 ) | 0x0C); return DFB_OK; }
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; } /* * Setup LCD buffer. */ 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 JPEG reload buffers in master here, slaves do it in driver_init_driver(). */ sdrv->lcd_virt = dfb_gfxcard_memory_virtual( device, sdev->lcd_offset ); 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) ); /* * Setup JPEG reload buffers. */ sdev->jpeg_size = SH7722GFX_JPEG_RELOAD_SIZE * 2 + SH7722GFX_JPEG_LINEBUFFER_SIZE * 2; sdev->jpeg_offset = dfb_gfxcard_reserve_memory( device, sdev->jpeg_size ); if (sdev->jpeg_offset < 0) { D_ERROR( "SH7722/Driver: Allocating %d bytes for the JPEG reload and line buffers failed!\n", sdev->jpeg_size ); return DFB_FAILURE; } sdev->jpeg_phys = dfb_gfxcard_memory_physical( device, sdev->jpeg_offset ); sdev->jpeg_lb1 = sdev->jpeg_phys + SH7722GFX_JPEG_RELOAD_SIZE * 2; sdev->jpeg_lb2 = sdev->jpeg_lb1 + SH7722GFX_JPEG_LINEBUFFER_SIZE; /* Get virtual addresses for JPEG reload buffers in master here, slaves do it in driver_init_driver(). */ sdrv->jpeg_virt = dfb_gfxcard_memory_virtual( device, sdev->jpeg_offset ); D_INFO( "SH7722/JPEG: Allocated reload and line buffers (%d bytes) at 0x%08lx (%p)\n", sdev->jpeg_size, sdev->jpeg_phys, sdrv->jpeg_virt ); D_ASSERT( ! (sdev->jpeg_size & 0xff) ); D_ASSERT( ! (sdev->jpeg_phys & 0xf) ); /* 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; } /* * Initialize hardware. */ /* Reset the drawing engine. */ sh7722EngineReset( sdrv, sdev ); /* 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 ); /* 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; } /* * 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 ); /* 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 ); /* Initialize BEU lock. */ fusion_skirmish_init( &sdev->beu_lock, "BEU", dfb_core_world(sdrv->core) ); /* Initialize JPEG lock. */ fusion_skirmish_init( &sdev->jpeg_lock, "JPEG", dfb_core_world(sdrv->core) ); return DFB_OK; }
static DFBResult driver_init_driver(CoreGraphicsDevice *device, GraphicsDeviceFuncs *funcs, void *driver_data, void *device_data, CoreDFB *core) { SiSDriverData *drv = (SiSDriverData *)driver_data; FBDev *dfb_fbdev; struct sisfb_info *fbinfo; u32 fbinfo_size; u32 zero = 0; (void)device_data; dfb_fbdev = dfb_system_data(); if (!dfb_fbdev) return DFB_IO; if (ioctl(dfb_fbdev->fd, SISFB_GET_INFO_SIZE, &fbinfo_size) == 0) { fbinfo = D_MALLOC(fbinfo_size); drv->get_info = SISFB_GET_INFO | (fbinfo_size << 16); drv->get_automaximize = SISFB_GET_AUTOMAXIMIZE; drv->set_automaximize = SISFB_SET_AUTOMAXIMIZE; } else { fbinfo = D_MALLOC(sizeof(struct sisfb_info)); drv->get_info = SISFB_GET_INFO_OLD; drv->get_automaximize = SISFB_GET_AUTOMAXIMIZE_OLD; drv->set_automaximize = SISFB_SET_AUTOMAXIMIZE_OLD; } if (fbinfo == NULL) return DFB_NOSYSTEMMEMORY; if (ioctl(dfb_fbdev->fd, drv->get_info, fbinfo) == -1) { D_FREE(fbinfo); return DFB_IO; } check_sisfb_version(drv, fbinfo); D_FREE(fbinfo); if (drv->has_auto_maximize) { if (ioctl(dfb_fbdev->fd, drv->get_automaximize, &drv->auto_maximize)) return DFB_IO; if (drv->auto_maximize) if (ioctl(dfb_fbdev->fd, drv->set_automaximize, &zero)) return DFB_IO; } drv->mmio_base = dfb_gfxcard_map_mmio(device, 0, -1); if (!drv->mmio_base) return DFB_IO; /* base functions */ funcs->EngineSync = sis_engine_sync; funcs->CheckState = sis_check_state; funcs->SetState = sis_set_state; /* drawing functions */ funcs->FillRectangle = sis_fill_rectangle; funcs->DrawRectangle = sis_draw_rectangle; funcs->DrawLine = sis_draw_line; /* blitting functions */ funcs->Blit = sis_blit; funcs->StretchBlit = sis_stretchblit; /* allocate buffer for stretchBlit with colorkey */ drv->buffer_offset = dfb_gfxcard_reserve_memory( device, 1024*768*4 ); return DFB_OK; }
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; }