Re: [PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Fabio Falzoi
On Sun, Aug 02, 2015 at 07:54:48PM +0200, Noralf Trønnes wrote:
> 
> Seems I wasn't clear enough, you could use my ack if you put
> struct flexfb_lcd_controller inside the driver and not in
> fbtft.h
> 
> 
> Noralf.
> 
>

Sorry Noralf, I misunderstood your review.
I will modify the patch and send an updated version.

Thank you,
Fabio
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Noralf Trønnes


Den 02.08.2015 16:57, skrev Fabio Falzoi:

Use a struct flexfb_lcd_controller to holds chip properties, instead of
relying on a long 'if - else if' chain.
This allows to:
- use a simple linear search to verify if a certain LCD controller
model is supported or not.
- add support for a new LCD chip controller simply defining a new
flexfb_lcd_controller struct.

Signed-off-by: Fabio Falzoi 
Acked-by: Noralf Trønnes 
---


Seems I wasn't clear enough, you could use my ack if you put
struct flexfb_lcd_controller inside the driver and not in
fbtft.h


Noralf.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Fabio Falzoi
Use a struct flexfb_lcd_controller to holds chip properties, instead of
relying on a long 'if - else if' chain.
This allows to:
- use a simple linear search to verify if a certain LCD controller
model is supported or not.
- add support for a new LCD chip controller simply defining a new
flexfb_lcd_controller struct.

Signed-off-by: Fabio Falzoi 
Acked-by: Noralf Trønnes 
---
 drivers/staging/fbtft/fbtft.h  |  20 
 drivers/staging/fbtft/flexfb.c | 203 ++---
 2 files changed, 127 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index 7d817eb..c96c06b 100644
--- a/drivers/staging/fbtft/fbtft.h
+++ b/drivers/staging/fbtft/fbtft.h
@@ -256,6 +256,26 @@ struct fbtft_par {
void *extra;
 };
 
+/**
+ * struct flexfb_lcd_controller - Describes the LCD controller properties
+ * @name: Model name of the chip
+ * @width: Width of display in pixels
+ * @height: Height of display in pixels
+ * @setaddrwin: Which set_addr_win() implementation to use
+ * @regwidth: LCD Controller Register width in bits
+ * @init_seq: LCD initialization sequence
+ * @init_seq_sz: Size of LCD initialization sequence
+ */
+struct flexfb_lcd_controller {
+   const char *name;
+   unsigned int width;
+   unsigned int height;
+   unsigned int setaddrwin;
+   unsigned int regwidth;
+   int *init_seq;
+   int init_seq_sz;
+};
+
 #define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))
 
 #define write_reg(par, ...)  \
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index ce6e3ae..e70678f 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -126,6 +126,80 @@ static int ssd1351_init[] = { -1, 0xfd, 0x12, -1, 0xfd, 
0xb1, -1, 0xae, -1, 0xb3
  -1, 0xab, 0x01, -1, 0xb1, 0x32, -1, 0xb4, 0xa0, 
0xb5, 0x55, -1, 0xbb, 0x17, -1, 0xbe, 0x05,
  -1, 0xc1, 0xc8, 0x80, 0xc8, -1, 0xc7, 0x0f, -1, 
0xb6, 0x01, -1, 0xa6, -1, 0xaf, -3 };
 
+static const struct flexfb_lcd_controller flexfb_chip_table[] = {
+   {
+   .name = "st7735r",
+   .width = 120,
+   .height = 160,
+   .init_seq = st7735r_init,
+   .init_seq_sz = ARRAY_SIZE(st7735r_init),
+   }, {
+   .name = "hx8340bn",
+   .width = 176,
+   .height = 220,
+   .init_seq = hx8340bn_init,
+   .init_seq_sz = ARRAY_SIZE(hx8340bn_init),
+   }, {
+   .name = "ili9225",
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = "ili9225",
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = "ili9225",
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = "ili9320",
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 1,
+   .regwidth = 16,
+   .init_seq = ili9320_init,
+   .init_seq_sz = ARRAY_SIZE(ili9320_init),
+   }, {
+   .name = "ili9325",
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 1,
+   .regwidth = 16,
+   .init_seq = ili9325_init,
+   .init_seq_sz = ARRAY_SIZE(ili9325_init),
+   }, {
+   .name = "ili9341",
+   .width = 240,
+   .height = 320,
+   .init_seq = ili9341_init,
+   .init_seq_sz = ARRAY_SIZE(ili9341_init),
+   }, {
+   .name = "ssd1289",
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 2,
+   .regwidth = 16,
+   .init_seq = ssd1289_init,
+   .init_seq_sz = ARRAY_SIZE(ssd1289_init),
+   }, {
+   .name = "ssd1351",
+   .width = 128,
+   .height = 128,
+   .setaddrwin = 3,
+   .init_seq = ssd1351_init,
+   .init_seq_sz = ARRAY_SIZE(ssd1351_init),
+   },
+};
+
 /* ili9320, ili9325 */
 static void flexfb_set_addr_win_1(struct fbtft_par *par,
  int xs, int ys, int xe, int ye)
@@ -247,8 +321,38 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par)
return 0;
 }
 
+static void flexfb_chip_load_param(const struct flexfb_lcd_controller *chip)
+{
+   if (!width)
+   width = chip->width;
+   if 

[PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Fabio Falzoi
Use a struct flexfb_lcd_controller to holds chip properties, instead of
relying on a long 'if - else if' chain.
This allows to:
- use a simple linear search to verify if a certain LCD controller
model is supported or not.
- add support for a new LCD chip controller simply defining a new
flexfb_lcd_controller struct.

Signed-off-by: Fabio Falzoi fabio.falzo...@gmail.com
Acked-by: Noralf Trønnes nor...@tronnes.org
---
 drivers/staging/fbtft/fbtft.h  |  20 
 drivers/staging/fbtft/flexfb.c | 203 ++---
 2 files changed, 127 insertions(+), 96 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft.h b/drivers/staging/fbtft/fbtft.h
index 7d817eb..c96c06b 100644
--- a/drivers/staging/fbtft/fbtft.h
+++ b/drivers/staging/fbtft/fbtft.h
@@ -256,6 +256,26 @@ struct fbtft_par {
void *extra;
 };
 
+/**
+ * struct flexfb_lcd_controller - Describes the LCD controller properties
+ * @name: Model name of the chip
+ * @width: Width of display in pixels
+ * @height: Height of display in pixels
+ * @setaddrwin: Which set_addr_win() implementation to use
+ * @regwidth: LCD Controller Register width in bits
+ * @init_seq: LCD initialization sequence
+ * @init_seq_sz: Size of LCD initialization sequence
+ */
+struct flexfb_lcd_controller {
+   const char *name;
+   unsigned int width;
+   unsigned int height;
+   unsigned int setaddrwin;
+   unsigned int regwidth;
+   int *init_seq;
+   int init_seq_sz;
+};
+
 #define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))
 
 #define write_reg(par, ...)  \
diff --git a/drivers/staging/fbtft/flexfb.c b/drivers/staging/fbtft/flexfb.c
index ce6e3ae..e70678f 100644
--- a/drivers/staging/fbtft/flexfb.c
+++ b/drivers/staging/fbtft/flexfb.c
@@ -126,6 +126,80 @@ static int ssd1351_init[] = { -1, 0xfd, 0x12, -1, 0xfd, 
0xb1, -1, 0xae, -1, 0xb3
  -1, 0xab, 0x01, -1, 0xb1, 0x32, -1, 0xb4, 0xa0, 
0xb5, 0x55, -1, 0xbb, 0x17, -1, 0xbe, 0x05,
  -1, 0xc1, 0xc8, 0x80, 0xc8, -1, 0xc7, 0x0f, -1, 
0xb6, 0x01, -1, 0xa6, -1, 0xaf, -3 };
 
+static const struct flexfb_lcd_controller flexfb_chip_table[] = {
+   {
+   .name = st7735r,
+   .width = 120,
+   .height = 160,
+   .init_seq = st7735r_init,
+   .init_seq_sz = ARRAY_SIZE(st7735r_init),
+   }, {
+   .name = hx8340bn,
+   .width = 176,
+   .height = 220,
+   .init_seq = hx8340bn_init,
+   .init_seq_sz = ARRAY_SIZE(hx8340bn_init),
+   }, {
+   .name = ili9225,
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = ili9225,
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = ili9225,
+   .width = 176,
+   .height = 220,
+   .regwidth = 16,
+   .init_seq = ili9225_init,
+   .init_seq_sz = ARRAY_SIZE(ili9225_init),
+   }, {
+   .name = ili9320,
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 1,
+   .regwidth = 16,
+   .init_seq = ili9320_init,
+   .init_seq_sz = ARRAY_SIZE(ili9320_init),
+   }, {
+   .name = ili9325,
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 1,
+   .regwidth = 16,
+   .init_seq = ili9325_init,
+   .init_seq_sz = ARRAY_SIZE(ili9325_init),
+   }, {
+   .name = ili9341,
+   .width = 240,
+   .height = 320,
+   .init_seq = ili9341_init,
+   .init_seq_sz = ARRAY_SIZE(ili9341_init),
+   }, {
+   .name = ssd1289,
+   .width = 240,
+   .height = 320,
+   .setaddrwin = 2,
+   .regwidth = 16,
+   .init_seq = ssd1289_init,
+   .init_seq_sz = ARRAY_SIZE(ssd1289_init),
+   }, {
+   .name = ssd1351,
+   .width = 128,
+   .height = 128,
+   .setaddrwin = 3,
+   .init_seq = ssd1351_init,
+   .init_seq_sz = ARRAY_SIZE(ssd1351_init),
+   },
+};
+
 /* ili9320, ili9325 */
 static void flexfb_set_addr_win_1(struct fbtft_par *par,
  int xs, int ys, int xe, int ye)
@@ -247,8 +321,38 @@ static int flexfb_verify_gpios_db(struct fbtft_par *par)
return 0;
 }
 
+static void flexfb_chip_load_param(const struct flexfb_lcd_controller *chip)
+{
+   if (!width)
+   width = 

Re: [PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Noralf Trønnes


Den 02.08.2015 16:57, skrev Fabio Falzoi:

Use a struct flexfb_lcd_controller to holds chip properties, instead of
relying on a long 'if - else if' chain.
This allows to:
- use a simple linear search to verify if a certain LCD controller
model is supported or not.
- add support for a new LCD chip controller simply defining a new
flexfb_lcd_controller struct.

Signed-off-by: Fabio Falzoi fabio.falzo...@gmail.com
Acked-by: Noralf Trønnes nor...@tronnes.org
---


Seems I wasn't clear enough, you could use my ack if you put
struct flexfb_lcd_controller inside the driver and not in
fbtft.h


Noralf.


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] Staging: fbtft: Use a struct to describe each LCD controller

2015-08-02 Thread Fabio Falzoi
On Sun, Aug 02, 2015 at 07:54:48PM +0200, Noralf Trønnes wrote:
 
 Seems I wasn't clear enough, you could use my ack if you put
 struct flexfb_lcd_controller inside the driver and not in
 fbtft.h
 
 
 Noralf.
 


Sorry Noralf, I misunderstood your review.
I will modify the patch and send an updated version.

Thank you,
Fabio
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/