diff options
-rw-r--r-- | drivers/video/fbdev/Kconfig | 33 | ||||
-rw-r--r-- | drivers/video/fbdev/Makefile | 3 | ||||
-rw-r--r-- | drivers/video/fbdev/auo_k1900fb.c | 204 | ||||
-rw-r--r-- | drivers/video/fbdev/auo_k1901fb.c | 257 | ||||
-rw-r--r-- | drivers/video/fbdev/auo_k190x.c | 1190 | ||||
-rw-r--r-- | drivers/video/fbdev/auo_k190x.h | 129 | ||||
-rw-r--r-- | include/video/auo_k190xfb.h | 107 |
7 files changed, 0 insertions, 1923 deletions
diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 434e95b9320e..381a9c588792 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2253,39 +2253,6 @@ config FB_BROADSHEET and could also have been called by other names when coupled with a bridge adapter. -config FB_AUO_K190X - tristate "AUO-K190X EPD controller support" - depends on FB - select FB_SYS_FILLRECT - select FB_SYS_COPYAREA - select FB_SYS_IMAGEBLIT - select FB_SYS_FOPS - select FB_DEFERRED_IO - help - Provides support for epaper controllers from the K190X series - of AUO. These controllers can be used to drive epaper displays - from Sipix. - - This option enables the common support, shared by the individual - controller drivers. You will also have to enable the driver - for the controller type used in your device. - -config FB_AUO_K1900 - tristate "AUO-K1900 EPD controller support" - depends on FB && FB_AUO_K190X - help - This driver implements support for the AUO K1900 epd-controller. - This controller can drive Sipix epaper displays but can only do - serial updates, reducing the number of possible frames per second. - -config FB_AUO_K1901 - tristate "AUO-K1901 EPD controller support" - depends on FB && FB_AUO_K190X - help - This driver implements support for the AUO K1901 epd-controller. - This controller can drive Sipix epaper displays and supports - concurrent updates, making higher frames per second possible. - config FB_JZ4740 tristate "JZ4740 LCD framebuffer support" depends on FB && MACH_JZ4740 diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile index 55282a21b500..317a6fd0e54e 100644 --- a/drivers/video/fbdev/Makefile +++ b/drivers/video/fbdev/Makefile @@ -100,9 +100,6 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o obj-$(CONFIG_FB_MAXINE) += maxinefb.o obj-$(CONFIG_FB_METRONOME) += metronomefb.o obj-$(CONFIG_FB_BROADSHEET) += broadsheetfb.o -obj-$(CONFIG_FB_AUO_K190X) += auo_k190x.o -obj-$(CONFIG_FB_AUO_K1900) += auo_k1900fb.o -obj-$(CONFIG_FB_AUO_K1901) += auo_k1901fb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o obj-$(CONFIG_FB_SH7760) += sh7760fb.o obj-$(CONFIG_FB_IMX) += imxfb.o diff --git a/drivers/video/fbdev/auo_k1900fb.c b/drivers/video/fbdev/auo_k1900fb.c deleted file mode 100644 index 7637c60eae3d..000000000000 --- a/drivers/video/fbdev/auo_k1900fb.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * auok190xfb.c -- FB driver for AUO-K1900 controllers - * - * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de> - * - * based on broadsheetfb.c - * - * Copyright (C) 2008, Jaya Kumar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven. - * - * This driver is written to be used with the AUO-K1900 display controller. - * - * It is intended to be architecture independent. A board specific driver - * must be used to perform all the physical IO interactions. - * - * The controller supports different update modes: - * mode0+1 16 step gray (4bit) - * mode2 4 step gray (2bit) - FIXME: add strange refresh - * mode3 2 step gray (1bit) - FIXME: add strange refresh - * mode4 handwriting mode (strange behaviour) - * mode5 automatic selection of update mode - */ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/string.h> -#include <linux/mm.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/fb.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/list.h> -#include <linux/firmware.h> -#include <linux/gpio.h> -#include <linux/pm_runtime.h> - -#include <video/auo_k190xfb.h> - -#include "auo_k190x.h" - -/* - * AUO-K1900 specific commands - */ - -#define AUOK1900_CMD_PARTIALDISP 0x1001 -#define AUOK1900_CMD_ROTATION 0x1006 -#define AUOK1900_CMD_LUT_STOP 0x1009 - -#define AUOK1900_INIT_TEMP_AVERAGE (1 << 13) -#define AUOK1900_INIT_ROTATE(_x) ((_x & 0x3) << 10) -#define AUOK1900_INIT_RESOLUTION(_res) ((_res & 0x7) << 2) - -static void auok1900_init(struct auok190xfb_par *par) -{ - struct device *dev = par->info->device; - struct auok190x_board *board = par->board; - u16 init_param = 0; - - pm_runtime_get_sync(dev); - - init_param |= AUOK1900_INIT_TEMP_AVERAGE; - init_param |= AUOK1900_INIT_ROTATE(par->rotation); - init_param |= AUOK190X_INIT_INVERSE_WHITE; - init_param |= AUOK190X_INIT_FORMAT0; - init_param |= AUOK1900_INIT_RESOLUTION(par->resolution); - init_param |= AUOK190X_INIT_SHIFT_RIGHT; - - auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param); - - /* let the controller finish */ - board->wait_for_rdy(par); - - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); -} - -static void auok1900_update_region(struct auok190xfb_par *par, int mode, - u16 y1, u16 y2) -{ - struct device *dev = par->info->device; - unsigned char *buf = (unsigned char *)par->info->screen_base; - int xres = par->info->var.xres; - int line_length = par->info->fix.line_length; - u16 args[4]; - - pm_runtime_get_sync(dev); - - mutex_lock(&(par->io_lock)); - - /* y1 and y2 must be a multiple of 2 so drop the lowest bit */ - y1 &= 0xfffe; - y2 &= 0xfffe; - - dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n", - 1, y1+1, xres, y2-y1, mode); - - /* to FIX handle different partial update modes */ - args[0] = mode | 1; - args[1] = y1 + 1; - args[2] = xres; - args[3] = y2 - y1; - buf += y1 * line_length; - auok190x_send_cmdargs_pixels(par, AUOK1900_CMD_PARTIALDISP, 4, args, - ((y2 - y1) * line_length)/2, (u16 *) buf); - auok190x_send_command(par, AUOK190X_CMD_DATA_STOP); - - par->update_cnt++; - - mutex_unlock(&(par->io_lock)); - - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); -} - -static void auok1900fb_dpy_update_pages(struct auok190xfb_par *par, - u16 y1, u16 y2) -{ - int mode; - - if (par->update_mode < 0) { - mode = AUOK190X_UPDATE_MODE(1); - par->last_mode = -1; - } else { - mode = AUOK190X_UPDATE_MODE(par->update_mode); - par->last_mode = par->update_mode; - } - - if (par->flash) - mode |= AUOK190X_UPDATE_NONFLASH; - - auok1900_update_region(par, mode, y1, y2); -} - -static void auok1900fb_dpy_update(struct auok190xfb_par *par) -{ - int mode; - - if (par->update_mode < 0) { - mode = AUOK190X_UPDATE_MODE(0); - par->last_mode = -1; - } else { - mode = AUOK190X_UPDATE_MODE(par->update_mode); - par->last_mode = par->update_mode; - } - - if (par->flash) - mode |= AUOK190X_UPDATE_NONFLASH; - - auok1900_update_region(par, mode, 0, par->info->var.yres); - par->update_cnt = 0; -} - -static bool auok1900fb_need_refresh(struct auok190xfb_par *par) -{ - return (par->update_cnt > 10); -} - -static int auok1900fb_probe(struct platform_device *pdev) -{ - struct auok190x_init_data init; - struct auok190x_board *board; - - /* pick up board specific routines */ - board = pdev->dev.platform_data; - if (!board) - return -EINVAL; - - /* fill temporary init struct for common init */ - init.id = "auo_k1900fb"; - init.board = board; - init.update_partial = auok1900fb_dpy_update_pages; - init.update_all = auok1900fb_dpy_update; - init.need_refresh = auok1900fb_need_refresh; - init.init = auok1900_init; - - return auok190x_common_probe(pdev, &init); -} - -static int auok1900fb_remove(struct platform_device *pdev) -{ - return auok190x_common_remove(pdev); -} - -static struct platform_driver auok1900fb_driver = { - .probe = auok1900fb_probe, - .remove = auok1900fb_remove, - .driver = { - .name = "auo_k1900fb", - .pm = &auok190x_pm, - }, -}; -module_platform_driver(auok1900fb_driver); - -MODULE_DESCRIPTION("framebuffer driver for the AUO-K1900 EPD controller"); -MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/auo_k1901fb.c b/drivers/video/fbdev/auo_k1901fb.c deleted file mode 100644 index 681fe61957b6..000000000000 --- a/drivers/video/fbdev/auo_k1901fb.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * auok190xfb.c -- FB driver for AUO-K1901 controllers - * - * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de> - * - * based on broadsheetfb.c - * - * Copyright (C) 2008, Jaya Kumar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven. - * - * This driver is written to be used with the AUO-K1901 display controller. - * - * It is intended to be architecture independent. A board specific driver - * must be used to perform all the physical IO interactions. - * - * The controller supports different update modes: - * mode0+1 16 step gray (4bit) - * mode2+3 4 step gray (2bit) - * mode4+5 2 step gray (1bit) - * - mode4 is described as "without LUT" - * mode7 automatic selection of update mode - * - * The most interesting difference to the K1900 is the ability to do screen - * updates in an asynchronous fashion. Where the K1900 needs to wait for the - * current update to complete, the K1901 can process later updates already. - */ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/string.h> -#include <linux/mm.h> -#include <linux/slab.h> -#include <linux/delay.h> -#include <linux/interrupt.h> -#include <linux/fb.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/list.h> -#include <linux/firmware.h> -#include <linux/gpio.h> -#include <linux/pm_runtime.h> - -#include <video/auo_k190xfb.h> - -#include "auo_k190x.h" - -/* - * AUO-K1901 specific commands - */ - -#define AUOK1901_CMD_LUT_INTERFACE 0x0005 -#define AUOK1901_CMD_DMA_START 0x1001 -#define AUOK1901_CMD_CURSOR_START 0x1007 -#define AUOK1901_CMD_CURSOR_STOP AUOK190X_CMD_DATA_STOP -#define AUOK1901_CMD_DDMA_START 0x1009 - -#define AUOK1901_INIT_GATE_PULSE_LOW (0 << 14) -#define AUOK1901_INIT_GATE_PULSE_HIGH (1 << 14) -#define AUOK1901_INIT_SINGLE_GATE (0 << 13) -#define AUOK1901_INIT_DOUBLE_GATE (1 << 13) - -/* Bits to pixels - * Mode 15-12 11-8 7-4 3-0 - * format2 2 T 1 T - * format3 1 T 2 T - * format4 T 2 T 1 - * format5 T 1 T 2 - * - * halftone modes: - * format6 2 2 1 1 - * format7 1 1 2 2 - */ -#define AUOK1901_INIT_FORMAT2 (1 << 7) -#define AUOK1901_INIT_FORMAT3 ((1 << 7) | (1 << 6)) -#define AUOK1901_INIT_FORMAT4 (1 << 8) -#define AUOK1901_INIT_FORMAT5 ((1 << 8) | (1 << 6)) -#define AUOK1901_INIT_FORMAT6 ((1 << 8) | (1 << 7)) -#define AUOK1901_INIT_FORMAT7 ((1 << 8) | (1 << 7) | (1 << 6)) - -/* res[4] to bit 10 - * res[3-0] to bits 5-2 - */ -#define AUOK1901_INIT_RESOLUTION(_res) (((_res & (1 << 4)) << 6) \ - | ((_res & 0xf) << 2)) - -/* - * portrait / landscape orientation in AUOK1901_CMD_DMA_START - */ -#define AUOK1901_DMA_ROTATE90(_rot) ((_rot & 1) << 13) - -/* - * equivalent to 1 << 11, needs the ~ to have same rotation like K1900 - */ -#define AUOK1901_DDMA_ROTATE180(_rot) ((~_rot & 2) << 10) - -static void auok1901_init(struct auok190xfb_par *par) -{ - struct device *dev = par->info->device; - struct auok190x_board *board = par->board; - u16 init_param = 0; - - pm_runtime_get_sync(dev); - - init_param |= AUOK190X_INIT_INVERSE_WHITE; - init_param |= AUOK190X_INIT_FORMAT0; - init_param |= AUOK1901_INIT_RESOLUTION(par->resolution); - init_param |= AUOK190X_INIT_SHIFT_LEFT; - - auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param); - - /* let the controller finish */ - board->wait_for_rdy(par); - - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); -} - -static void auok1901_update_region(struct auok190xfb_par *par, int mode, - u16 y1, u16 y2) -{ - struct device *dev = par->info->device; - unsigned char *buf = (unsigned char *)par->info->screen_base; - int xres = par->info->var.xres; - int line_length = par->info->fix.line_length; - u16 args[5]; - - pm_runtime_get_sync(dev); - - mutex_lock(&(par->io_lock)); - - /* y1 and y2 must be a multiple of 2 so drop the lowest bit */ - y1 &= 0xfffe; - y2 &= 0xfffe; - - dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n", - 1, y1+1, xres, y2-y1, mode); - - /* K1901: first transfer the region data */ - args[0] = AUOK1901_DMA_ROTATE90(par->rotation) | 1; - args[1] = y1 + 1; - args[2] = xres; - args[3] = y2 - y1; - buf += y1 * line_length; - auok190x_send_cmdargs_pixels_nowait(par, AUOK1901_CMD_DMA_START, 4, - args, ((y2 - y1) * line_length)/2, - (u16 *) buf); - auok190x_send_command_nowait(par, AUOK190X_CMD_DATA_STOP); - - /* K1901: second tell the controller to update the region with mode */ - args[0] = mode | AUOK1901_DDMA_ROTATE180(par->rotation); - args[1] = 1; - args[2] = y1 + 1; - args[3] = xres; - args[4] = y2 - y1; - auok190x_send_cmdargs_nowait(par, AUOK1901_CMD_DDMA_START, 5, args); - - par->update_cnt++; - - mutex_unlock(&(par->io_lock)); - - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); -} - -static void auok1901fb_dpy_update_pages(struct auok190xfb_par *par, - u16 y1, u16 y2) -{ - int mode; - - if (par->update_mode < 0) { - mode = AUOK190X_UPDATE_MODE(1); - par->last_mode = -1; - } else { - mode = AUOK190X_UPDATE_MODE(par->update_mode); - par->last_mode = par->update_mode; - } - - if (par->flash) - mode |= AUOK190X_UPDATE_NONFLASH; - - auok1901_update_region(par, mode, y1, y2); -} - -static void auok1901fb_dpy_update(struct auok190xfb_par *par) -{ - int mode; - - /* When doing full updates, wait for the controller to be ready - * This will hopefully catch some hangs of the K1901 - */ - par->board->wait_for_rdy(par); - - if (par->update_mode < 0) { - mode = AUOK190X_UPDATE_MODE(0); - par->last_mode = -1; - } else { - mode = AUOK190X_UPDATE_MODE(par->update_mode); - par->last_mode = par->update_mode; - } - - if (par->flash) - mode |= AUOK190X_UPDATE_NONFLASH; - - auok1901_update_region(par, mode, 0, par->info->var.yres); - par->update_cnt = 0; -} - -static bool auok1901fb_need_refresh(struct auok190xfb_par *par) -{ - return (par->update_cnt > 10); -} - -static int auok1901fb_probe(struct platform_device *pdev) -{ - struct auok190x_init_data init; - struct auok190x_board *board; - - /* pick up board specific routines */ - board = pdev->dev.platform_data; - if (!board) - return -EINVAL; - - /* fill temporary init struct for common init */ - init.id = "auo_k1901fb"; - init.board = board; - init.update_partial = auok1901fb_dpy_update_pages; - init.update_all = auok1901fb_dpy_update; - init.need_refresh = auok1901fb_need_refresh; - init.init = auok1901_init; - - return auok190x_common_probe(pdev, &init); -} - -static int auok1901fb_remove(struct platform_device *pdev) -{ - return auok190x_common_remove(pdev); -} - -static struct platform_driver auok1901fb_driver = { - .probe = auok1901fb_probe, - .remove = auok1901fb_remove, - .driver = { - .name = "auo_k1901fb", - .pm = &auok190x_pm, - }, -}; -module_platform_driver(auok1901fb_driver); - -MODULE_DESCRIPTION("framebuffer driver for the AUO-K1901 EPD controller"); -MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>"); -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/auo_k190x.c b/drivers/video/fbdev/auo_k190x.c deleted file mode 100644 index b39681e6f4fd..000000000000 --- a/drivers/video/fbdev/auo_k190x.c +++ /dev/null @@ -1,1190 +0,0 @@ -/* - * Common code for AUO-K190X framebuffer drivers - * - * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include <linux/module.h> -#include <linux/sched/mm.h> -#include <linux/kernel.h> -#include <linux/gpio.h> -#include <linux/platform_device.h> -#include <linux/pm_runtime.h> -#include <linux/fb.h> -#include <linux/delay.h> -#include <linux/uaccess.h> -#include <linux/vmalloc.h> -#include <linux/regulator/consumer.h> - -#include <video/auo_k190xfb.h> - -#include "auo_k190x.h" - -struct panel_info { - int w; - int h; -}; - -/* table of panel specific parameters to be indexed into by the board drivers */ -static struct panel_info panel_table[] = { - /* standard 6" */ - [AUOK190X_RESOLUTION_800_600] = { - .w = 800, - .h = 600, - }, - /* standard 9" */ - [AUOK190X_RESOLUTION_1024_768] = { - .w = 1024, - .h = 768, - }, - [AUOK190X_RESOLUTION_600_800] = { - .w = 600, - .h = 800, - }, - [AUOK190X_RESOLUTION_768_1024] = { - .w = 768, - .h = 1024, - }, -}; - -/* - * private I80 interface to the board driver - */ - -static void auok190x_issue_data(struct auok190xfb_par *par, u16 data) -{ - par->board->set_ctl(par, AUOK190X_I80_WR, 0); - par->board->set_hdb(par, data); - par->board->set_ctl(par, AUOK190X_I80_WR, 1); -} - -static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data) -{ - par->board->set_ctl(par, AUOK190X_I80_DC, 0); - auok190x_issue_data(par, data); - par->board->set_ctl(par, AUOK190X_I80_DC, 1); -} - -/** - * Conversion of 16bit color to 4bit grayscale - * does roughly (0.3 * R + 0.6 G + 0.1 B) / 2 - */ -static inline int rgb565_to_gray4(u16 data, struct fb_var_screeninfo *var) -{ - return ((((data & 0xF800) >> var->red.offset) * 77 + - ((data & 0x07E0) >> (var->green.offset + 1)) * 151 + - ((data & 0x1F) >> var->blue.offset) * 28) >> 8 >> 1); -} - -static int auok190x_issue_pixels_rgb565(struct auok190xfb_par *par, int size, - u16 *data) -{ - struct fb_var_screeninfo *var = &par->info->var; - struct device *dev = par->info->device; - int i; - u16 tmp; - - if (size & 7) { - dev_err(dev, "issue_pixels: size %d must be a multiple of 8\n", - size); - return -EINVAL; - } - - for (i = 0; i < (size >> 2); i++) { - par->board->set_ctl(par, AUOK190X_I80_WR, 0); - - tmp = (rgb565_to_gray4(data[4*i], var) & 0x000F); - tmp |= (rgb565_to_gray4(data[4*i+1], var) << 4) & 0x00F0; - tmp |= (rgb565_to_gray4(data[4*i+2], var) << 8) & 0x0F00; - tmp |= (rgb565_to_gray4(data[4*i+3], var) << 12) & 0xF000; - - par->board->set_hdb(par, tmp); - par->board->set_ctl(par, AUOK190X_I80_WR, 1); - } - - return 0; -} - -static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size, - u16 *data) -{ - struct device *dev = par->info->device; - int i; - u16 tmp; - - if (size & 3) { - dev_err(dev, "issue_pixels: size %d must be a multiple of 4\n", - size); - return -EINVAL; - } - - for (i = 0; i < (size >> 1); i++) { - par->board->set_ctl(par, AUOK190X_I80_WR, 0); - - /* simple reduction of 8bit staticgray to 4bit gray - * combines 4 * 4bit pixel values into a 16bit value - */ - tmp = (data[2*i] & 0xF0) >> 4; - tmp |= (data[2*i] & 0xF000) >> 8; - tmp |= (data[2*i+1] & 0xF0) << 4; - tmp |= (data[2*i+1] & 0xF000); - - par->board->set_hdb(par, tmp); - par->board->set_ctl(par, AUOK190X_I80_WR, 1); - } - - return 0; -} - -static int auok190x_issue_pixels(struct auok190xfb_par *par, int size, - u16 *data) -{ - struct fb_info *info = par->info; - struct device *dev = par->info->device; - - if (info->var.bits_per_pixel == 8 && info->var.grayscale) - auok190x_issue_pixels_gray8(par, size, data); - else if (info->var.bits_per_pixel == 16) - auok190x_issue_pixels_rgb565(par, size, data); - else - dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n", - info->var.bits_per_pixel, info->var.grayscale); - - return 0; -} - -static u16 auok190x_read_data(struct auok190xfb_par *par) -{ - u16 data; - - par->board->set_ctl(par, AUOK190X_I80_OE, 0); - data = par->board->get_hdb(par); - par->board->set_ctl(par, AUOK190X_I80_OE, 1); - - return data; -} - -/* - * Command interface for the controller drivers - */ - -void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data) -{ - par->board->set_ctl(par, AUOK190X_I80_CS, 0); - auok190x_issue_cmd(par, data); - par->board->set_ctl(par, AUOK190X_I80_CS, 1); -} -EXPORT_SYMBOL_GPL(auok190x_send_command_nowait); - -void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd, - int argc, u16 *argv) -{ - int i; - - par->board->set_ctl(par, AUOK190X_I80_CS, 0); - auok190x_issue_cmd(par, cmd); - - for (i = 0; i < argc; i++) - auok190x_issue_data(par, argv[i]); - par->board->set_ctl(par, AUOK190X_I80_CS, 1); -} -EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_nowait); - -int auok190x_send_command(struct auok190xfb_par *par, u16 data) -{ - int ret; - - ret = par->board->wait_for_rdy(par); - if (ret) - return ret; - - auok190x_send_command_nowait(par, data); - return 0; -} -EXPORT_SYMBOL_GPL(auok190x_send_command); - -int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd, - int argc, u16 *argv) -{ - int ret; - - ret = par->board->wait_for_rdy(par); - if (ret) - return ret; - - auok190x_send_cmdargs_nowait(par, cmd, argc, argv); - return 0; -} -EXPORT_SYMBOL_GPL(auok190x_send_cmdargs); - -int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd, - int argc, u16 *argv) -{ - int i, ret; - - ret = par->board->wait_for_rdy(par); - if (ret) - return ret; - - par->board->set_ctl(par, AUOK190X_I80_CS, 0); - auok190x_issue_cmd(par, cmd); - - for (i = 0; i < argc; i++) - argv[i] = auok190x_read_data(par); - par->board->set_ctl(par, AUOK190X_I80_CS, 1); - - return 0; -} -EXPORT_SYMBOL_GPL(auok190x_read_cmdargs); - -void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par, u16 cmd, - int argc, u16 *argv, int size, u16 *data) -{ - int i; - - par->board->set_ctl(par, AUOK190X_I80_CS, 0); - - auok190x_issue_cmd(par, cmd); - - for (i = 0; i < argc; i++) - auok190x_issue_data(par, argv[i]); - - auok190x_issue_pixels(par, size, data); - - par->board->set_ctl(par, AUOK190X_I80_CS, 1); -} -EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels_nowait); - -int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd, - int argc, u16 *argv, int size, u16 *data) -{ - int ret; - - ret = par->board->wait_for_rdy(par); - if (ret) - return ret; - - auok190x_send_cmdargs_pixels_nowait(par, cmd, argc, argv, size, data); - - return 0; -} -EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels); - -/* - * fbdefio callbacks - common on both controllers. - */ - -static void auok190xfb_dpy_first_io(struct fb_info *info) -{ - /* tell runtime-pm that we wish to use the device in a short time */ - pm_runtime_get(info->device); -} - -/* this is called back from the deferred io workqueue */ -static void auok190xfb_dpy_deferred_io(struct fb_info *info, - struct list_head *pagelist) -{ - struct fb_deferred_io *fbdefio = info->fbdefio; - struct auok190xfb_par *par = info->par; - u16 line_length = info->fix.line_length; - u16 yres = info->var.yres; - u16 y1 = 0, h = 0; - int prev_index = -1; - struct page *cur; - int h_inc; - int threshold; - - if (!list_empty(pagelist)) - /* the device resume should've been requested through first_io, - * if the resume did not finish until now, wait for it. - */ - pm_runtime_barrier(info->device); - else - /* We reached this via the fsync or some other way. - * In either case the first_io function did not run, - * so we runtime_resume the device here synchronously. - */ - pm_runtime_get_sync(info->device); - - /* Do a full screen update every n updates to prevent - * excessive darkening of the Sipix display. - * If we do this, there is no need to walk the pages. - */ - if (par->need_refresh(par)) { - par->update_all(par); - goto out; - } - - /* height increment is fixed per page */ - h_inc = DIV_ROUND_UP(PAGE_SIZE , line_length); - - /* calculate number of pages from pixel height */ - threshold = par->consecutive_threshold / h_inc; - if (threshold < 1) - threshold = 1; - - /* walk the written page list and swizzle the data */ - list_for_each_entry(cur, &fbdefio->pagelist, lru) { - if (prev_index < 0) { - /* just starting so assign first page */ - y1 = (cur->index << PAGE_SHIFT) / line_length; - h = h_inc; - } else if ((cur->index - prev_index) <= threshold) { - /* page is within our threshold for single updates */ - h += h_inc * (cur->index - prev_index); - } else { - /* page not consecutive, issue previous update first */ - par->update_partial(par, y1, y1 + h); - - /* start over with our non consecutive page */ - y1 = (cur->index << PAGE_SHIFT) / line_length; - h = h_inc; - } - prev_index = cur->index; - } - - /* if we still have any pages to update we do so now */ - if (h >= yres) - /* its a full screen update, just do it */ - par->update_all(par); - else - par->update_partial(par, y1, min((u16) (y1 + h), yres)); - -out: - pm_runtime_mark_last_busy(info->device); - pm_runtime_put_autosuspend(info->device); -} - -/* - * framebuffer operations - */ - -/* - * this is the slow path from userspace. they can seek and write to - * the fb. it's inefficient to do anything less than a full screen draw - */ -static ssize_t auok190xfb_write(struct fb_info *info, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct auok190xfb_par *par = info->par; - unsigned long p = *ppos; - void *dst; - int err = 0; - unsigned long total_size; - - if (info->state != FBINFO_STATE_RUNNING) - return -EPERM; - - total_size = info->fix.smem_len; - - if (p > total_size) - return -EFBIG; - - if (count > total_size) { - err = -EFBIG; - count = total_size; - } - - if (count + p > total_size) { - if (!err) - err = -ENOSPC; - - count = total_size - p; - } - - dst = (void *)(info->screen_base + p); - - if (copy_from_user(dst, buf, count)) - err = -EFAULT; - - if (!err) - *ppos += count; - - par->update_all(par); - - return (err) ? err : count; -} - -static void auok190xfb_fillrect(struct fb_info *info, - const struct fb_fillrect *rect) -{ - struct auok190xfb_par *par = info->par; - - sys_fillrect(info, rect); - - par->update_all(par); -} - -static void auok190xfb_copyarea(struct fb_info *info, - const struct fb_copyarea *area) -{ - struct auok190xfb_par *par = info->par; - - sys_copyarea(info, area); - - par->update_all(par); -} - -static void auok190xfb_imageblit(struct fb_info *info, - const struct fb_image *image) -{ - struct auok190xfb_par *par = info->par; - - sys_imageblit(info, image); - - par->update_all(par); -} - -static int auok190xfb_check_var(struct fb_var_screeninfo *var, - struct fb_info *info) -{ - struct device *dev = info->device; - struct auok190xfb_par *par = info->par; - struct panel_info *panel = &panel_table[par->resolution]; - int size; - - /* - * Color depth - */ - - if (var->bits_per_pixel == 8 && var->grayscale == 1) { - /* - * For 8-bit grayscale, R, G, and B offset are equal. - */ - var->red.length = 8; - var->red.offset = 0; - var->red.msb_right = 0; - - var->green.length = 8; - var->green.offset = 0; - var->green.msb_right = 0; - - var->blue.length = 8; - var->blue.offset = 0; - var->blue.msb_right = 0; - - var->transp.length = 0; - var->transp.offset = 0; - var->transp.msb_right = 0; - } else if (var->bits_per_pixel == 16) { - var->red.length = 5; - var->red.offset = 11; - var->red.msb_right = 0; - - var->green.length = 6; - var->green.offset = 5; - var->green.msb_right = 0; - - var->blue.length = 5; - var->blue.offset = 0; - var->blue.msb_right = 0; - - var->transp.length = 0; - var->transp.offset = 0; - var->transp.msb_right = 0; - } else { - dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n", - info->var.bits_per_pixel, info->var.grayscale); - return -EINVAL; - } - - /* - * Dimensions - */ - - switch (var->rotate) { - case FB_ROTATE_UR: - case FB_ROTATE_UD: - var->xres = panel->w; - var->yres = panel->h; - break; - case FB_ROTATE_CW: - case FB_ROTATE_CCW: - var->xres = panel->h; - var->yres = panel->w; - break; - default: - dev_dbg(dev, "Invalid rotation request\n"); - return -EINVAL; - } - - var->xres_virtual = var->xres; - var->yres_virtual = var->yres; - - /* - * Memory limit - */ - - size = var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8; - if (size > info->fix.smem_len) { - dev_err(dev, "Memory limit exceeded, requested %dK\n", - size >> 10); - return -ENOMEM; - } - - return 0; -} - -static int auok190xfb_set_fix(struct fb_info *info) -{ - struct fb_fix_screeninfo *fix = &info->fix; - struct fb_var_screeninfo *var = &info->var; - - fix->line_length = var->xres_virtual * var->bits_per_pixel / 8; - - fix->type = FB_TYPE_PACKED_PIXELS; - fix->accel = FB_ACCEL_NONE; - fix->visual = (var->grayscale) ? FB_VISUAL_STATIC_PSEUDOCOLOR - : FB_VISUAL_TRUECOLOR; - fix->xpanstep = 0; - fix->ypanstep = 0; - fix->ywrapstep = 0; - - return 0; -} - -static int auok190xfb_set_par(struct fb_info *info) -{ - struct auok190xfb_par *par = info->par; - - par->rotation = info->var.rotate; - auok190xfb_set_fix(info); - - /* reinit the controller to honor the rotation */ - par->init(par); - - /* wait for init to complete */ - par->board->wait_for_rdy(par); - - return 0; -} - -static struct fb_ops auok190xfb_ops = { - .owner = THIS_MODULE, - .fb_read = fb_sys_read, - .fb_write = auok190xfb_write, - .fb_fillrect = auok190xfb_fillrect, - .fb_copyarea = auok190xfb_copyarea, - .fb_imageblit = auok190xfb_imageblit, - .fb_check_var = auok190xfb_check_var, - .fb_set_par = auok190xfb_set_par, -}; - -/* - * Controller-functions common to both K1900 and K1901 - */ - -static int auok190x_read_temperature(struct auok190xfb_par *par) -{ - struct device *dev = par->info->device; - u16 data[4]; - int temp; - - pm_runtime_get_sync(dev); - - mutex_lock(&(par->io_lock)); - - auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data); - - mutex_unlock(&(par->io_lock)); - - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); - - /* sanitize and split of half-degrees for now */ - temp = ((data[0] & AUOK190X_VERSION_TEMP_MASK) >> 1); - - /* handle positive and negative temperatures */ - if (temp >= 201) - return (255 - temp + 1) * (-1); - else - return temp; -} - -static void auok190x_identify(struct auok190xfb_par *par) -{ - struct device *dev = par->info->device; - u16 data[4]; - - pm_runtime_get_sync(dev); - - mutex_lock(&(par->io_lock)); - - auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data); - - mutex_unlock(&(par->io_lock)); - - par->epd_type = data[1] & AUOK190X_VERSION_TEMP_MASK; - - par->panel_size_int = AUOK190X_VERSION_SIZE_INT(data[2]); - par->panel_size_float = AUOK190X_VERSION_SIZE_FLOAT(data[2]); - par->panel_model = AUOK190X_VERSION_MODEL(data[2]); - - par->tcon_version = AUOK190X_VERSION_TCON(data[3]); - par->lut_version = AUOK190X_VERSION_LUT(data[3]); - - dev_dbg(dev, "panel %d.%din, model 0x%x, EPD 0x%x TCON-rev |