Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix many Linux kernel coding style issues

  • Loading branch information...
commit 3e99fae54a0d20f6cfda96544c53f3b3bed1faac 1 parent f2e680d
@notro authored
View
175 fbtft-bus.c
@@ -5,67 +5,67 @@
-/**********************************************************************************
+/*****************************************************************************
*
* void (*write_reg)(struct fbtft_par *par, int len, ...);
*
- **********************************************************************************/
-
-#define define_fbtft_write_reg(func, type, modifier) \
-void func(struct fbtft_par *par, int len, ...) \
-{ \
- va_list args; \
- int i, ret; \
- int offset = 0; \
- type *buf = (type *)par->buf; \
- \
- if (unlikely(par->debug & DEBUG_WRITE_DATA_COMMAND)) { \
- va_start(args, len); \
- for (i=0;i<len;i++) { \
- buf[i] = (type)va_arg(args, unsigned int); \
- } \
- va_end(args); \
- fbtft_par_dbg_hex(DEBUG_WRITE_DATA_COMMAND, par, par->info->device, type, buf, len, "%s: ", __func__); \
- } \
- \
- va_start(args, len); \
- \
- if(par->startbyte) { \
- *(u8 *)par->buf = par->startbyte; \
- buf = (type *)(par->buf + 1); \
- offset = 1; \
- } \
- \
- *buf = modifier((type)va_arg(args, unsigned int)); \
- if (par->gpio.dc != -1) \
- gpio_set_value(par->gpio.dc, 0); \
- ret = par->fbtftops.write(par, par->buf, sizeof(type)+offset); \
- if (ret < 0) { \
- va_end(args); \
- dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret); \
- return; \
- } \
- len--; \
- \
- if(par->startbyte) \
- *(u8 *)par->buf = par->startbyte | 0x2; \
- \
- if (len) { \
- i = len; \
- while (i--) { \
- *buf++ = modifier((type)va_arg(args, unsigned int)); \
- } \
- if (par->gpio.dc != -1) \
- gpio_set_value(par->gpio.dc, 1); \
- ret = par->fbtftops.write(par, par->buf, len * (sizeof(type)+offset)); \
- if (ret < 0) { \
- va_end(args); \
- dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret); \
- return; \
- } \
- } \
- va_end(args); \
-} \
+ *****************************************************************************/
+
+#define define_fbtft_write_reg(func, type, modifier) \
+void func(struct fbtft_par *par, int len, ...) \
+{ \
+ va_list args; \
+ int i, ret; \
+ int offset = 0; \
+ type *buf = (type *)par->buf; \
+ \
+ if (unlikely(par->debug & DEBUG_WRITE_DATA_COMMAND)) { \
+ va_start(args, len); \
+ for (i = 0; i < len; i++) { \
+ buf[i] = (type)va_arg(args, unsigned int); \
+ } \
+ va_end(args); \
+ fbtft_par_dbg_hex(DEBUG_WRITE_DATA_COMMAND, par, par->info->device, type, buf, len, "%s: ", __func__); \
+ } \
+ \
+ va_start(args, len); \
+ \
+ if (par->startbyte) { \
+ *(u8 *)par->buf = par->startbyte; \
+ buf = (type *)(par->buf + 1); \
+ offset = 1; \
+ } \
+ \
+ *buf = modifier((type)va_arg(args, unsigned int)); \
+ if (par->gpio.dc != -1) \
+ gpio_set_value(par->gpio.dc, 0); \
+ ret = par->fbtftops.write(par, par->buf, sizeof(type)+offset); \
+ if (ret < 0) { \
+ va_end(args); \
+ dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret); \
+ return; \
+ } \
+ len--; \
+ \
+ if (par->startbyte) \
+ *(u8 *)par->buf = par->startbyte | 0x2; \
+ \
+ if (len) { \
+ i = len; \
+ while (i--) { \
+ *buf++ = modifier((type)va_arg(args, unsigned int)); \
+ } \
+ if (par->gpio.dc != -1) \
+ gpio_set_value(par->gpio.dc, 1); \
+ ret = par->fbtftops.write(par, par->buf, len * (sizeof(type)+offset)); \
+ if (ret < 0) { \
+ va_end(args); \
+ dev_err(par->info->device, "%s: write() failed and returned %d\n", __func__, ret); \
+ return; \
+ } \
+ } \
+ va_end(args); \
+} \
EXPORT_SYMBOL(func);
define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, )
@@ -118,14 +118,15 @@ EXPORT_SYMBOL(fbtft_write_reg8_bus9);
-/**********************************************************************************
+/*****************************************************************************
*
* void (*write_data_command)(struct fbtft_par *par, unsigned dc, u32 val);
*
- **********************************************************************************/
+ *****************************************************************************/
/* 8-bit register over 8-bit databus */
-void fbtft_write_data_command8_bus8(struct fbtft_par *par, unsigned dc, u32 val)
+void
+fbtft_write_data_command8_bus8(struct fbtft_par *par, unsigned dc, u32 val)
{
int ret;
@@ -139,12 +140,15 @@ void fbtft_write_data_command8_bus8(struct fbtft_par *par, unsigned dc, u32 val)
ret = par->fbtftops.write(par, par->buf, 1);
if (ret < 0)
- dev_err(par->info->device, "%s: dc=%d, val=0x%X, failed with status %d\n", __func__, dc, val, ret);
+ dev_err(par->info->device,
+ "%s: dc=%d, val=0x%X, failed with status %d\n",
+ __func__, dc, val, ret);
}
EXPORT_SYMBOL(fbtft_write_data_command8_bus8);
/* 8-bit register/data over 9-bit SPI: dc + 8-bit */
-void fbtft_write_data_command8_bus9(struct fbtft_par *par, unsigned dc, u32 val)
+void
+fbtft_write_data_command8_bus9(struct fbtft_par *par, unsigned dc, u32 val)
{
int ret;
@@ -155,11 +159,14 @@ void fbtft_write_data_command8_bus9(struct fbtft_par *par, unsigned dc, u32 val)
ret = par->fbtftops.write(par, par->buf, 2);
if (ret < 0)
- dev_err(par->info->device, "%s: dc=%d, val=0x%X, failed with status %d\n", __func__, dc, val, ret);
+ dev_err(par->info->device,
+ "%s: dc=%d, val=0x%X, failed with status %d\n",
+ __func__, dc, val, ret);
}
EXPORT_SYMBOL(fbtft_write_data_command8_bus9);
-void fbtft_write_data_command16_bus16(struct fbtft_par *par, unsigned dc, u32 val)
+void
+fbtft_write_data_command16_bus16(struct fbtft_par *par, unsigned dc, u32 val)
{
int ret;
@@ -173,11 +180,14 @@ void fbtft_write_data_command16_bus16(struct fbtft_par *par, unsigned dc, u32 va
ret = par->fbtftops.write(par, par->buf, 2);
if (ret < 0)
- dev_err(par->info->device, "%s: dc=%d, val=0x%X, failed with status %d\n", __func__, dc, val, ret);
+ dev_err(par->info->device,
+ "%s: dc=%d, val=0x%X, failed with status %d\n",
+ __func__, dc, val, ret);
}
EXPORT_SYMBOL(fbtft_write_data_command16_bus16);
-void fbtft_write_data_command16_bus8(struct fbtft_par *par, unsigned dc, u32 val)
+void
+fbtft_write_data_command16_bus8(struct fbtft_par *par, unsigned dc, u32 val)
{
int ret;
unsigned offset = 0;
@@ -199,18 +209,20 @@ void fbtft_write_data_command16_bus8(struct fbtft_par *par, unsigned dc, u32 val
*(u16 *)(par->buf + offset) = cpu_to_be16((u16)val);
ret = par->fbtftops.write(par, par->buf, 2 + offset);
if (ret < 0)
- dev_err(par->info->device, "%s: dc=%d, val=0x%X, failed with status %d\n", __func__, dc, val, ret);
+ dev_err(par->info->device,
+ "%s: dc=%d, val=0x%X, failed with status %d\n",
+ __func__, dc, val, ret);
}
EXPORT_SYMBOL(fbtft_write_data_command16_bus8);
-/**********************************************************************************
+/*****************************************************************************
*
* int (*write_vmem)(struct fbtft_par *par);
*
- **********************************************************************************/
+ *****************************************************************************/
/* 16 bit pixel over 8-bit databus */
int fbtft_write_vmem16_bus8(struct fbtft_par *par)
@@ -236,11 +248,11 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par)
if (par->gpio.dc != -1)
gpio_set_value(par->gpio.dc, 1);
- // non buffered write
+ /* non buffered write */
if (!par->txbuf.buf)
return par->fbtftops.write(par, vmem16, len);
- // buffered write
+ /* buffered write */
tx_array_size = par->txbuf.len / 2;
if (par->startbyte) {
@@ -252,13 +264,15 @@ int fbtft_write_vmem16_bus8(struct fbtft_par *par)
while (remain) {
to_copy = remain > tx_array_size ? tx_array_size : remain;
- dev_dbg(par->info->device, " to_copy=%d, remain=%d\n", to_copy, remain - to_copy);
+ dev_dbg(par->info->device, " to_copy=%d, remain=%d\n",
+ to_copy, remain - to_copy);
- for (i=0;i<to_copy;i++)
+ for (i = 0; i < to_copy; i++)
txbuf16[i] = cpu_to_be16(vmem16[i]);
vmem16 = vmem16 + to_copy;
- ret = par->fbtftops.write(par, par->txbuf.buf, startbyte_size + to_copy*2);
+ ret = par->fbtftops.write(par, par->txbuf.buf,
+ startbyte_size + to_copy * 2);
if (ret < 0)
return ret;
remain -= to_copy;
@@ -273,7 +287,7 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par)
{
u8 *vmem8;
u16 *txbuf16 = par->txbuf.buf;
- size_t remain;
+ size_t remain;
size_t to_copy;
size_t tx_array_size;
int i;
@@ -297,15 +311,16 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par)
while (remain) {
to_copy = remain > tx_array_size ? tx_array_size : remain;
- dev_dbg(par->info->device, " to_copy=%d, remain=%d\n", to_copy, remain - to_copy);
+ dev_dbg(par->info->device, " to_copy=%d, remain=%d\n",
+ to_copy, remain - to_copy);
#ifdef __LITTLE_ENDIAN
- for (i=0;i<to_copy;i+=2) {
+ for (i = 0; i < to_copy; i += 2) {
txbuf16[i] = 0x0100 | vmem8[i+1];
txbuf16[i+1] = 0x0100 | vmem8[i];
}
#else
- for (i=0;i<to_copy;i++)
+ for (i = 0; i < to_copy; i++)
txbuf16[i] = 0x0100 | vmem8[i];
#endif
vmem8 = vmem8 + to_copy;
@@ -342,7 +357,7 @@ int fbtft_write_vmem16_bus16(struct fbtft_par *par)
if (par->gpio.dc != -1)
gpio_set_value(par->gpio.dc, 1);
- // no need for buffered write with 16-bit bus
+ /* no need for buffered write with 16-bit bus */
return par->fbtftops.write(par, vmem16, len);
}
EXPORT_SYMBOL(fbtft_write_vmem16_bus16);
View
183 fbtft-core.c
@@ -40,14 +40,16 @@
extern void fbtft_sysfs_init(struct fbtft_par *par);
extern void fbtft_sysfs_exit(struct fbtft_par *par);
extern void fbtft_expand_debug_value(unsigned long *debug);
-extern int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const char *str, int size);
+extern int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
+ const char *str, int size);
static unsigned long debug;
module_param(debug, ulong , 0);
-MODULE_PARM_DESC(debug,"override device debug level");
+MODULE_PARM_DESC(debug, "override device debug level");
-void fbtft_dbg_hex(const struct device *dev, int groupsize, void *buf, size_t len, const char *fmt, ...)
+void fbtft_dbg_hex(const struct device *dev, int groupsize,
+ void *buf, size_t len, const char *fmt, ...)
{
va_list args;
static char textbuf[512];
@@ -58,7 +60,8 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize, void *buf, size_t le
text_len = vscnprintf(text, sizeof(textbuf), fmt, args);
va_end(args);
- hex_dump_to_buffer(buf, len, 32, groupsize, text + text_len, 512 - text_len, false);
+ hex_dump_to_buffer(buf, len, 32, groupsize, text + text_len,
+ 512 - text_len, false);
if (len > 32)
dev_info(dev, "%s ...\n", text);
@@ -67,7 +70,8 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize, void *buf, size_t le
}
EXPORT_SYMBOL(fbtft_dbg_hex);
-unsigned long fbtft_request_gpios_match(struct fbtft_par *par, const struct fbtft_gpio *gpio)
+unsigned long fbtft_request_gpios_match(struct fbtft_par *par,
+ const struct fbtft_gpio *gpio)
{
int ret;
long val;
@@ -78,35 +82,28 @@ unsigned long fbtft_request_gpios_match(struct fbtft_par *par, const struct fbtf
if (strcasecmp(gpio->name, "reset") == 0) {
par->gpio.reset = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
- }
- else if (strcasecmp(gpio->name, "dc") == 0) {
+ } else if (strcasecmp(gpio->name, "dc") == 0) {
par->gpio.dc = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
- }
- else if (strcasecmp(gpio->name, "cs") == 0) {
+ } else if (strcasecmp(gpio->name, "cs") == 0) {
par->gpio.cs = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
- }
- else if (strcasecmp(gpio->name, "wr") == 0) {
+ } else if (strcasecmp(gpio->name, "wr") == 0) {
par->gpio.wr = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
- }
- else if (strcasecmp(gpio->name, "rd") == 0) {
+ } else if (strcasecmp(gpio->name, "rd") == 0) {
par->gpio.rd = gpio->gpio;
return GPIOF_OUT_INIT_HIGH;
- }
- else if (strcasecmp(gpio->name, "latch") == 0) {
+ } else if (strcasecmp(gpio->name, "latch") == 0) {
par->gpio.latch = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
- }
- else if (gpio->name[0] == 'd' && gpio->name[1] == 'b') {
+ } else if (gpio->name[0] == 'd' && gpio->name[1] == 'b') {
ret = kstrtol(&gpio->name[2], 10, &val);
if (ret == 0 && val < 16) {
par->gpio.db[val] = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
}
- }
- else if (strcasecmp(gpio->name, "led") == 0) {
+ } else if (strcasecmp(gpio->name, "led") == 0) {
par->gpio.led[0] = gpio->gpio;
return GPIOF_OUT_INIT_LOW;
}
@@ -129,7 +126,7 @@ int fbtft_request_gpios(struct fbtft_par *par)
par->gpio.wr = -1;
par->gpio.cs = -1;
par->gpio.latch = -1;
- for (i=0;i<16;i++) {
+ for (i = 0; i < 16; i++) {
par->gpio.db[i] = -1;
par->gpio.led[i] = -1;
par->gpio.aux[i] = -1;
@@ -139,15 +136,20 @@ int fbtft_request_gpios(struct fbtft_par *par)
gpio = pdata->gpios;
while (gpio->name[0]) {
flags = FBTFT_GPIO_NO_MATCH;
- /* if driver provides match function, try it first, if no match use our own */
+ /* if driver provides match function, try it first,
+ if no match use our own */
if (par->fbtftops.request_gpios_match)
flags = par->fbtftops.request_gpios_match(par, gpio);
if (flags == FBTFT_GPIO_NO_MATCH)
flags = fbtft_request_gpios_match(par, gpio);
if (flags != FBTFT_GPIO_NO_MATCH) {
- ret = gpio_request_one(gpio->gpio, flags, par->info->device->driver->name);
+ ret = gpio_request_one(gpio->gpio, flags,
+ par->info->device->driver->name);
if (ret < 0) {
- dev_err(par->info->device, "%s: gpio_request_one('%s'=%d) failed with %d\n", __func__, gpio->name, gpio->gpio, ret);
+ dev_err(par->info->device,
+ "%s: gpio_request_one('%s'=%d) failed with %d\n",
+ __func__, gpio->name,
+ gpio->gpio, ret);
return ret;
}
fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par,
@@ -168,7 +170,7 @@ void fbtft_free_gpios(struct fbtft_par *par)
fbtft_par_dbg(DEBUG_FREE_GPIOS, par, "%s()\n", __func__);
- if(par->spi)
+ if (par->spi)
pdata = par->spi->dev.platform_data;
if (par->pdev)
pdata = par->pdev->dev.platform_data;
@@ -179,7 +181,9 @@ void fbtft_free_gpios(struct fbtft_par *par)
fbtft_par_dbg(DEBUG_FREE_GPIOS, par,
"%s(): gpio_free('%s'=%d)\n",
__func__, gpio->name, gpio->gpio);
- gpio_direction_input(gpio->gpio); /* if the gpio wasn't recognized by request_gpios, WARN() will protest */
+ /* if the gpio wasn't recognized by request_gpios,
+ WARN() will protest */
+ gpio_direction_input(gpio->gpio);
gpio_free(gpio->gpio);
gpio++;
}
@@ -191,7 +195,8 @@ int fbtft_backlight_update_status(struct backlight_device *bd)
struct fbtft_par *par = bl_get_data(bd);
bool polarity = !!(bd->props.state & BL_CORE_DRIVER1);
- fbtft_par_dbg(DEBUG_BACKLIGHT, par, "%s: polarity=%d, power=%d, fb_blank=%d\n",
+ fbtft_par_dbg(DEBUG_BACKLIGHT, par,
+ "%s: polarity=%d, power=%d, fb_blank=%d\n",
__func__, polarity, bd->props.power, bd->props.fb_blank);
if ((bd->props.power == FB_BLANK_UNBLANK) && (bd->props.fb_blank == FB_BLANK_UNBLANK))
@@ -238,7 +243,9 @@ void fbtft_register_backlight(struct fbtft_par *par)
bl_ops = kzalloc(sizeof(struct backlight_ops), GFP_KERNEL);
if (!bl_ops) {
- dev_err(par->info->device, "%s: could not allocate memeory for backlight operations.\n", __func__);
+ dev_err(par->info->device,
+ "%s: could not allocate memeory for backlight operations.\n",
+ __func__);
return;
}
@@ -250,9 +257,12 @@ void fbtft_register_backlight(struct fbtft_par *par)
if (!gpio_get_value(par->gpio.led[0]))
bl_props.state |= BL_CORE_DRIVER1;
- bd = backlight_device_register(dev_driver_string(par->info->device), par->info->device, par, bl_ops, &bl_props);
+ bd = backlight_device_register(dev_driver_string(par->info->device),
+ par->info->device, par, bl_ops, &bl_props);
if (IS_ERR(bd)) {
- dev_err(par->info->device, "cannot register backlight device (%ld)\n", PTR_ERR(bd));
+ dev_err(par->info->device,
+ "cannot register backlight device (%ld)\n",
+ PTR_ERR(bd));
goto failed;
}
par->info->bl_dev = bd;
@@ -263,8 +273,7 @@ void fbtft_register_backlight(struct fbtft_par *par)
return;
failed:
- if (bl_ops)
- kfree(bl_ops);
+ kfree(bl_ops);
}
EXPORT_SYMBOL(fbtft_register_backlight);
@@ -306,31 +315,30 @@ void fbtft_reset(struct fbtft_par *par)
void fbtft_update_display(struct fbtft_par *par)
{
- struct timespec ts_start,ts_end,test_of_time;
+ struct timespec ts_start, ts_end, test_of_time;
long ms, us, ns;
bool timeit = false;
int ret = 0;
if (unlikely(par->debug & (DEBUG_TIME_FIRST_UPDATE | DEBUG_TIME_EACH_UPDATE))) {
- if ( (par->debug & DEBUG_TIME_EACH_UPDATE) || \
- ((par->debug & DEBUG_TIME_FIRST_UPDATE) && !par->first_update_done) )
- {
+ if ((par->debug & DEBUG_TIME_EACH_UPDATE) || \
+ ((par->debug & DEBUG_TIME_FIRST_UPDATE) && !par->first_update_done)) {
getnstimeofday(&ts_start);
timeit = true;
}
}
- // Sanity checks
+ /* Sanity checks */
if (par->dirty_lines_start > par->dirty_lines_end) {
fbtft_par_dbg(0xFFFFFFFF, par,
- "%s: dirty_lines_start=%d is larger than dirty_lines_end=%d. Shouldn't happen, will do full display update\n",
+ "%s: dirty_lines_start=%d is larger than dirty_lines_end=%d. Shouldn't happen, will do full display update\n",
__func__, par->dirty_lines_start, par->dirty_lines_end);
par->dirty_lines_start = 0;
par->dirty_lines_end = par->info->var.yres - 1;
}
if (par->dirty_lines_start > par->info->var.yres - 1 || par->dirty_lines_end > par->info->var.yres - 1) {
- dev_warn(par->info->device,
- "%s: dirty_lines_start=%d or dirty_lines_end=%d larger than max=%d. Shouldn't happen, will do full display update\n",
+ dev_warn(par->info->device,
+ "%s: dirty_lines_start=%d or dirty_lines_end=%d larger than max=%d. Shouldn't happen, will do full display update\n",
__func__, par->dirty_lines_start, par->dirty_lines_end, par->info->var.yres - 1);
par->dirty_lines_start = 0;
par->dirty_lines_end = par->info->var.yres - 1;
@@ -340,24 +348,30 @@ void fbtft_update_display(struct fbtft_par *par)
__func__, par->dirty_lines_start, par->dirty_lines_end);
if (par->fbtftops.set_addr_win)
- par->fbtftops.set_addr_win(par, 0, par->dirty_lines_start, par->info->var.xres-1, par->dirty_lines_end);
+ par->fbtftops.set_addr_win(par, 0, par->dirty_lines_start,
+ par->info->var.xres-1, par->dirty_lines_end);
ret = par->fbtftops.write_vmem(par);
if (ret < 0)
- dev_err(par->info->device, "%s: write_vmem failed to update display buffer\n", __func__);
+ dev_err(par->info->device,
+ "%s: write_vmem failed to update display buffer\n",
+ __func__);
if (unlikely(timeit)) {
getnstimeofday(&ts_end);
- test_of_time = timespec_sub(ts_end,ts_start);
+ test_of_time = timespec_sub(ts_end, ts_start);
us = (test_of_time.tv_nsec / 1000) % 1000;
ms = (test_of_time.tv_sec * 1000) + ((test_of_time.tv_nsec / 1000000) % 1000);
ns = test_of_time.tv_nsec % 1000;
- dev_info(par->info->device, "Elapsed time for display update: %4lu.%.3lu%.3lu ms (fps: %2lu, lines=%u)\n",
- ms, us, ns, test_of_time.tv_nsec ? 1000000000 / test_of_time.tv_nsec : 0, par->dirty_lines_end - par->dirty_lines_start + 1);
+ dev_info(par->info->device,
+ "Elapsed time for display update: %4lu.%.3lu%.3lu ms (fps: %2lu, lines=%u)\n",
+ ms, us, ns,
+ test_of_time.tv_nsec ? 1000000000 / test_of_time.tv_nsec : 0,
+ par->dirty_lines_end - par->dirty_lines_start + 1);
par->first_update_done = true;
}
- // set display line markers as clean
+ /* set display line markers as clean */
par->dirty_lines_start = par->info->var.yres - 1;
par->dirty_lines_end = 0;
}
@@ -368,19 +382,19 @@ void fbtft_mkdirty(struct fb_info *info, int y, int height)
struct fbtft_par *par = info->par;
struct fb_deferred_io *fbdefio = info->fbdefio;
- // special case, needed ?
+ /* special case, needed ? */
if (y == -1) {
y = 0;
height = info->var.yres - 1;
}
- // Mark display lines/area as dirty
+ /* Mark display lines/area as dirty */
if (y < par->dirty_lines_start)
par->dirty_lines_start = y;
if (y + height - 1 > par->dirty_lines_end)
par->dirty_lines_end = y + height - 1;
- // Schedule deferred_io to update display (no-op if already on queue)
+ /* Schedule deferred_io to update display (no-op if already on queue)*/
schedule_delayed_work(&info->deferred_work, fbdefio->delay);
}
@@ -389,7 +403,7 @@ void fbtft_deferred_io(struct fb_info *info, struct list_head *pagelist)
struct fbtft_par *par = info->par;
struct page *page;
unsigned long index;
- unsigned y_low=0, y_high=0;
+ unsigned y_low = 0, y_high = 0;
int count = 0;
/* Mark display lines as dirty */
@@ -425,7 +439,7 @@ void fbtft_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
par->fbtftops.mkdirty(info, rect->dy, rect->height);
}
-void fbtft_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+void fbtft_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
{
struct fbtft_par *par = info->par;
@@ -437,7 +451,7 @@ void fbtft_fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
par->fbtftops.mkdirty(info, area->dy, area->height);
}
-void fbtft_fb_imageblit(struct fb_info *info, const struct fb_image *image)
+void fbtft_fb_imageblit(struct fb_info *info, const struct fb_image *image)
{
struct fbtft_par *par = info->par;
@@ -449,7 +463,8 @@ void fbtft_fb_imageblit(struct fb_info *info, const struct fb_image *image)
par->fbtftops.mkdirty(info, image->dy, image->height);
}
-ssize_t fbtft_fb_write(struct fb_info *info, const char __user *buf, size_t count, loff_t *ppos)
+ssize_t fbtft_fb_write(struct fb_info *info,
+ const char __user *buf, size_t count, loff_t *ppos)
{
struct fbtft_par *par = info->par;
ssize_t res;
@@ -458,14 +473,14 @@ ssize_t fbtft_fb_write(struct fb_info *info, const char __user *buf, size_t coun
"%s: count=%zd, ppos=%llu\n", __func__, count, *ppos);
res = fb_sys_write(info, buf, count, ppos);
- // TODO: only mark changed area
- // update all for now
+ /* TODO: only mark changed area
+ update all for now */
par->fbtftops.mkdirty(info, -1, 0);
return res;
}
-// from pxafb.c
+/* from pxafb.c */
unsigned int chan_to_field(unsigned chan, struct fb_bitfield *bf)
{
chan &= 0xffff;
@@ -588,7 +603,8 @@ void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src)
* Returns the new structure, or NULL if an error occurred.
*
*/
-struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct device *dev)
+struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
+ struct device *dev)
{
struct fb_info *info;
struct fbtft_par *par;
@@ -613,7 +629,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
/* sanity check */
if (display->gamma_num * display->gamma_len > FBTFT_GAMMA_MAX_VALUES_TOTAL) {
- dev_err(dev, "%s: FBTFT_GAMMA_MAX_VALUES_TOTAL=%d is exceeded\n", __func__, FBTFT_GAMMA_MAX_VALUES_TOTAL);
+ dev_err(dev,
+ "%s: FBTFT_GAMMA_MAX_VALUES_TOTAL=%d is exceeded\n",
+ __func__, FBTFT_GAMMA_MAX_VALUES_TOTAL);
return NULL;
}
@@ -719,7 +737,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
info->var.bits_per_pixel = bpp;
info->var.nonstd = 1;
- // RGB565
+ /* RGB565 */
info->var.red.offset = 11;
info->var.red.length = 5;
info->var.green.offset = 5;
@@ -736,7 +754,8 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
par->pdata = dev->platform_data;
par->debug = display->debug;
par->buf = buf;
- // Set display line markers as dirty for all. Ensures first update to update all of the display.
+ /* Set display line markers as dirty for all.
+ Ensures that the first update is updating the whole display. */
par->dirty_lines_start = 0;
par->dirty_lines_end = par->info->var.yres - 1;
par->bgr = bgr;
@@ -749,9 +768,10 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
info->pseudo_palette = par->pseudo_palette;
if (par->gamma.curves && gamma)
- fbtft_gamma_parse_str(par, par->gamma.curves, gamma, strlen(gamma));
+ fbtft_gamma_parse_str(par,
+ par->gamma.curves, gamma, strlen(gamma));
- // Transmit buffer
+ /* Transmit buffer */
if (txbuflen == -1)
txbuflen = vmem_size;
@@ -768,7 +788,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
par->txbuf.len = txbuflen;
}
- // default fbtft operations
+ /* default fbtft operations */
par->fbtftops.write = fbtft_write_spi;
par->fbtftops.read = fbtft_read_spi;
par->fbtftops.write_vmem = fbtft_write_vmem16_bus8;
@@ -795,12 +815,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct de
vfree(txbuf);
if (buf)
vfree(buf);
- if (fbops)
- kfree(fbops);
- if (fbdefio)
- kfree(fbdefio);
- if (gamma_curves)
- kfree(gamma_curves);
+ kfree(fbops);
+ kfree(fbdefio);
+ kfree(gamma_curves);
return NULL;
}
@@ -823,9 +840,7 @@ void fbtft_framebuffer_release(struct fb_info *info)
vfree(par->buf);
kfree(info->fbops);
kfree(info->fbdefio);
- if (par->gamma.curves) {
- kfree(par->gamma.curves);
- }
+ kfree(par->gamma.curves);
framebuffer_release(info);
}
EXPORT_SYMBOL(fbtft_framebuffer_release);
@@ -851,7 +866,7 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
struct fbtft_par *par = fb_info->par;
struct spi_device *spi = par->spi;
- // sanity checks
+ /* sanity checks */
if (!par->fbtftops.init_display) {
dev_err(fb_info->device, "missing fbtftops.init_display()\n");
return -EINVAL;
@@ -901,9 +916,13 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
if (par->txbuf.buf)
sprintf(text1, ", %d KiB buffer memory", par->txbuf.len >> 10);
if (spi)
- sprintf(text2, ", spi%d.%d at %d MHz", spi->master->bus_num, spi->chip_select, spi->max_speed_hz/1000000);
- dev_info(fb_info->dev, "%s frame buffer, %dx%d, %d KiB video memory%s, fps=%lu%s\n",
- fb_info->fix.id, fb_info->var.xres, fb_info->var.yres, fb_info->fix.smem_len >> 10, text1, HZ/fb_info->fbdefio->delay, text2);
+ sprintf(text2, ", spi%d.%d at %d MHz", spi->master->bus_num,
+ spi->chip_select, spi->max_speed_hz/1000000);
+ dev_info(fb_info->dev,
+ "%s frame buffer, %dx%d, %d KiB video memory%s, fps=%lu%s\n",
+ fb_info->fix.id, fb_info->var.xres, fb_info->var.yres,
+ fb_info->fix.smem_len >> 10, text1,
+ HZ/fb_info->fbdefio->delay, text2);
/* Turn on backlight if available */
if (fb_info->bl_dev) {
@@ -971,17 +990,13 @@ int fbtft_init_display(struct fbtft_par *par)
fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+ /* sanity check */
if (!par->init_sequence) {
dev_err(par->info->device,
"error: init_sequence is not set\n");
return -EINVAL;
}
- par->fbtftops.reset(par);
-
- if (par->gpio.cs != -1)
- gpio_set_value(par->gpio.cs, 0); /* Activate chip */
-
/* make sure stop marker exists */
for (i = 0; i < FBTFT_MAX_INIT_SEQUENCE; i++)
if (par->init_sequence[i] == -3)
@@ -992,6 +1007,10 @@ int fbtft_init_display(struct fbtft_par *par)
return -EINVAL;
}
+ par->fbtftops.reset(par);
+ if (par->gpio.cs != -1)
+ gpio_set_value(par->gpio.cs, 0); /* Activate chip */
+
i = 0;
while (i < FBTFT_MAX_INIT_SEQUENCE) {
if (par->init_sequence[i] == -3) {
@@ -1073,7 +1092,8 @@ int fbtft_verify_gpios(struct fbtft_par *par)
return 0;
}
- if (pdata->display.buswidth != 9 && par->startbyte == 0 && par->gpio.dc < 0) {
+ if (pdata->display.buswidth != 9 && par->startbyte == 0 && \
+ par->gpio.dc < 0) {
dev_err(par->info->device,
"Missing info about 'dc' gpio. Aborting.\n");
return -EINVAL;
@@ -1264,5 +1284,4 @@ int fbtft_remove_common(struct device *dev, struct fb_info *info)
}
EXPORT_SYMBOL(fbtft_remove_common);
-
MODULE_LICENSE("GPL");
View
78 fbtft-io.c
@@ -9,7 +9,8 @@ int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len)
"%s(len=%d): ", __func__, len);
if (!par->spi) {
- dev_err(par->info->device, "%s: par->spi is unexpectedly NULL\n", __func__);
+ dev_err(par->info->device,
+ "%s: par->spi is unexpectedly NULL\n", __func__);
return -1;
}
return spi_write(par->spi, buf, len);
@@ -83,13 +84,16 @@ int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len)
struct spi_message m;
if (!par->spi) {
- dev_err(par->info->device, "%s: par->spi is unexpectedly NULL\n", __func__);
+ dev_err(par->info->device,
+ "%s: par->spi is unexpectedly NULL\n", __func__);
return -ENODEV;
}
if (par->startbyte) {
if (len > 32) {
- dev_err(par->info->device, "%s: len=%d can't be larger than 32 when using 'startbyte'\n", __func__, len);
+ dev_err(par->info->device,
+ "%s: len=%d can't be larger than 32 when using 'startbyte'\n",
+ __func__, len);
return -EINVAL;
}
txbuf[0] = par->startbyte | 0x3;
@@ -111,14 +115,24 @@ EXPORT_SYMBOL(fbtft_read_spi);
#ifdef CONFIG_ARCH_BCM2708
-/* Raspberry Pi - writing directly to the registers is 40-50% faster than optimized use of gpiolib */
+/*
+ * Raspberry Pi
+ * - writing directly to the registers is 40-50% faster than
+ * optimized use of gpiolib
+ */
-#define GPIOSET(no, ishigh) { if (ishigh) set|=(1<<no); else reset|=(1<<no); } while(0)
+#define GPIOSET(no, ishigh) \
+do { \
+ if (ishigh) \
+ set |= (1 << (no)); \
+ else \
+ reset |= (1 << (no)); \
+} while (0)
int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
{
- unsigned int set=0;
- unsigned int reset=0;
+ unsigned int set = 0;
+ unsigned int reset = 0;
u8 data;
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
@@ -140,9 +154,9 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
writel(set, __io_address(GPIO_BASE+0x1C));
writel(reset, __io_address(GPIO_BASE+0x28));
- //Pulse /WR low
+ /* Pulse /WR low */
writel((1<<par->gpio.wr), __io_address(GPIO_BASE+0x28));
- writel(0, __io_address(GPIO_BASE+0x28)); //used as a delay
+ writel(0, __io_address(GPIO_BASE+0x28)); /* used as a delay */
writel((1<<par->gpio.wr), __io_address(GPIO_BASE+0x1C));
set = 0;
@@ -151,11 +165,12 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
return 0;
}
+EXPORT_SYMBOL(fbtft_write_gpio8_wr);
int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
{
- unsigned int set=0;
- unsigned int reset=0;
+ unsigned int set = 0;
+ unsigned int reset = 0;
u16 data;
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
@@ -164,7 +179,7 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
while (len) {
len -= 2;
data = *(u16 *) buf;
- buf +=2;
+ buf += 2;
/* Start writing by pulling down /WR */
gpio_set_value(par->gpio.wr, 0);
@@ -200,11 +215,12 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
return 0;
}
+EXPORT_SYMBOL(fbtft_write_gpio16_wr);
int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
{
- unsigned int set=0;
- unsigned int reset=0;
+ unsigned int set = 0;
+ unsigned int reset = 0;
u16 data;
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
@@ -213,7 +229,7 @@ int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
while (len) {
len -= 2;
data = *(u16 *) buf;
- buf +=2;
+ buf += 2;
/* Start writing by pulling down /WR */
gpio_set_value(par->gpio.wr, 0);
@@ -255,19 +271,22 @@ int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
return 0;
}
+EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
#undef GPIOSET
#else
-/* Optimized use of gpiolib is twice as fast as no optimization */
-/* only one driver can use the optimized version at a time */
+/*
+ * Optimized use of gpiolib is twice as fast as no optimization
+ * only one driver can use the optimized version at a time
+ */
int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
{
u8 data;
int i;
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
- static u8 prev_data = 0;
+ static u8 prev_data;
#endif
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
@@ -284,15 +303,16 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
if (data == prev_data) {
gpio_set_value(par->gpio.wr, 0); /* used as delay */
} else {
- for (i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
if ((data & 1) != (prev_data & 1))
- gpio_set_value(par->gpio.db[i], (data & 1));
+ gpio_set_value(par->gpio.db[i],
+ (data & 1));
data >>= 1;
prev_data >>= 1;
}
}
#else
- for (i=0;i<8;i++) {
+ for (i = 0; i < 8; i++) {
gpio_set_value(par->gpio.db[i], (data & 1));
data >>= 1;
}
@@ -309,13 +329,14 @@ int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len)
return 0;
}
+EXPORT_SYMBOL(fbtft_write_gpio8_wr);
int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
{
u16 data;
int i;
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
- static u16 prev_data = 0;
+ static u16 prev_data;
#endif
fbtft_par_dbg_hex(DEBUG_WRITE, par, par->info->device, u8, buf, len,
@@ -332,15 +353,16 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
if (data == prev_data) {
gpio_set_value(par->gpio.wr, 0); /* used as delay */
} else {
- for (i=0;i<16;i++) {
+ for (i = 0; i < 16; i++) {
if ((data & 1) != (prev_data & 1))
- gpio_set_value(par->gpio.db[i], (data & 1));
+ gpio_set_value(par->gpio.db[i],
+ (data & 1));
data >>= 1;
prev_data >>= 1;
}
}
#else
- for (i=0;i<16;i++) {
+ for (i = 0; i < 16; i++) {
gpio_set_value(par->gpio.db[i], (data & 1));
data >>= 1;
}
@@ -358,15 +380,13 @@ int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len)
return 0;
}
+EXPORT_SYMBOL(fbtft_write_gpio16_wr);
int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len)
{
dev_err(par->info->device, "%s: function not implemented\n", __func__);
return -1;
}
+EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
#endif /* CONFIG_ARCH_BCM2708 */
-
-EXPORT_SYMBOL(fbtft_write_gpio8_wr);
-EXPORT_SYMBOL(fbtft_write_gpio16_wr);
-EXPORT_SYMBOL(fbtft_write_gpio16_wr_latched);
View
72 fbtft-sysfs.c
@@ -21,11 +21,12 @@ static int get_next_ulong(char **str_p, unsigned long *val, char *sep, int base)
return 0;
}
-int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const char *str, int size)
+int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves,
+ const char *str, int size)
{
- char *str_p, *curve_p=NULL;
+ char *str_p, *curve_p = NULL;
char *tmp;
- unsigned long val=0;
+ unsigned long val = 0;
int ret = 0;
int curve_counter, value_counter;
@@ -34,8 +35,7 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const ch
if (!str || !curves)
return -EINVAL;
- if (par->debug & DEBUG_SYSFS)
- printk("%s\n", str);
+ fbtft_par_dbg(DEBUG_SYSFS, par, "%s\n", str);
tmp = kmalloc(size+1, GFP_KERNEL);
if (!tmp)
@@ -57,7 +57,7 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const ch
curve_counter = 0;
while (str_p) {
if (curve_counter == par->gamma.num_curves) {
- printk("Gamma: Too many curves\n");
+ dev_err(par->info->device, "Gamma: Too many curves\n");
ret = -EINVAL;
goto out;
}
@@ -65,26 +65,26 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const ch
value_counter = 0;
while (curve_p) {
if (value_counter == par->gamma.num_values) {
- printk("Gamma: Too many values\n");
+ dev_err(par->info->device,
+ "Gamma: Too many values\n");
ret = -EINVAL;
goto out;
}
ret = get_next_ulong(&curve_p, &val, " ", 16);
- if (ret) {
+ if (ret)
goto out;
- }
curves[curve_counter * par->gamma.num_values + value_counter] = val;
value_counter++;
}
if (value_counter != par->gamma.num_values) {
- printk("Gamma: Too few values\n");
+ dev_err(par->info->device, "Gamma: Too few values\n");
ret = -EINVAL;
goto out;
}
curve_counter++;
}
if (curve_counter != par->gamma.num_curves) {
- printk("Gamma: Too few curves\n");
+ dev_err(par->info->device, "Gamma: Too few curves\n");
ret = -EINVAL;
goto out;
}
@@ -94,7 +94,8 @@ int fbtft_gamma_parse_str(struct fbtft_par *par, unsigned long *curves, const ch
return ret;
}
-static ssize_t sprintf_gamma(struct fbtft_par *par, unsigned long *curves, char *buf)
+static ssize_t
+sprintf_gamma(struct fbtft_par *par, unsigned long *curves, char *buf)
{
ssize_t len = 0;
unsigned int i, j;
@@ -112,8 +113,8 @@ static ssize_t sprintf_gamma(struct fbtft_par *par, unsigned long *curves, char
}
static ssize_t store_gamma_curve(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
@@ -137,7 +138,7 @@ static ssize_t store_gamma_curve(struct device *device,
}
static ssize_t show_gamma_curve(struct device *device,
- struct device_attribute *attr, char *buf)
+ struct device_attribute *attr, char *buf)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
@@ -146,25 +147,40 @@ static ssize_t show_gamma_curve(struct device *device,
}
static struct device_attribute gamma_device_attrs[] = {
- __ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma_curve, store_gamma_curve),
+ __ATTR(gamma, S_IRUGO | S_IWUGO, show_gamma_curve, store_gamma_curve),
};
-void fbtft_expand_debug_value(unsigned long *debug) {
+void fbtft_expand_debug_value(unsigned long *debug)
+{
switch (*debug & 0b111) {
- case 1: *debug |= DEBUG_LEVEL_1; break;
- case 2: *debug |= DEBUG_LEVEL_2; break;
- case 3: *debug |= DEBUG_LEVEL_3; break;
- case 4: *debug |= DEBUG_LEVEL_4; break;
- case 5: *debug |= DEBUG_LEVEL_5; break;
- case 6: *debug |= DEBUG_LEVEL_6; break;
- case 7: *debug = 0xFFFFFFFF; break;
+ case 1:
+ *debug |= DEBUG_LEVEL_1;
+ break;
+ case 2:
+ *debug |= DEBUG_LEVEL_2;
+ break;
+ case 3:
+ *debug |= DEBUG_LEVEL_3;
+ break;
+ case 4:
+ *debug |= DEBUG_LEVEL_4;
+ break;
+ case 5:
+ *debug |= DEBUG_LEVEL_5;
+ break;
+ case 6:
+ *debug |= DEBUG_LEVEL_6;
+ break;
+ case 7:
+ *debug = 0xFFFFFFFF;
+ break;
}
}
static ssize_t store_debug(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
@@ -179,7 +195,7 @@ static ssize_t store_debug(struct device *device,
}
static ssize_t show_debug(struct device *device,
- struct device_attribute *attr, char *buf)
+ struct device_attribute *attr, char *buf)
{
struct fb_info *fb_info = dev_get_drvdata(device);
struct fbtft_par *par = fb_info->par;
@@ -188,7 +204,7 @@ static ssize_t show_debug(struct device *device,
}
static struct device_attribute debug_device_attr = \
- __ATTR(debug, S_IRUGO | S_IWUGO, show_debug, store_debug);
+ __ATTR(debug, S_IRUGO | S_IWUGO, show_debug, store_debug);
void fbtft_sysfs_init(struct fbtft_par *par)
View
125 fbtft.h
@@ -70,7 +70,8 @@ struct fbtft_par;
* @verify_gpios: Verify that necessary gpios is present (optional)
* @register_backlight: Used to register backlight device (optional)
* @unregister_backlight: Unregister backlight device (optional)
- * @set_var: Configure LCD with values from variables like @rotate and @bgr (optional)
+ * @set_var: Configure LCD with values from variables like @rotate and @bgr
+ * (optional)
* @set_gamma: Set Gamma curve (optional)
*
* Most of these operations have default functions assigned to them in
@@ -83,14 +84,16 @@ struct fbtft_ops {
void (*write_data_command)(struct fbtft_par *par, unsigned dc, u32 val);
void (*write_reg)(struct fbtft_par *par, int len, ...);
- void (*set_addr_win)(struct fbtft_par *par, int xs, int ys, int xe, int ye);
+ void (*set_addr_win)(struct fbtft_par *par,
+ int xs, int ys, int xe, int ye);
void (*reset)(struct fbtft_par *par);
void (*mkdirty)(struct fb_info *info, int from, int to);
void (*update_display)(struct fbtft_par *par);
int (*init_display)(struct fbtft_par *par);
int (*blank)(struct fbtft_par *par, bool on);
- unsigned long (*request_gpios_match)(struct fbtft_par *par, const struct fbtft_gpio *gpio);
+ unsigned long (*request_gpios_match)(struct fbtft_par *par,
+ const struct fbtft_gpio *gpio);
int (*request_gpios)(struct fbtft_par *par);
void (*free_gpios)(struct fbtft_par *par);
int (*verify_gpios)(struct fbtft_par *par);
@@ -180,7 +183,8 @@ struct fbtft_platform_data {
* @txbuf.buf: Transmit buffer
* @txbuf.len: Transmit buffer length
* @buf: Small buffer used when writing init data over SPI
- * @startbyte: Used by some controllers when in SPI mode. Format: 6 bit Device id + RS bit + RW bit
+ * @startbyte: Used by some controllers when in SPI mode.
+ * Format: 6 bit Device id + RS bit + RW bit
* @fbtftops: FBTFT operations provided by driver or device (platform_data)
* @dirty_lines_start: Where to begin updating display
* @dirty_lines_end: Where to end updating display
@@ -199,7 +203,7 @@ struct fbtft_platform_data {
* @gamma.num_values: Number of values per Gamma curve
* @gamma.num_curves: Number of Gamma curves
* @debug: Pointer to debug value
- * @current_debug:
+ * @current_debug:
* @first_update_done: Used to only time the first display update
* @bgr: BGR mode/\n
* @extra: Extra info needed by driver (not used by core)
@@ -215,8 +219,8 @@ struct fbtft_par {
void *buf;
size_t len;
} txbuf;
- u8 *buf; /* small buffer used when writing init data over SPI */
- u8 startbyte; /* used by some controllers when in SPI mode. Format: 6 bit Device id + RS bit + RW bit */
+ u8 *buf;
+ u8 startbyte;
struct fbtft_ops fbtftops;
unsigned dirty_lines_start;
unsigned dirty_lines_end;
@@ -245,29 +249,46 @@ struct fbtft_par {
};
#define NUMARGS(...) (sizeof((int[]){__VA_ARGS__})/sizeof(int))
-#define write_reg(par, ...) par->fbtftops.write_reg(par, NUMARGS(__VA_ARGS__), __VA_ARGS__)
-#define write_cmd(par, val) par->fbtftops.write_data_command(par, 0, val)
-#define write_data(par, val) par->fbtftops.write_data_command(par, 1, val)
+
+#define write_reg(par, ...) \
+do { \
+ par->fbtftops.write_reg(par, NUMARGS(__VA_ARGS__), __VA_ARGS__); \
+} while (0)
+
+#define write_cmd(par, val) \
+do { \
+ par->fbtftops.write_data_command(par, 0, val); \
+} while (0)
+
+#define write_data(par, val) \
+do { \
+ par->fbtftops.write_data_command(par, 1, val); \
+} while (0)
/* fbtft-core.c */
-extern void fbtft_dbg_hex(const struct device *dev, int groupsize, void *buf, size_t len, const char *fmt, ...);
-extern struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, struct device *dev);
+extern void fbtft_dbg_hex(const struct device *dev,
+ int groupsize, void *buf, size_t len, const char *fmt, ...);
+extern struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
+ struct device *dev);
extern void fbtft_framebuffer_release(struct fb_info *info);
extern int fbtft_register_framebuffer(struct fb_info *fb_info);
extern int fbtft_unregister_framebuffer(struct fb_info *fb_info);
extern void fbtft_register_backlight(struct fbtft_par *par);
extern void fbtft_unregister_backlight(struct fbtft_par *par);
extern int fbtft_init_display(struct fbtft_par *par);
-extern int fbtft_probe_common(struct fbtft_display *display, struct spi_device *sdev, struct platform_device *pdev);
+extern int fbtft_probe_common(struct fbtft_display *display,
+ struct spi_device *sdev, struct platform_device *pdev);
extern int fbtft_remove_common(struct device *dev, struct fb_info *info);
/* fbtft-io.c */
extern int fbtft_write_spi(struct fbtft_par *par, void *buf, size_t len);
-extern int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len);
+extern int fbtft_write_spi_emulate_9(struct fbtft_par *par,
+ void *buf, size_t len);
extern int fbtft_read_spi(struct fbtft_par *par, void *buf, size_t len);
extern int fbtft_write_gpio8_wr(struct fbtft_par *par, void *buf, size_t len);
extern int fbtft_write_gpio16_wr(struct fbtft_par *par, void *buf, size_t len);
-extern int fbtft_write_gpio16_wr_latched(struct fbtft_par *par, void *buf, size_t len);
+extern int fbtft_write_gpio16_wr_latched(struct fbtft_par *par,
+ void *buf, size_t len);
/* fbtft-bus.c */
extern int fbtft_write_vmem8_bus8(struct fbtft_par *par);
@@ -278,38 +299,42 @@ extern void fbtft_write_reg8_bus8(struct fbtft_par *par, int len, ...);
extern void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...);
extern void fbtft_write_reg16_bus8(struct fbtft_par *par, int len, ...);
extern void fbtft_write_reg16_bus16(struct fbtft_par *par, int len, ...);
-extern void fbtft_write_data_command8_bus8(struct fbtft_par *par, unsigned dc, u32 val);
-extern void fbtft_write_data_command8_bus9(struct fbtft_par *par, unsigned dc, u32 val);
-extern void fbtft_write_data_command16_bus16(struct fbtft_par *par, unsigned dc, u32 val);
-extern void fbtft_write_data_command16_bus8(struct fbtft_par *par, unsigned dc, u32 val);
+extern void fbtft_write_data_command8_bus8(struct fbtft_par *par,
+ unsigned dc, u32 val);
+extern void fbtft_write_data_command8_bus9(struct fbtft_par *par,
+ unsigned dc, u32 val);
+extern void fbtft_write_data_command16_bus16(struct fbtft_par *par,
+ unsigned dc, u32 val);
+extern void fbtft_write_data_command16_bus8(struct fbtft_par *par,
+ unsigned dc, u32 val);
#define FBTFT_REGISTER_DRIVER(_name, _display) \
- \
+ \
static int fbtft_driver_probe_spi(struct spi_device *spi) \
{ \
return fbtft_probe_common(_display, spi, NULL); \
} \
- \
+ \
static int fbtft_driver_remove_spi(struct spi_device *spi) \
{ \
struct fb_info *info = spi_get_drvdata(spi); \
- \
+ \
return fbtft_remove_common(&spi->dev, info); \
} \
- \
+ \
static int fbtft_driver_probe_pdev(struct platform_device *pdev) \
{ \
return fbtft_probe_common(_display, NULL, pdev); \
} \
- \
+ \
static int fbtft_driver_remove_pdev(struct platform_device *pdev) \
{ \
struct fb_info *info = platform_get_drvdata(pdev); \
- \
+ \
return fbtft_remove_common(&pdev->dev, info); \
} \
- \
+ \
static struct spi_driver fbtft_driver_spi_driver = { \
.driver = { \
.name = _name, \
@@ -318,7 +343,7 @@ static struct spi_driver fbtft_driver_spi_driver = { \
.probe = fbtft_driver_probe_spi, \
.remove = fbtft_driver_remove_spi, \
}; \
- \
+ \
static struct platform_driver fbtft_driver_platform_driver = { \
.driver = { \
.name = _name, \
@@ -327,23 +352,23 @@ static struct platform_driver fbtft_driver_platform_driver = { \
.probe = fbtft_driver_probe_pdev, \
.remove = fbtft_driver_remove_pdev, \
}; \
- \
+ \
static int __init fbtft_driver_module_init(void) \
{ \
int ret; \
- \
+ \
ret = spi_register_driver(&fbtft_driver_spi_driver); \
if (ret < 0) \
return ret; \
return platform_driver_register(&fbtft_driver_platform_driver); \
} \
- \
+ \
static void __exit fbtft_driver_module_exit(void) \
{ \
spi_unregister_driver(&fbtft_driver_spi_driver); \
platform_driver_unregister(&fbtft_driver_platform_driver); \
} \
- \
+ \
module_init(fbtft_driver_module_init); \
module_exit(fbtft_driver_module_exit);
@@ -351,13 +376,13 @@ module_exit(fbtft_driver_module_exit);
/* Debug macros */
/* shorthand debug levels */
-#define DEBUG_LEVEL_1 DEBUG_REQUEST_GPIOS
-#define DEBUG_LEVEL_2 (DEBUG_LEVEL_1 | DEBUG_DRIVER_INIT_FUNCTIONS | DEBUG_TIME_FIRST_UPDATE)
-#define DEBUG_LEVEL_3 (DEBUG_LEVEL_2 | DEBUG_RESET | DEBUG_INIT_DISPLAY | DEBUG_BLANK | DEBUG_FREE_GPIOS | DEBUG_VERIFY_GPIOS | DEBUG_BACKLIGHT | DEBUG_SYSFS)
-#define DEBUG_LEVEL_4 (DEBUG_LEVEL_2 | DEBUG_FB_READ | DEBUG_FB_WRITE | DEBUG_FB_FILLRECT | DEBUG_FB_COPYAREA | DEBUG_FB_IMAGEBLIT | DEBUG_FB_BLANK)
-#define DEBUG_LEVEL_5 (DEBUG_LEVEL_3 | DEBUG_UPDATE_DISPLAY)
-#define DEBUG_LEVEL_6 (DEBUG_LEVEL_4 | DEBUG_LEVEL_5)
-#define DEBUG_LEVEL_7 0xFFFFFFFF
+#define DEBUG_LEVEL_1 DEBUG_REQUEST_GPIOS
+#define DEBUG_LEVEL_2 (DEBUG_LEVEL_1 | DEBUG_DRIVER_INIT_FUNCTIONS | DEBUG_TIME_FIRST_UPDATE)
+#define DEBUG_LEVEL_3 (DEBUG_LEVEL_2 | DEBUG_RESET | DEBUG_INIT_DISPLAY | DEBUG_BLANK | DEBUG_FREE_GPIOS | DEBUG_VERIFY_GPIOS | DEBUG_BACKLIGHT | DEBUG_SYSFS)
+#define DEBUG_LEVEL_4 (DEBUG_LEVEL_2 | DEBUG_FB_READ | DEBUG_FB_WRITE | DEBUG_FB_FILLRECT | DEBUG_FB_COPYAREA | DEBUG_FB_IMAGEBLIT | DEBUG_FB_BLANK)
+#define DEBUG_LEVEL_5 (DEBUG_LEVEL_3 | DEBUG_UPDATE_DISPLAY)
+#define DEBUG_LEVEL_6 (DEBUG_LEVEL_4 | DEBUG_LEVEL_5)
+#define DEBUG_LEVEL_7 0xFFFFFFFF
#define DEBUG_DRIVER_INIT_FUNCTIONS (1<<3)
#define DEBUG_TIME_FIRST_UPDATE (1<<4)
@@ -366,7 +391,7 @@ module_exit(fbtft_driver_module_exit);
#define DEBUG_FBTFT_INIT_FUNCTIONS (1<<7)
/* fbops */
-#define DEBUG_FB_READ (1<<8) /* not in use */
+#define DEBUG_FB_READ (1<<8)
#define DEBUG_FB_WRITE (1<<9)
#define DEBUG_FB_FILLRECT (1<<10)
#define DEBUG_FB_COPYAREA (1<<11)
@@ -378,13 +403,13 @@ module_exit(fbtft_driver_module_exit);
/* fbtftops */
#define DEBUG_BACKLIGHT (1<<17)
-#define DEBUG_READ (1<<18) /* not in use */
+#define DEBUG_READ (1<<18)
#define DEBUG_WRITE (1<<19)
#define DEBUG_WRITE_VMEM (1<<20)
#define DEBUG_WRITE_DATA_COMMAND (1<<21)
#define DEBUG_SET_ADDR_WIN (1<<22)
#define DEBUG_RESET (1<<23)
-#define DEBUG_MKDIRTY (1<<24) /* not in use */
+#define DEBUG_MKDIRTY (1<<24)
#define DEBUG_UPDATE_DISPLAY (1<<25)
#define DEBUG_INIT_DISPLAY (1<<26)
#define DEBUG_BLANK (1<<27)
@@ -395,20 +420,28 @@ module_exit(fbtft_driver_module_exit);
#define fbtft_init_dbg(dev, format, arg...) \
+do { \
if (unlikely((dev)->platform_data && \
(((struct fbtft_platform_data *)(dev)->platform_data)->display.debug & DEBUG_DRIVER_INIT_FUNCTIONS))) \
- dev_info(dev, format, ##arg);
+ dev_info(dev, format, ##arg); \
+} while (0)
#define fbtft_par_dbg(level, par, format, arg...) \
+do { \
if (unlikely(par->debug & level)) \
- dev_info(par->info->device, format, ##arg);
+ dev_info(par->info->device, format, ##arg); \
+} while (0)
#define fbtft_dev_dbg(level, par, dev, format, arg...) \
+do { \
if (unlikely(par->debug & level)) \
- dev_info(dev, format, ##arg);
+ dev_info(dev, format, ##arg); \
+} while (0)
#define fbtft_par_dbg_hex(level, par, dev, type, buf, num, format, arg...) \
- if (unlikely(par->debug & level)) \
- fbtft_dbg_hex(dev, sizeof(type), buf, num * sizeof(type), format, ##arg);
+do { \
+ if (unlikely(par->debug & level)) \
+ fbtft_dbg_hex(dev, sizeof(type), buf, num * sizeof(type), format, ##arg); \
+} while (0)
#endif /* __LINUX_FBTFT_H */
View
16 fbtft_device.c
@@ -105,13 +105,14 @@ module_param(buswidth, uint, 0);
MODULE_PARM_DESC(buswidth, "Display bus width, used with the custom argument");
static int init[FBTFT_MAX_INIT_SEQUENCE];
-static int init_num = 0;
+static int init_num;
module_param_array(init, int, &init_num, 0);
MODULE_PARM_DESC(init, "Init sequence, used with the custom argument");
-static unsigned long debug = 0;
+static unsigned long debug;
module_param(debug, ulong , 0);
-MODULE_PARM_DESC(debug,"level: 0-7 (the remaining 29 bits is for advanced usage)");
+MODULE_PARM_DESC(debug,
+"level: 0-7 (the remaining 29 bits is for advanced usage)");
static unsigned verbose = 3;
module_param(verbose, uint, 0);
@@ -749,7 +750,7 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len)
u16 data;
int i;
#ifndef DO_NOT_OPTIMIZE_FBTFT_WRITE_GPIO
- static u16 prev_data = 0;
+ static u16 prev_data;
#endif
fbtft_par_dbg(DEBUG_WRITE, par, "%s(len=%d)\n", __func__, len);
@@ -765,15 +766,16 @@ static int write_gpio16_wr_slow(struct fbtft_par *par, void *buf, size_t len)
if (data == prev_data) {
gpio_set_value(par->gpio.wr, 0); /* used as delay */
} else {
- for (i=0;i<16;i++) {
+ for (i = 0; i < 16; i++) {
if ((data & 1) != (prev_data & 1))
- gpio_set_value(par->gpio.db[i], (data & 1));
+ gpio_set_value(par->gpio.db[i],
+ (data & 1));
data >>= 1;
prev_data >>= 1;
}
}
#else
- for (i=0;i<16;i++) {
+ for (i = 0; i < 16; i++) {
gpio_set_value(par->gpio.db[i], (data & 1));
data >>= 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.