static int s3cfb_register_framebuffer(struct s3cfb_global *ctrl) { struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); int ret, i, j; for (i = pdata->default_win; i < pdata->nr_wins + pdata->default_win; i++) { j = i % pdata->nr_wins; ret = register_framebuffer(ctrl->fb[j]); if (ret) { dev_err(ctrl->dev, "failed to register " "framebuffer device\n"); return -EINVAL; goto err_register_fb; } #ifndef CONFIG_FRAMEBUFFER_CONSOLE if (j == pdata->default_win) { s3cfb_check_var(&ctrl->fb[j]->var, ctrl->fb[j]); s3cfb_set_par(ctrl->fb[j]); s3cfb_draw_logo(ctrl->fb[j]); } #endif } return 0; err_register_fb: while (--i >= pdata->default_win) { j = i % pdata->nr_wins; unregister_framebuffer(ctrl->fb[j]); } return ret; }
int s3cfb_register_framebuffer(void) { struct s3c_platform_fb *pdata = to_fb_plat(fbdev->dev); int ret, i, j; /* on registering framebuffer, framebuffer of default window is registered at first. */ for (i = pdata->default_win; i < pdata->nr_wins + pdata->default_win; i++) { j = i % pdata->nr_wins; ret = register_framebuffer(fbdev->fb[j]); if (ret) { dev_err(fbdev->dev, "failed to register " "framebuffer device\n"); return -EINVAL; } #ifndef CONFIG_FRAMEBUFFER_CONSOLE if (j == pdata->default_win) { s3cfb_check_var(&fbdev->fb[j]->var, fbdev->fb[j]); s3cfb_set_par(fbdev->fb[j]); s3cfb_draw_logo(fbdev->fb[j]); } #endif } return 0; }
int s3cfb_resume(struct platform_device *pdev) { struct s3c_platform_fb *pdata = to_fb_plat(&pdev->dev); struct fb_info *fb; struct s3cfb_window *win; int i; dev_dbg(ctrl->dev, "wake up from suspend\n"); if (pdata->cfg_gpio) pdata->cfg_gpio(pdev); if (pdata->backlight_on) pdata->backlight_on(pdev); if (pdata->lcd_on) pdata->lcd_on(pdev); if (ctrl->lcd->init_ldi) ctrl->lcd->init_ldi(); clk_enable(ctrl->clock); s3cfb_init_global(); s3cfb_set_clock(ctrl); s3cfb_display_on(ctrl); for (i = 0; i < pdata->nr_wins; i++) { fb = ctrl->fb[i]; win = fb->par; if (win->path == DATA_PATH_FIFO && win->resume_fifo) { if (win->resume_fifo()) dev_info(ctrl->dev, "failed to run the resume for fifo\n"); } else { if (win->enabled) { s3cfb_check_var(&fb->var, fb); s3cfb_set_par(fb); s3cfb_enable_window(win->id); } } } return 0; }
int s3cfb_register_framebuffer(void) { struct s3c_platform_fb *pdata = to_fb_plat(ctrl->dev); int ret, i; for (i = 0; i < pdata->nr_wins; i++) { ret = register_framebuffer(ctrl->fb[i]); if (ret) { dev_err(ctrl->dev, "failed to register framebuffer device\n"); return -EINVAL; } #ifndef CONFIG_FRAMEBUFFER_CONSOLE if (i == pdata->default_win) { s3cfb_check_var(&ctrl->fb[i]->var, ctrl->fb[i]); s3cfb_set_par(ctrl->fb[i]); s3cfb_draw_logo(ctrl->fb[i]); } #endif } return 0; }
int s3cfb_direct_ioctl(int id, unsigned int cmd, unsigned long arg) { struct s3cfb_global *fbdev = get_fimd_global(id); struct fb_info *fb = fbdev->fb[id]; struct fb_var_screeninfo *var = &fb->var; struct fb_fix_screeninfo *fix = &fb->fix; struct s3cfb_window *win = fb->par; struct s3cfb_lcd *lcd = fbdev->lcd; struct s3cfb_user_window user_win; void *argp = (void *)arg; int ret = 0; switch (cmd) { case FBIOGET_FSCREENINFO: ret = memcpy(argp, &fb->fix, sizeof(fb->fix)) ? 0 : -EFAULT; break; case FBIOGET_VSCREENINFO: ret = memcpy(argp, &fb->var, sizeof(fb->var)) ? 0 : -EFAULT; break; case FBIOPUT_VSCREENINFO: ret = s3cfb_check_var((struct fb_var_screeninfo *)argp, fb); if (ret) { dev_err(fbdev->dev, "invalid vscreeninfo\n"); break; } ret = memcpy(&fb->var, (struct fb_var_screeninfo *)argp, sizeof(fb->var)) ? 0 : -EFAULT; if (ret) { dev_err(fbdev->dev, "failed to put new vscreeninfo\n"); break; } fix->line_length = var->xres_virtual * var->bits_per_pixel / 8; fix->smem_len = fix->line_length * var->yres_virtual; s3cfb_set_win_params(fbdev, id); break; case S3CFB_WIN_POSITION: ret = memcpy(&user_win, (struct s3cfb_user_window __user *)arg, sizeof(user_win)) ? 0 : -EFAULT; if (ret) { dev_err(fbdev->dev, "failed to S3CFB_WIN_POSITION\n"); break; } if (user_win.x < 0) user_win.x = 0; if (user_win.y < 0) user_win.y = 0; if (user_win.x + var->xres > lcd->width) win->x = lcd->width - var->xres; else win->x = user_win.x; if (user_win.y + var->yres > lcd->height) win->y = lcd->height - var->yres; else win->y = user_win.y; s3cfb_set_window_position(fbdev, win->id); break; case S3CFB_GET_LCD_WIDTH: ret = memcpy(argp, &lcd->width, sizeof(int)) ? 0 : -EFAULT; if (ret) { dev_err(fbdev->dev, "failed to S3CFB_GET_LCD_WIDTH\n"); break; } break; case S3CFB_GET_LCD_HEIGHT: ret = memcpy(argp, &lcd->height, sizeof(int)) ? 0 : -EFAULT; if (ret) { dev_err(fbdev->dev, "failed to S3CFB_GET_LCD_HEIGHT\n"); break; } break; case S3CFB_SET_WRITEBACK: if ((u32)argp == 1) fbdev->output = OUTPUT_WB_RGB; else fbdev->output = OUTPUT_RGB; s3cfb_set_output(fbdev); break; case S3CFB_SET_WIN_ON: s3cfb_enable_window(fbdev, id); break; case S3CFB_SET_WIN_OFF: s3cfb_disable_window(fbdev, id); break; case S3CFB_SET_WIN_PATH: win->path = (enum s3cfb_data_path_t)argp; break; case S3CFB_SET_WIN_ADDR: fix->smem_start = (unsigned long)argp; s3cfb_set_buffer_address(fbdev, id); break; case S3CFB_SET_WIN_MEM: win->owner = (enum s3cfb_mem_owner_t)argp; break; case S3CFB_SET_VSYNC_INT: if (argp) s3cfb_set_global_interrupt(fbdev, 1); s3cfb_set_vsync_interrupt(fbdev, (int)argp); break; case S3CFB_GET_VSYNC_INT_STATUS: ret = s3cfb_get_vsync_interrupt(fbdev); break; default: ret = s3cfb_ioctl(fb, cmd, arg); break; } return ret; }
int s3cfb_direct_ioctl(int id, unsigned int cmd, unsigned long arg) { struct fb_info *fb = ctrl->fb[id]; struct fb_var_screeninfo *var = &fb->var; struct s3cfb_window *win = fb->par; struct s3cfb_lcd *lcd = ctrl->lcd; struct s3cfb_user_window user_win; void *argp = (void *) arg; int ret = 0; switch (cmd) { case FBIO_ALLOC: win->path = (enum s3cfb_data_path_t) argp; break; case FBIOGET_FSCREENINFO: ret = memcpy(argp, &fb->fix, sizeof(fb->fix)) ? 0 : -EFAULT; break; case FBIOGET_VSCREENINFO: ret = memcpy(argp, &fb->var, sizeof(fb->var)) ? 0 : -EFAULT; break; case FBIOPUT_VSCREENINFO: ret = s3cfb_check_var((struct fb_var_screeninfo *) argp, fb); if (ret) { dev_err(ctrl->dev, "invalid vscreeninfo\n"); break; } ret = memcpy(&fb->var, (struct fb_var_screeninfo *) argp, sizeof(fb->var)) ? 0 : -EFAULT; if (ret) { dev_err(ctrl->dev, "failed to put new vscreeninfo\n"); break; } ret = s3cfb_set_par(fb); break; case S3CFB_WIN_POSITION: ret = memcpy(&user_win, (struct s3cfb_user_window __user *) arg, sizeof(user_win)) ? 0 : -EFAULT; if (ret) { dev_err(ctrl->dev, "failed to S3CFB_WIN_POSITION.\n"); break; } if (user_win.x < 0) user_win.x = 0; if (user_win.y < 0) user_win.y = 0; if (user_win.x + var->xres > lcd->width) win->x = lcd->width - var->xres; else win->x = user_win.x; if (user_win.y + var->yres > lcd->height) win->y = lcd->height - var->yres; else win->y = user_win.y; s3cfb_set_window_position(ctrl, win->id); break; case S3CFB_SET_SUSPEND_FIFO: win->suspend_fifo = argp; break; case S3CFB_SET_RESUME_FIFO: win->resume_fifo = argp; break; /* * for FBIO_WAITFORVSYNC */ default: ret = s3cfb_ioctl(fb, cmd, arg); break; } return ret; }