linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset
@ 2020-05-12 20:52 Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:52 ` [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion Rodrigo Rolim Mendes de Alencar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rodrigo Rolim Mendes de Alencar @ 2020-05-12 20:52 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-kernel, maxime.ripard, alencar.fmce, Rodrigo Alencar

This patch provides support for displays like VGM128064B0W10,
which requires a column offset of 2, i.e., its segments starts
in SEG2 and ends in SEG129.

Signed-off-by: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
---
 Documentation/devicetree/bindings/display/ssd1307fb.txt | 1 +
 drivers/video/fbdev/ssd1307fb.c                         | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt
index 27333b9551b3..74a7b228bcef 100644
--- a/Documentation/devicetree/bindings/display/ssd1307fb.txt
+++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt
@@ -23,6 +23,7 @@ Optional properties:
   - solomon,com-lrremap: Display uses left-right COM pin remap
   - solomon,com-invdir: Display uses inverted COM pin scan direction
   - solomon,com-offset: Number of the COM pin wired to the first display line
+  - solomon,col-offset: Offset of columns (SEG) that the screen is mapped to.
   - solomon,prechargep1: Length of deselect period (phase 1) in clock cycles.
   - solomon,prechargep2: Length of precharge period (phase 2) in clock cycles.
                          This needs to be the higher, the higher the capacitance
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 12fa1050f3eb..ac88bbe174b6 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -77,6 +77,7 @@ struct ssd1307fb_par {
 	struct fb_info *info;
 	u8 lookup_table[4];
 	u32 page_offset;
+	u32 col_offset;
 	u32 prechargep1;
 	u32 prechargep2;
 	struct pwm_device *pwm;
@@ -468,11 +469,11 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
-	ret = ssd1307fb_write_cmd(par->client, 0x0);
+	ret = ssd1307fb_write_cmd(par->client, par->col_offset);
 	if (ret < 0)
 		return ret;
 
-	ret = ssd1307fb_write_cmd(par->client, par->width - 1);
+	ret = ssd1307fb_write_cmd(par->client, par->col_offset + par->width - 1);
 	if (ret < 0)
 		return ret;
 
@@ -644,6 +645,9 @@ static int ssd1307fb_probe(struct i2c_client *client,
 	if (of_property_read_u32(node, "solomon,page-offset", &par->page_offset))
 		par->page_offset = 1;
 
+	if (of_property_read_u32(node, "solomon,col-offset", &par->col_offset))
+		par->col_offset = 0;
+
 	if (of_property_read_u32(node, "solomon,com-offset", &par->com_offset))
 		par->com_offset = 0;
 
-- 
2.23.0.rc1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion
  2020-05-12 20:52 [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Rodrigo Rolim Mendes de Alencar
@ 2020-05-12 20:52 ` Rodrigo Rolim Mendes de Alencar
  2020-05-13  7:09   ` Geert Uytterhoeven
  2020-05-12 20:52 ` [PATCH 3/3] video: fbdev: ssd1307fb: Switch to atomic PWM API Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:59 ` [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Andy Shevchenko
  2 siblings, 1 reply; 5+ messages in thread
From: Rodrigo Rolim Mendes de Alencar @ 2020-05-12 20:52 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-kernel, maxime.ripard, alencar.fmce, Rodrigo Alencar

Pixel inversion in hardware is performed by issuing the
command 0xa7. This patch adds a boolean  property to control
color inversion.

Signed-off-by: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
---
 .../devicetree/bindings/display/ssd1307fb.txt         |  1 +
 drivers/video/fbdev/ssd1307fb.c                       | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt
index 74a7b228bcef..3076b71ede68 100644
--- a/Documentation/devicetree/bindings/display/ssd1307fb.txt
+++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt
@@ -22,6 +22,7 @@ Optional properties:
   - solomon,com-seq: Display uses sequential COM pin configuration
   - solomon,com-lrremap: Display uses left-right COM pin remap
   - solomon,com-invdir: Display uses inverted COM pin scan direction
+  - solomon,color-inv: Set Inverse display mode (invert pixel color)
   - solomon,com-offset: Number of the COM pin wired to the first display line
   - solomon,col-offset: Offset of columns (SEG) that the screen is mapped to.
   - solomon,prechargep1: Length of deselect period (phase 1) in clock cycles.
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index ac88bbe174b6..748c21c0567b 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -31,8 +31,9 @@
 #define SSD1307FB_SET_LOOKUP_TABLE	0x91
 #define	SSD1307FB_CHARGE_PUMP		0x8d
 #define SSD1307FB_SEG_REMAP_ON		0xa1
-#define SSD1307FB_DISPLAY_OFF		0xae
+#define SSD1307FB_DISPLAY_NORMAL	0xa6
 #define SSD1307FB_SET_MULTIPLEX_RATIO	0xa8
+#define SSD1307FB_DISPLAY_OFF		0xae
 #define SSD1307FB_DISPLAY_ON		0xaf
 #define SSD1307FB_START_PAGE_ADDRESS	0xb0
 #define SSD1307FB_SET_DISPLAY_OFFSET	0xd3
@@ -62,6 +63,7 @@ struct ssd1307fb_deviceinfo {
 struct ssd1307fb_par {
 	unsigned area_color_enable : 1;
 	unsigned com_invdir : 1;
+	unsigned color_inv : 1;
 	unsigned com_lrremap : 1;
 	unsigned com_seq : 1;
 	unsigned lookup_table_set : 1;
@@ -492,6 +494,12 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 	if (ret < 0)
 		return ret;
 
+	/* Set normal or inverse */
+	ret = ssd1307fb_write_cmd(par->client,
+				  SSD1307FB_DISPLAY_NORMAL | (par->color_inv & 0x1));
+	if (ret < 0)
+		return ret;
+
 	/* Clear the screen */
 	ssd1307fb_update_display(par);
 
@@ -666,6 +674,7 @@ static int ssd1307fb_probe(struct i2c_client *client,
 	par->com_seq = of_property_read_bool(node, "solomon,com-seq");
 	par->com_lrremap = of_property_read_bool(node, "solomon,com-lrremap");
 	par->com_invdir = of_property_read_bool(node, "solomon,com-invdir");
+	par->color_inv = of_property_read_bool(node, "solomon,color-inv");
 	par->area_color_enable =
 		of_property_read_bool(node, "solomon,area-color-enable");
 	par->low_power = of_property_read_bool(node, "solomon,low-power");
-- 
2.23.0.rc1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] video: fbdev: ssd1307fb: Switch to atomic PWM API
  2020-05-12 20:52 [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:52 ` [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion Rodrigo Rolim Mendes de Alencar
@ 2020-05-12 20:52 ` Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:59 ` [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Rodrigo Rolim Mendes de Alencar @ 2020-05-12 20:52 UTC (permalink / raw)
  To: linux-fbdev; +Cc: linux-kernel, maxime.ripard, alencar.fmce

Signed-off-by: Rodrigo Rolim Mendes de Alencar <alencar.fmce@imbel.gov.br>
---
 drivers/video/fbdev/ssd1307fb.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 748c21c0567b..b1cac4a3722f 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -303,7 +303,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 {
 	int ret;
 	u32 precharge, dclk, com_invdir, compins;
-	struct pwm_args pargs;
+	struct pwm_state pstate;
 
 	if (par->device_info->need_pwm) {
 		par->pwm = pwm_get(&par->client->dev, NULL);
@@ -312,18 +312,18 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
 			return PTR_ERR(par->pwm);
 		}
 
-		/*
-		 * FIXME: pwm_apply_args() should be removed when switching to
-		 * the atomic PWM API.
-		 */
-		pwm_apply_args(par->pwm);
+		pwm_init_state(par->pwm, &pstate);
+		par->pwm_period = pstate.period;
 
-		pwm_get_args(par->pwm, &pargs);
-
-		par->pwm_period = pargs.period;
 		/* Enable the PWM */
-		pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period);
-		pwm_enable(par->pwm);
+		pstate.enabled = true;
+		pstate.duty_cycle = pstate.period / 2;
+
+		ret = pwm_apply_state(par->pwm, &pstate);
+		if (ret) {
+			dev_err(&par->client->dev, "Failed to apply PWM state: %d\n", ret);
+			return ret;
+		}
 
 		dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
 			par->pwm->pwm, par->pwm_period);
-- 
2.23.0.rc1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset
  2020-05-12 20:52 [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:52 ` [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion Rodrigo Rolim Mendes de Alencar
  2020-05-12 20:52 ` [PATCH 3/3] video: fbdev: ssd1307fb: Switch to atomic PWM API Rodrigo Rolim Mendes de Alencar
@ 2020-05-12 20:59 ` Andy Shevchenko
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-05-12 20:59 UTC (permalink / raw)
  To: Rodrigo Rolim Mendes de Alencar
  Cc: linux-fbdev, Linux Kernel Mailing List, maxime.ripard, alencar.fmce

On Tue, May 12, 2020 at 11:55 PM Rodrigo Rolim Mendes de Alencar
<455.rodrigo.alencar@gmail.com> wrote:
>
> This patch provides support for displays like VGM128064B0W10,
> which requires a column offset of 2, i.e., its segments starts
> in SEG2 and ends in SEG129.

Thank you!

>         if (of_property_read_u32(node, "solomon,page-offset", &par->page_offset))
>                 par->page_offset = 1;
>
> +       if (of_property_read_u32(node, "solomon,col-offset", &par->col_offset))
> +               par->col_offset = 0;
> +
>         if (of_property_read_u32(node, "solomon,com-offset", &par->com_offset))
>                 par->com_offset = 0;

Needs to be rebased on top of latest changes (can be, in particular,
found in Linux Next tree).

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion
  2020-05-12 20:52 ` [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion Rodrigo Rolim Mendes de Alencar
@ 2020-05-13  7:09   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2020-05-13  7:09 UTC (permalink / raw)
  To: Rodrigo Rolim Mendes de Alencar
  Cc: Linux Fbdev development list, Linux Kernel Mailing List,
	Maxime Ripard, alencar.fmce

Hi Rodrigo,

On Tue, May 12, 2020 at 10:53 PM Rodrigo Rolim Mendes de Alencar
<455.rodrigo.alencar@gmail.com> wrote:
> Pixel inversion in hardware is performed by issuing the
> command 0xa7. This patch adds a boolean  property to control
> color inversion.
>
> Signed-off-by: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>

Thanks for your patch!

> --- a/Documentation/devicetree/bindings/display/ssd1307fb.txt
> +++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt
> @@ -22,6 +22,7 @@ Optional properties:
>    - solomon,com-seq: Display uses sequential COM pin configuration
>    - solomon,com-lrremap: Display uses left-right COM pin remap
>    - solomon,com-invdir: Display uses inverted COM pin scan direction
> +  - solomon,color-inv: Set Inverse display mode (invert pixel color)

Isn't that software configuration instead of hard description?
DT describes the hardware, not software configuration, so this may not
belong here?

>    - solomon,com-offset: Number of the COM pin wired to the first display line
>    - solomon,col-offset: Offset of columns (SEG) that the screen is mapped to.
>    - solomon,prechargep1: Length of deselect period (phase 1) in clock cycles.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-13  7:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 20:52 [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Rodrigo Rolim Mendes de Alencar
2020-05-12 20:52 ` [PATCH 2/3] video: fbdev: ssd1307fb: Support to pixel inversion Rodrigo Rolim Mendes de Alencar
2020-05-13  7:09   ` Geert Uytterhoeven
2020-05-12 20:52 ` [PATCH 3/3] video: fbdev: ssd1307fb: Switch to atomic PWM API Rodrigo Rolim Mendes de Alencar
2020-05-12 20:59 ` [PATCH 1/3] video: fbdev: ssd1307fb: Added support to Column offset Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).