Staging: fbtft: Move variable declarations to improve codestyle
Subsystems (2)
PATCH 1/1 Staging: fbtft: Move variable declarations to improve codestyle
Move variable declarations, use typedefs to define variables and reindent code to improve compactness and readability.
Signed-off-by Vatika Harlalka <[email protected]>
--- drivers/staging/fbtft/fb_agm1264k-fl.c | 39 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-)
drivers/staging/fbtft/fb_agm1264k-fl.c +18 -21
@@ -33,13 +33,13 @@#define WIDTH 64#define HEIGHT 64#define TOTALWIDTH (WIDTH * 2)/* because 2 x ks0108 in one display */ -#define FPS 20 +#define FPS 20#define EPIN gpio.wr -#define RS gpio.dc -#define RW gpio.aux[2] -#define CS0 gpio.aux[0] -#define CS1 gpio.aux[1] +#define RS gpio.dc +#define RW gpio.aux[2] +#define CS0 gpio.aux[0] +#define CS1 gpio.aux[1]/* diffusing error (�Floyd-Steinberg�) */
@@ -275,22 +275,25 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) {u16 *vmem16 = (u16 *)par->info->screen_base;u8 *buf = par->txbuf.buf; +u16 i, j, b, g, r;int x, y;int ret =0 ; +s16 pixel, error_b, error_w, error, *write_pos; +s8 coeff;/* buffer to convert RGB565 -> grayscale16 -> Ditherd image 1bpp */ -signed short *convert_buf =kmalloc (par->info->var.xres * +s16 *convert_buf =kmalloc (par->info->var.xres * par->info->var.yres *sizeof (signed short ),GFP_NOIO ); -fbtft_par_dbg (DEBUG_WRITE_VMEM , par,"%s()\n" , __func__);/* converting to grayscale16 */ for (x =0 ; x < par->info->var.xres; ++x)for (y =0 ; y < par->info->var.yres; ++y) {u16 pixel = vmem16[y * par->info->var.xres + x]; -u16 b = pixel &0x1f ; -u16 g = (pixel & (0x3f <<5 )) >>5 ; -u16 r = (pixel & (0x1f << (5 +6 ))) >> (5 +6 ); + + b = pixel &0x1f ; + g = (pixel & (0x3f <<5 )) >>5 ; + r = (pixel & (0x1f << (5 +6 ))) >> (5 +6 ); pixel = (299 * r +587 * g +114 * b) /200 ;if (pixel >255 )
@@ -304,12 +307,9 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)/* Image Dithering */ for (x =0 ; x < par->info->var.xres; ++x)for (y =0 ; y < par->info->var.yres; ++y) { -signed short pixel = - convert_buf[y * par->info->var.xres + x]; -signed short error_b = pixel -BLACK ; -signed short error_w = pixel -WHITE ; -signed short error; -u16 i, j; + pixel = convert_buf[y * par->info->var.xres + x]; + error_b = pixel -BLACK ; + error_w = pixel -WHITE ;/* what color close? */ if (abs (error_b) >=abs (error_w)) {
@@ -328,8 +328,6 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)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 ||
@@ -412,15 +410,14 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)static int write (struct fbtft_par *par,void *buf,size_t len) { +u8 i, data; +fbtft_par_dbg_hex (DEBUG_WRITE , par, par->info->device, u8, buf, len,"%s(len=%d): " , __func__, len);gpio_set_value (par->RW,0 );/* set write mode */ -while (len--) { -u8 i, data; - data = *(u8 *) buf++;/* set data bus */
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 50 lines · Vatika Harlalka
Move variable declarations, use typedefs to define variables and reindent code to improve compactness and readability.
Signed-off-by Vatika Harlalka <[email protected]>--- drivers/staging/fbtft/fb_agm1264k-fl.c | 39 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-)drivers/staging/fbtft/fb_agm1264k-fl.c +9
-7@@ -33,13 +33,13 @@#define WIDTH 64#define HEIGHT 64#define TOTALWIDTH (WIDTH * 2)/* because 2 x ks0108 in one display */ -#define FPS 20 +#define FPS 20#define EPIN gpio.wr -#define RS gpio.dc -#define RW gpio.aux[2] -#define CS0 gpio.aux[0] -#define CS1 gpio.aux[1] +#define RS gpio.dc +#define RW gpio.aux[2] +#define CS0 gpio.aux[0] +#define CS1 gpio.aux[1]/* diffusing error (“Floyd-Steinberg”) */ @@ -275,22 +275,25 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) {u16 *vmem16 = (u16 *)par->info->screen_base;u8 *buf = par->txbuf.buf; +u16 i, j, b, g, r;int x, y;int ret =0 ; +s16 pixel, error_b, error_w, error, *write_pos; +s8 coeff;/* buffer to convert RGB565 -> grayscale16 -> Ditherd image 1bpp */ -signed short *convert_buf =kmalloc (par->info->var.xres * +s16 *convert_buf =kmalloc (par->info->var.xres * par->info->var.yres *sizeof (signed short ),GFP_NOIO ); -fbtft_par_dbg (DEBUG_WRITE_VMEM , par,"%s()\n" , __func__);/* converting to grayscale16 */
drivers/staging/fbtft/fb_agm1264k-fl.c static int write_vmem(struct fbtft_par *par, size_t offset, size_t len) · line 296
Quoted 10 lines
drivers/staging/fbtft/fb_agm1264k-fl.c +4
-3for (x =0 ; x < par->info->var.xres; ++x)for (y =0 ; y < par->info->var.yres; ++y) {u16 pixel = vmem16[y * par->info->var.xres + x]; -u16 b = pixel &0x1f ; -u16 g = (pixel & (0x3f <<5 )) >>5 ; -u16 r = (pixel & (0x1f << (5 +6 ))) >> (5 +6 ); + + b = pixel &0x1f ; + g = (pixel & (0x3f <<5 )) >>5 ; + r = (pixel & (0x1f << (5 +6 ))) >> (5 +6 );
I don't really think this helped out at all. The original code is just fine, no need to change it.
thanks,
greg k-h