Commit 5cf79371 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Greg Kroah-Hartman

Staging: fbtft: Fix too many leading tabs warning

This is a patch to the fb_agm1264k-fl.c file that fixes up the following
issue:

WARNING: Too many leading tabs - consider code refactoring

Add new function iterate_diffusion_matrix() to refactor a piece of code
inside write_vmem().
Signed-off-by: default avatarGustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9f8e0562
...@@ -264,6 +264,39 @@ construct_line_bitmap(struct fbtft_par *par, u8 *dest, signed short *src, ...@@ -264,6 +264,39 @@ construct_line_bitmap(struct fbtft_par *par, u8 *dest, signed short *src,
} }
} }
static void iterate_diffusion_matrix(u32 xres, u32 yres, int x,
int y, signed short *convert_buf,
signed short pixel, signed short error)
{
u16 i, j;
/* diffusion matrix row */
for (i = 0; i < DIFFUSING_MATRIX_WIDTH; ++i)
/* diffusion matrix column */
for (j = 0; j < DIFFUSING_MATRIX_HEIGHT; ++j) {
signed short *write_pos;
signed char coeff;
/* skip pixels out of zone */
if (x + i < 0 || x + i >= xres || y + j >= yres)
continue;
write_pos = &convert_buf[(y + j) * xres + x + i];
coeff = diffusing_matrix[i][j];
if (-1 == coeff)
/* pixel itself */
*write_pos = pixel;
else {
signed short p = *write_pos + error * coeff;
if (p > WHITE)
p = WHITE;
if (p < BLACK)
p = BLACK;
*write_pos = p;
}
}
}
static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
{ {
u16 *vmem16 = (u16 *)par->info->screen_buffer; u16 *vmem16 = (u16 *)par->info->screen_buffer;
...@@ -303,7 +336,6 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -303,7 +336,6 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
signed short error_b = pixel - BLACK; signed short error_b = pixel - BLACK;
signed short error_w = pixel - WHITE; signed short error_w = pixel - WHITE;
signed short error; signed short error;
u16 i, j;
/* what color close? */ /* what color close? */
if (abs(error_b) >= abs(error_w)) { if (abs(error_b) >= abs(error_w)) {
...@@ -318,36 +350,10 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) ...@@ -318,36 +350,10 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
error /= 8; error /= 8;
/* diffusion matrix row */ iterate_diffusion_matrix(par->info->var.xres,
for (i = 0; i < DIFFUSING_MATRIX_WIDTH; ++i) par->info->var.yres,
/* diffusion matrix column */ x, y, convert_buf,
for (j = 0; j < DIFFUSING_MATRIX_HEIGHT; ++j) { pixel, error);
signed short *write_pos;
signed char coeff;
/* skip pixels out of zone */
if (x + i < 0 ||
x + i >= par->info->var.xres
|| y + j >= par->info->var.yres)
continue;
write_pos = &convert_buf[
(y + j) * par->info->var.xres +
x + i];
coeff = diffusing_matrix[i][j];
if (coeff == -1)
/* pixel itself */
*write_pos = pixel;
else {
signed short p = *write_pos +
error * coeff;
if (p > WHITE)
p = WHITE;
if (p < BLACK)
p = BLACK;
*write_pos = p;
}
}
} }
/* 1 string = 2 pages */ /* 1 string = 2 pages */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment