[PATCH v5 3/3] drm/panel-simple: allow LVDS format override

2023-09-29 Thread Johannes Zink
Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

  v4 -> v5: none

  v3 -> v4: - worked in Dan's feedback (thanks for reviewing my work):
- return with a proper error in case the call to
  panel_simple_override_nondefault_lvds_datamapping()
  fails
- drop the unneeded and ambiguous ret variable

  v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
  my work):
- extract fixing up the bus format to separate
  function
- only call function on LVDS panels
- fix typos found by Laurent
- simplified error handling

  v1 -> v2: - fix missing unwind goto found by test robot
  Reported-by: kernel test robot 
  Reported-by: Dan Carpenter 
  Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
 drivers/gpu/drm/panel/panel-simple.c | 53 
 1 file changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 857bc01591db..4195cf54934b 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -549,6 +550,51 @@ static void panel_simple_parse_panel_timing_node(struct 
device *dev,
dev_err(dev, "Reject override mode: No display_timing found\n");
 }
 
+static int panel_simple_override_nondefault_lvds_datamapping(struct device 
*dev,
+struct 
panel_simple *panel)
+{
+   int ret, bpc;
+
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret < 0) {
+   if (ret == -EINVAL)
+   dev_warn(dev, "Ignore invalid data-mapping property\n");
+
+   /*
+* Ignore non-existing or malformatted property, fallback to
+* default data-mapping, and return 0.
+*/
+   return 0;
+   }
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (panel->desc->bpc != bpc || panel->desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, panel->desc, 
sizeof(*panel->desc), GFP_KERNEL);
+   if (!override_desc)
+   return -ENOMEM;
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+
+   return 0;
+}
+
 static int panel_simple_probe(struct device *dev, const struct panel_desc 
*desc)
 {
struct panel_simple *panel;
@@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+   if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {
+   /* Optional data-mapping property for overriding bus format */
+   err = panel_simple_override_nondefault_lvds_datamapping(dev, 
panel);
+   if (err)
+   goto free_ddc;
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {

-- 
2.39.2



[PATCH v5 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-09-29 Thread Johannes Zink
Some Displays support more than just a single default LVDS data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus, use
it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Reviewed-by: Conor Dooley 
Signed-off-by: Johannes Zink 

---

Changes:

v4 -> v5: none, re-added lost reviewed-by tag

v3 -> v4: none

v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
my work): fix typos in commit message

v1 -> v2: - worked in Rob's review findings (thanks for reviewing my
work): use extracted common property instead of duplicating
the property
  - refined commit message
  - add an example dts for automated checking
---
 .../bindings/display/panel/panel-simple.yaml   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 50143fe67471..81ac402ceed1 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -21,9 +21,9 @@ description: |
 
 allOf:
   - $ref: panel-common.yaml#
+  - $ref: ../lvds-data-mapping.yaml#
 
 properties:
-
   compatible:
 enum:
 # compatible must be listed in alphabetical order, ordered by compatible.
@@ -359,6 +359,17 @@ properties:
   power-supply: true
   no-hpd: true
   hpd-gpios: true
+  data-mapping: true
+
+if:
+  not:
+properties:
+  compatible:
+contains:
+  const: innolux,g101ice-l01
+then:
+  properties:
+data-mapping: false
 
 additionalProperties: false
 
@@ -378,3 +389,16 @@ examples:
 };
   };
 };
+  - |
+panel_lvds: panel-lvds {
+  compatible = "innolux,g101ice-l01";
+  power-supply = <_lcd_reg>;
+
+  data-mapping = "jeida-24";
+
+  port {
+panel_in_lvds: endpoint {
+  remote-endpoint = <_out_lvds>;
+};
+  };
+};

-- 
2.39.2



[PATCH v5 1/3] dt-bindings: display: move LVDS data-mapping definition to separate file

2023-09-29 Thread Johannes Zink
As the LVDS data-mapping property is required in multiple bindings: move
it to separate file and include instead of duplicating it.

Reviewed-by: Conor Dooley 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Johannes Zink 
---

Changes:

v4 -> v5: none, but are-dded the reviewed-bys from v2, that were missing in

v3 -> v4: none

v2 -> v3: worked in Conor's and Laurent's review findings (thank you
  for reviewing my work): drop +| on description

v1 -> v2: worked in Rob's review findings (thank you for reviewing my
  work): extract common properties to
  file and include it instead of duplicating it
---
 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 2 files changed, 93 insertions(+), 68 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml 
b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
new file mode 100644
index ..d68982fe2e9b
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/lvds-data-mapping.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LVDS Data Mapping
+
+maintainers:
+  - Laurent Pinchart 
+  - Thierry Reding 
+
+description: |
+  LVDS is a physical layer specification defined in ANSI/TIA/EIA-644-A. 
Multiple
+  incompatible data link layers have been used over time to transmit image data
+  to LVDS devices. This bindings supports devices compatible with the following
+  specifications.
+
+  [JEIDA] "Digital Interface Standards for Monitor", JEIDA-59-1999, February
+  1999 (Version 1.0), Japan Electronic Industry Development Association (JEIDA)
+  [LDI] "Open LVDS Display Interface", May 1999 (Version 0.95), National
+  Semiconductor
+  [VESA] "VESA Notebook Panel Standard", October 2007 (Version 1.0), Video
+  Electronics Standards Association (VESA)
+
+  Device compatible with those specifications have been marketed under the
+  FPD-Link and FlatLink brands.
+
+properties:
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__&

[PATCH v5 0/3] Support non-default LVDS data mapping for simple panel

2023-09-29 Thread Johannes Zink
Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series moves the data-mapping property for LVDS panels in a
separate file and optionally adds it to simple-panel when matching to
the innolux,g101ice-l01 compatible. This property allows to override
the default data mapping set in the panel description in simple-panel.

The last patch in this series actually adds the driver support for
parsing the data format override device tree property and modifying the
corresponding values for bit per color and media bus format in the panel
descriptor.

Best regards
Johannes

---

Changelog:

v4 -> v5:  - no changes, but added the reviewed-by-tags from v3 that
 were lost in v3/v4
   - Link to v4: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v4-0-e6e7011f3...@pengutronix.de

v3 -> v4:  - driver: worked in Dan's Feedback:
 - return with proper error in case the call into
   panel_simple_override_nondefault_lvds_datamapping()
   failed
 - drop the unneeded and ambiguous ret local value
- Link to v3: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v3-0-78ede374d...@pengutronix.de

v2 -> v3:  - dt bindings: Worked in Conor's and Laurent's Feedback
 (thanks for your review): Drop the chomping indicator
   - dt bindings: Worked in Laurent's Feedback: fix typos
   - driver: worked in Laurent's review findings:
 - extract function for fixing up the bus format
 - only call this function on LVDS panels
 - fix typo
   - Link to v2: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0...@pengutronix.de

v1 -> v2:  - dt bindings: Worked in Rob's review findings (thanks for your
 review), refactored to use common include instead of duplication
   - driver: added missing error unwinding goto, as found by Dan
 Carpenter's test robot:
 Reported-by: kernel test robot 
 Reported-by: Dan Carpenter 
 Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/

To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Conor Dooley 
To: Laurent Pinchart 
To: Thierry Reding 
To: Neil Armstrong 
To: Sam Ravnborg 
Cc: patchwork-...@pengutronix.de
Cc: ker...@pengutronix.de
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Johannes Zink 

---

---
Johannes Zink (3):
  dt-bindings: display: move LVDS data-mapping definition to separate file
  dt-bindings: display: simple: support non-default data-mapping
  drm/panel-simple: allow LVDS format override

 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 .../bindings/display/panel/panel-simple.yaml   | 26 ++-
 drivers/gpu/drm/panel/panel-simple.c   | 53 ++
 4 files changed, 171 insertions(+), 69 deletions(-)
---
base-commit: 79fb229b8810071648b65c37382aea7819a5f935
change-id: 20230523-simplepanel_support_nondefault_datamapping-13c3f2ea28f8

Best regards,
-- 
Johannes Zink 



Re: [PATCH v4 3/3] drm/panel-simple: allow LVDS format override

2023-09-13 Thread Johannes Zink

Hi Dan,

On 9/13/23 13:14, Dan Carpenter wrote:

On Fri, Aug 18, 2023 at 09:04:34AM +0200, Johannes Zink wrote:

Hi Dan,

do you have any input on this for me?



Sorry, I was out of office and the truth is that I'm never going to
catch up on all the email I missed.  :/



nevermind, that's why I sent ping...


Looks okay to me.  I can't remember what I said about this code in v3
but it looks good now.  I'm not a DRM dev so I'm not sure my review
counts for much.  


IIRC it was a mistake I made with a return value that I have fixed in v4.

You should always just assume that if I'm quiet

then I'm happy.  :)


That's good to know ;-) Thanks for your review!

Johannes



regards,
dan carpenter




--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH v4 0/3] Support non-default LVDS data mapping for simple panel

2023-09-13 Thread Johannes Zink

Hi everyone,

gentle ping - is there any feedback you can give me for moving this series 
forward?

Best regards
Johannes

On 7/28/23 16:16, Johannes Zink wrote:

Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series moves the data-mapping property for LVDS panels in a
separate file and optionally adds it to simple-panel when matching to
the innolux,g101ice-l01 compatible. This property allows to override
the default data mapping set in the panel description in simple-panel.

The last patch in this series actually adds the driver support for
parsing the data format override device tree property and modifying the
corresponding values for bit per color and media bus format in the panel
descriptor.

Best regards
Johannes

---

Changelog:

v3 -> v4:  - driver: worked in Dan's Feedback:
  - return with proper error in case the call into
   panel_simple_override_nondefault_lvds_datamapping()
   failed
 - drop the unneeded and ambiguous ret local value

- Link to v3: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v3-0-78ede374d...@pengutronix.de
v2 -> v3:  - dt bindings: Worked in Conor's and Laurent's Feedback
 (thanks for your review): Drop the chomping indicator
   - dt bindings: Worked in Laurent's Feedback: fix typos
   - driver: worked in Laurent's review findings:
 - extract function for fixing up the bus format
 - only call this function on LVDS panels
 - fix typo
- Link to v2: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0...@pengutronix.de

v1 -> v2:  - dt bindings: Worked in Rob's review findings (thanks for your
  review), refactored to use common include instead of duplication
- driver: added missing error unwinding goto, as found by Dan
  Carpenter's test robot:
  Reported-by: kernel test robot 
  Reported-by: Dan Carpenter 
  Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/

To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Conor Dooley 
To: Laurent Pinchart 
To: Thierry Reding 
To: Neil Armstrong 
To: Sam Ravnborg 
Cc: patchwork-...@pengutronix.de
Cc: ker...@pengutronix.de
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Johannes Zink 

---

---
Johannes Zink (3):
   dt-bindings: display: move LVDS data-mapping definition to separate file
   dt-bindings: display: simple: support non-default data-mapping
   drm/panel-simple: allow LVDS format override

  .../bindings/display/lvds-data-mapping.yaml| 84 ++
  .../devicetree/bindings/display/lvds.yaml  | 77 +++-
  .../bindings/display/panel/panel-simple.yaml   | 26 ++-
  drivers/gpu/drm/panel/panel-simple.c   | 53 ++
  4 files changed, 171 insertions(+), 69 deletions(-)
---
base-commit: 52920704df878050123dfeb469aa6ab8022547c1
change-id: 20230523-simplepanel_support_nondefault_datamapping-13c3f2ea28f8

Best regards,


--
Pengutronix e.K.    | Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH v4 3/3] drm/panel-simple: allow LVDS format override

2023-08-18 Thread Johannes Zink

Hi Dan,

do you have any input on this for me?

Best regards
Johannes

On 7/28/23 16:16, Johannes Zink wrote:

Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

   v3 -> v4: - worked in Dan's feedback (thanks for reviewing my work):
 - return with a proper error in case the call to
  panel_simple_override_nondefault_lvds_datamapping()
  fails
 - drop the unneeded and ambiguous ret variable

   v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
   my work):
- extract fixing up the bus format to separate
  function
- only call function on LVDS panels
- fix typos found by Laurent
- simplified error handling

   v1 -> v2: - fix missing unwind goto found by test robot
   Reported-by: kernel test robot 
   Reported-by: Dan Carpenter 
   Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
  drivers/gpu/drm/panel/panel-simple.c | 53 
  1 file changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4badda6570d5..3a164931093e 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
  #include 
  #include 
  #include 
+#include 
  
  /**

   * struct panel_desc - Describes a simple panel.
@@ -549,6 +550,51 @@ static void panel_simple_parse_panel_timing_node(struct 
device *dev,
dev_err(dev, "Reject override mode: No display_timing found\n");
  }
  
+static int panel_simple_override_nondefault_lvds_datamapping(struct device *dev,

+struct 
panel_simple *panel)
+{
+   int ret, bpc;
+
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret < 0) {
+   if (ret == -EINVAL)
+   dev_warn(dev, "Ignore invalid data-mapping property\n");
+
+   /*
+* Ignore non-existing or malformatted property, fallback to
+* default data-mapping, and return 0.
+*/
+   return 0;
+   }
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (panel->desc->bpc != bpc || panel->desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, panel->desc, 
sizeof(*panel->desc), GFP_KERNEL);
+   if (!override_desc)
+   return -ENOMEM;
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+
+   return 0;
+}
+
  static int panel_simple_probe(struct device *dev, const struct panel_desc 
*desc)
  {
struct panel_simple *panel;
@@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
  
+	if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {

+   /* Optional data-mapping property for overriding bus format */
+   err = panel_simple_override_nondefault_lvds_datamapping(dev, 
panel);
+   if (err)
+   goto free_ddc;
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
    switch (connector_type) {



--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH v4 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-07-31 Thread Johannes Zink

Hi Conor,

On 7/29/23 12:19, Conor Dooley wrote:

On Fri, Jul 28, 2023 at 04:16:56PM +0200, Johannes Zink wrote:

Some Displays support more than just a single default LVDS data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus, use
it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Signed-off-by: Johannes Zink 

---

Changes:

v3 -> v4: none

v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
my work): fix typos in commit message


I gave you one for this patch too, no? > 
https://lore.kernel.org/all/20230523-jaywalker-modify-500ec1d79223@spud/
Any reason in particular you didn't pick up the tags? Here it is
against, since all that appears to have changed is some typos.


sorry, I forgot to add the Tags, There is no functional changes in patch 1-3 of 
4.

Johannes



Reviewed-by: Conor Dooley 




--
Pengutronix e.K.    | Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



[PATCH v4 1/3] dt-bindings: display: move LVDS data-mapping definition to separate file

2023-07-28 Thread Johannes Zink
As the LVDS data-mapping property is required in multiple bindings: move
it to separate file and include instead of duplicating it.

Signed-off-by: Johannes Zink 

---

Changes:

v3 -> v4: none

v2 -> v3: worked in Conor's and Laurent's review findings (thank you
  for reviewing my work): drop +| on description

v1 -> v2: worked in Rob's review findings (thank you for reviewing my
  work): extract common properties to
  file and include it instead of duplicating it
---
 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 2 files changed, 93 insertions(+), 68 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml 
b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
new file mode 100644
index ..d68982fe2e9b
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/lvds-data-mapping.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LVDS Data Mapping
+
+maintainers:
+  - Laurent Pinchart 
+  - Thierry Reding 
+
+description: |
+  LVDS is a physical layer specification defined in ANSI/TIA/EIA-644-A. 
Multiple
+  incompatible data link layers have been used over time to transmit image data
+  to LVDS devices. This bindings supports devices compatible with the following
+  specifications.
+
+  [JEIDA] "Digital Interface Standards for Monitor", JEIDA-59-1999, February
+  1999 (Version 1.0), Japan Electronic Industry Development Association (JEIDA)
+  [LDI] "Open LVDS Display Interface", May 1999 (Version 0.95), National
+  Semiconductor
+  [VESA] "VESA Notebook Panel Standard", October 2007 (Version 1.0), Video
+  Electronics Standards Association (VESA)
+
+  Device compatible with those specifications have been marketed under the
+  FPD-Link and FlatLink brands.
+
+properties:
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6__><__G7__><__G6__><__R7__>&l

[PATCH v4 3/3] drm/panel-simple: allow LVDS format override

2023-07-28 Thread Johannes Zink
Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

  v3 -> v4: - worked in Dan's feedback (thanks for reviewing my work):
- return with a proper error in case the call to
  panel_simple_override_nondefault_lvds_datamapping()
  fails
- drop the unneeded and ambiguous ret variable

  v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
  my work):
- extract fixing up the bus format to separate
  function
- only call function on LVDS panels
- fix typos found by Laurent
- simplified error handling

  v1 -> v2: - fix missing unwind goto found by test robot
  Reported-by: kernel test robot 
  Reported-by: Dan Carpenter 
  Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
 drivers/gpu/drm/panel/panel-simple.c | 53 
 1 file changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4badda6570d5..3a164931093e 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -549,6 +550,51 @@ static void panel_simple_parse_panel_timing_node(struct 
device *dev,
dev_err(dev, "Reject override mode: No display_timing found\n");
 }
 
+static int panel_simple_override_nondefault_lvds_datamapping(struct device 
*dev,
+struct 
panel_simple *panel)
+{
+   int ret, bpc;
+
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret < 0) {
+   if (ret == -EINVAL)
+   dev_warn(dev, "Ignore invalid data-mapping property\n");
+
+   /*
+* Ignore non-existing or malformatted property, fallback to
+* default data-mapping, and return 0.
+*/
+   return 0;
+   }
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (panel->desc->bpc != bpc || panel->desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, panel->desc, 
sizeof(*panel->desc), GFP_KERNEL);
+   if (!override_desc)
+   return -ENOMEM;
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+
+   return 0;
+}
+
 static int panel_simple_probe(struct device *dev, const struct panel_desc 
*desc)
 {
struct panel_simple *panel;
@@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+   if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {
+   /* Optional data-mapping property for overriding bus format */
+   err = panel_simple_override_nondefault_lvds_datamapping(dev, 
panel);
+   if (err)
+   goto free_ddc;
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {

-- 
2.39.2



[PATCH v4 0/3] Support non-default LVDS data mapping for simple panel

2023-07-28 Thread Johannes Zink
Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series moves the data-mapping property for LVDS panels in a
separate file and optionally adds it to simple-panel when matching to
the innolux,g101ice-l01 compatible. This property allows to override
the default data mapping set in the panel description in simple-panel.

The last patch in this series actually adds the driver support for
parsing the data format override device tree property and modifying the
corresponding values for bit per color and media bus format in the panel
descriptor.

Best regards
Johannes

---

Changelog:

v3 -> v4:  - driver: worked in Dan's Feedback:
 - return with proper error in case the call into
   panel_simple_override_nondefault_lvds_datamapping()
   failed
 - drop the unneeded and ambiguous ret local value

- Link to v3: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v3-0-78ede374d...@pengutronix.de
v2 -> v3:  - dt bindings: Worked in Conor's and Laurent's Feedback
 (thanks for your review): Drop the chomping indicator
   - dt bindings: Worked in Laurent's Feedback: fix typos
   - driver: worked in Laurent's review findings:
 - extract function for fixing up the bus format
 - only call this function on LVDS panels
 - fix typo
   - Link to v2: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0...@pengutronix.de

v1 -> v2:  - dt bindings: Worked in Rob's review findings (thanks for your
 review), refactored to use common include instead of duplication
   - driver: added missing error unwinding goto, as found by Dan
 Carpenter's test robot:
 Reported-by: kernel test robot 
 Reported-by: Dan Carpenter 
 Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/

To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Conor Dooley 
To: Laurent Pinchart 
To: Thierry Reding 
To: Neil Armstrong 
To: Sam Ravnborg 
Cc: patchwork-...@pengutronix.de
Cc: ker...@pengutronix.de
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Johannes Zink 

---

---
Johannes Zink (3):
  dt-bindings: display: move LVDS data-mapping definition to separate file
  dt-bindings: display: simple: support non-default data-mapping
  drm/panel-simple: allow LVDS format override

 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 .../bindings/display/panel/panel-simple.yaml   | 26 ++-
 drivers/gpu/drm/panel/panel-simple.c   | 53 ++
 4 files changed, 171 insertions(+), 69 deletions(-)
---
base-commit: 52920704df878050123dfeb469aa6ab8022547c1
change-id: 20230523-simplepanel_support_nondefault_datamapping-13c3f2ea28f8

Best regards,
-- 
Johannes Zink 



[PATCH v4 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-07-28 Thread Johannes Zink
Some Displays support more than just a single default LVDS data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus, use
it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Signed-off-by: Johannes Zink 

---

Changes:

v3 -> v4: none

v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
my work): fix typos in commit message

v1 -> v2: - worked in Rob's review findings (thanks for reviewing my
work): use extracted common property instead of duplicating
the property
  - refined commit message
  - add an example dts for automated checking
---
 .../bindings/display/panel/panel-simple.yaml   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 1d4936fc5182..e25e33f67d71 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -21,9 +21,9 @@ description: |
 
 allOf:
   - $ref: panel-common.yaml#
+  - $ref: ../lvds-data-mapping.yaml#
 
 properties:
-
   compatible:
 enum:
 # compatible must be listed in alphabetical order, ordered by compatible.
@@ -359,6 +359,17 @@ properties:
   power-supply: true
   no-hpd: true
   hpd-gpios: true
+  data-mapping: true
+
+if:
+  not:
+properties:
+  compatible:
+contains:
+  const: innolux,g101ice-l01
+then:
+  properties:
+data-mapping: false
 
 additionalProperties: false
 
@@ -378,3 +389,16 @@ examples:
 };
   };
 };
+  - |
+panel_lvds: panel-lvds {
+  compatible = "innolux,g101ice-l01";
+  power-supply = <_lcd_reg>;
+
+  data-mapping = "jeida-24";
+
+  port {
+panel_in_lvds: endpoint {
+  remote-endpoint = <_out_lvds>;
+};
+  };
+};

-- 
2.39.2



Re: [PATCH v3 3/3] drm/panel-simple: allow LVDS format override

2023-07-28 Thread Johannes Zink

Hi Dan,

thanks for your feedback.

On 7/28/23 14:03, Dan Carpenter wrote:

On Fri, Jul 28, 2023 at 01:54:40PM +0200, Johannes Zink wrote:

@@ -556,7 +602,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;


I don't like this at all...

  
  	panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);

if (!panel)
@@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
  
+	if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {

+   /* Optional data-mapping property for overriding bus format */
+   ret = panel_simple_override_nondefault_lvds_datamapping(dev, 
panel);
+   if (ret)
+   goto free_ddc;


This *looks* like we are returning an error but we aren't.  I think we
should be.  If not then we need to have a discussion about that and
add some comments.



Good catch. This should actually be err instead of ret. This way we'd make sure
to return -ENOMEM from panel_simple_probe() in case an error occured due
to devm_kmemdup failing in panel_simple_override_nondefault_lvds_datamapping().

I'll send a v4 with that fixed.

Thanks for having my back!
Johannes


regards,
dan carpenter


+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {

--
2.39.2





--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



[PATCH v3 0/3] Support non-default LVDS data mapping for simple panel

2023-07-28 Thread Johannes Zink
Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series moves the data-mapping property for LVDS panels in a
separate file and optionally adds it to simple-panel when matching to
the innolux,g101ice-l01 compatible. This property allows to override
the default data mapping set in the panel description in simple-panel.

The last patch in this series actually adds the driver support for
parsing the data format override device tree property and modifying the
corresponding values for bit per color and media bus format in the panel
descriptor.

Best regards
Johannes

---

Changelog:

v2 -> v3:  - dt bindings: Worked in Conor's and Laurent's Feedback
 (thanks for your review): Drop the chomping indicator
   - dt bindings: Worked in Laurent's Feedback: fix typos
   - driver: worked in Laurent's review findings:
 - extract function for fixing up the bus format
 - only call this function on LVDS panels
 - fix typo
   - Link to v2: 
https://lore.kernel.org/r/20230523-simplepanel_support_nondefault_datamapping-v2-0-87196f0d0...@pengutronix.de

v1 -> v2:  - dt bindings: Worked in Rob's review findings (thanks for your
 review), refactored to use common include instead of duplication
   - driver: added missing error unwinding goto, as found by Dan
 Carpenter's test robot:
 Reported-by: kernel test robot 
 Reported-by: Dan Carpenter 
 Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/

To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Conor Dooley 
To: Laurent Pinchart 
To: Thierry Reding 
To: Neil Armstrong 
To: Sam Ravnborg 
Cc: patchwork-...@pengutronix.de
Cc: ker...@pengutronix.de
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Johannes Zink 

---
Johannes Zink (3):
  dt-bindings: display: move LVDS data-mapping definition to separate file
  dt-bindings: display: simple: support non-default data-mapping
  drm/panel-simple: allow LVDS format override

 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 .../bindings/display/panel/panel-simple.yaml   | 26 ++-
 drivers/gpu/drm/panel/panel-simple.c   | 55 +-
 4 files changed, 172 insertions(+), 70 deletions(-)
---
base-commit: 52920704df878050123dfeb469aa6ab8022547c1
change-id: 20230523-simplepanel_support_nondefault_datamapping-13c3f2ea28f8

Best regards,
-- 
Johannes Zink 



[PATCH v3 1/3] dt-bindings: display: move LVDS data-mapping definition to separate file

2023-07-28 Thread Johannes Zink
As the LVDS data-mapping property is required in multiple bindings: move
it to separate file and include instead of duplicating it.

Signed-off-by: Johannes Zink 

---

Changes:
v2 -> v3: worked in Conor's and Laurent's review findings (thank you
  for reviewing my work): drop +| on description

v1 -> v2: worked in Rob's review findings (thank you for reviewing my
  work): extract common properties to
  file and include it instead of duplicating it
---
 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 77 +++-
 2 files changed, 93 insertions(+), 68 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml 
b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
new file mode 100644
index ..d68982fe2e9b
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/lvds-data-mapping.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LVDS Data Mapping
+
+maintainers:
+  - Laurent Pinchart 
+  - Thierry Reding 
+
+description: |
+  LVDS is a physical layer specification defined in ANSI/TIA/EIA-644-A. 
Multiple
+  incompatible data link layers have been used over time to transmit image data
+  to LVDS devices. This bindings supports devices compatible with the following
+  specifications.
+
+  [JEIDA] "Digital Interface Standards for Monitor", JEIDA-59-1999, February
+  1999 (Version 1.0), Japan Electronic Industry Development Association (JEIDA)
+  [LDI] "Open LVDS Display Interface", May 1999 (Version 0.95), National
+  Semiconductor
+  [VESA] "VESA Notebook Panel Standard", October 2007 (Version 1.0), Video
+  Electronics Standards Association (VESA)
+
+  Device compatible with those specifications have been marketed under the
+  FPD-Link and FlatLink brands.
+
+properties:
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6__><__G7__><__G6__><__R7__><__R6__><
+
+ 

[PATCH v3 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-07-28 Thread Johannes Zink
Some Displays support more than just a single default LVDS data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus, use
it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Signed-off-by: Johannes Zink 

---

Changes:

v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
my work): fix typos in commit message

v1 -> v2: - worked in Rob's review findings (thanks for reviewing my
work): use extracted common property instead of duplicating
the property
  - refined commit message
  - add an example dts for automated checking
---
 .../bindings/display/panel/panel-simple.yaml   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 1d4936fc5182..e25e33f67d71 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -21,9 +21,9 @@ description: |
 
 allOf:
   - $ref: panel-common.yaml#
+  - $ref: ../lvds-data-mapping.yaml#
 
 properties:
-
   compatible:
 enum:
 # compatible must be listed in alphabetical order, ordered by compatible.
@@ -359,6 +359,17 @@ properties:
   power-supply: true
   no-hpd: true
   hpd-gpios: true
+  data-mapping: true
+
+if:
+  not:
+properties:
+  compatible:
+contains:
+  const: innolux,g101ice-l01
+then:
+  properties:
+data-mapping: false
 
 additionalProperties: false
 
@@ -378,3 +389,16 @@ examples:
 };
   };
 };
+  - |
+panel_lvds: panel-lvds {
+  compatible = "innolux,g101ice-l01";
+  power-supply = <_lcd_reg>;
+
+  data-mapping = "jeida-24";
+
+  port {
+panel_in_lvds: endpoint {
+  remote-endpoint = <_out_lvds>;
+};
+  };
+};

-- 
2.39.2



[PATCH v3 3/3] drm/panel-simple: allow LVDS format override

2023-07-28 Thread Johannes Zink
Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

  v2 -> v3: - worked in Laurent's review findings (thanks for reviewing
  my work):
- extract fixing up the bus format to separate
  function
- only call function on LVDS panels
- fix typos found by Laurent
- simplified error handling

  v1 -> v2: - fix missing unwind goto found by test robot
  Reported-by: kernel test robot 
  Reported-by: Dan Carpenter 
  Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
 drivers/gpu/drm/panel/panel-simple.c | 55 +++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4badda6570d5..0c25718dcb56 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -549,6 +550,51 @@ static void panel_simple_parse_panel_timing_node(struct 
device *dev,
dev_err(dev, "Reject override mode: No display_timing found\n");
 }
 
+static int panel_simple_override_nondefault_lvds_datamapping(struct device 
*dev,
+struct 
panel_simple *panel)
+{
+   int ret, bpc;
+
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret < 0) {
+   if (ret == -EINVAL)
+   dev_warn(dev, "Ignore invalid data-mapping property\n");
+
+   /*
+* Ignore non-existing or malformatted property, fallback to
+* default data-mapping, and return 0.
+*/
+   return 0;
+   }
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (panel->desc->bpc != bpc || panel->desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, panel->desc, 
sizeof(*panel->desc), GFP_KERNEL);
+   if (!override_desc)
+   return -ENOMEM;
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+
+   return 0;
+}
+
 static int panel_simple_probe(struct device *dev, const struct panel_desc 
*desc)
 {
struct panel_simple *panel;
@@ -556,7 +602,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;
 
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
if (!panel)
@@ -601,6 +647,13 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+   if (desc->connector_type == DRM_MODE_CONNECTOR_LVDS) {
+   /* Optional data-mapping property for overriding bus format */
+   ret = panel_simple_override_nondefault_lvds_datamapping(dev, 
panel);
+   if (ret)
+   goto free_ddc;
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {

-- 
2.39.2



Re: [PATCH v2 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-07-28 Thread Johannes Zink

Hi Laurent,

thank you for your review.

On 6/2/23 17:35, Laurent Pinchart wrote:

Hi Johannes,

Thank you for the patch.

On Tue, May 23, 2023 at 10:19:42AM +0200, Johannes Zink wrote:

Some Displays support more than just a single default lvds data mapping,


s/lvds/LVDS/


ack, gonna fix in V3




which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus: use


s/bus:/bus,/


ack, gonna fix in V3




it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Signed-off-by: Johannes Zink 
---

Changes:

v1 -> v2: - worked in Rob's review findings (thanks for reviewing my
 work): use extracted common property instead of duplicating
the property
  - refined commit message
  - add an example dts for automated checking
---
  .../bindings/display/panel/panel-simple.yaml   | 26 +-
  1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index ec50dd268314..698301c8c920 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -21,9 +21,9 @@ description: |
  
  allOf:

- $ref: panel-common.yaml#
+  - $ref: ../lvds-data-mapping.yaml#
  
  properties:

-
compatible:
  enum:
  # compatible must be listed in alphabetical order, ordered by compatible.
@@ -353,6 +353,17 @@ properties:
power-supply: true
no-hpd: true
hpd-gpios: true
+  data-mapping: true


As the property is optional, don't you need a default value ?


as the simple-bus implicitely assumes default data mappings for LVDS panels, I 
think this is not necessary. If the property is not used in a DT, the default 
data mapping is used.


Best regards
Johannes




+
+if:
+  not:
+properties:
+  compatible:
+contains:
+  const: innolux,g101ice-l01
+then:
+  properties:
+data-mapping: false
  
  additionalProperties: false
  
@@ -372,3 +383,16 @@ examples:

  };
};
  };
+  - |
+panel_lvds: panel-lvds {
+  compatible = "innolux,g101ice-l01";
+  power-supply = <_lcd_reg>;
+
+  data-mapping = "jeida-24";
+
+  port {
+panel_in_lvds: endpoint {
+  remote-endpoint = <_out_lvds>;
+};
+  };
+};





--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH v2 1/3] dt-bindings: display: move LVDS data-mapping definition to separate file

2023-07-28 Thread Johannes Zink

Hi Laurent,

thank you for your review.

On 6/2/23 17:32, Laurent Pinchart wrote:

Hello Johannes,

Thank you for the patch.

On Tue, May 23, 2023 at 10:19:41AM +0200, Johannes Zink wrote:

As the LVDS data-mapping property is required in multiple bindings: move
it to separate file and include instead of duplicating it.

Signed-off-by: Johannes Zink 

---

Changes:

v1 -> v2: worked in Rob's review findings (thank you for reviewing my
   work): extract common properties to
   file and include it instead of duplicating it
---
  .../bindings/display/lvds-data-mapping.yaml| 84 ++
  .../devicetree/bindings/display/lvds.yaml  | 75 +++
  2 files changed, 92 insertions(+), 67 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml 
b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
new file mode 100644
index ..17ef5c9a5a90
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/lvds-data-mapping.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LVDS Data Mapping
+
+maintainers:
+  - Laurent Pinchart 
+  - Thierry Reding 
+
+description: |+
+  LVDS is a physical layer specification defined in ANSI/TIA/EIA-644-A. 
Multiple
+  incompatible data link layers have been used over time to transmit image data
+  to LVDS devices. This bindings supports devices compatible with the following
+  specifications.
+
+  [JEIDA] "Digital Interface Standards for Monitor", JEIDA-59-1999, February
+  1999 (Version 1.0), Japan Electronic Industry Development Association (JEIDA)
+  [LDI] "Open LVDS Display Interface", May 1999 (Version 0.95), National
+  Semiconductor
+  [VESA] "VESA Notebook Panel Standard", October 2007 (Version 1.0), Video
+  Electronics Standards Association (VESA)
+
+  Device compatible with those specifications have been marketed under the
+  FPD-Link and FlatLink brands.
+
+properties:
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6

Re: [PATCH v2 3/3] drm/panel-simple: allow LVDS format override

2023-06-05 Thread Johannes Zink

Hi Laurent,

thanks for your review and your feedback.

On 6/2/23 17:39, Laurent Pinchart wrote:

Hi Johannes,

Thank you for the patch.

On Tue, May 23, 2023 at 10:19:43AM +0200, Johannes Zink wrote:

Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.


Of course one could argue that the innolux,g101ice-l01 panel should have
used the panel-lvds bindings... :-)


I would prefer to add it in the panel-simple, if ever possible, as this already 
has the timing information etc. in the driver. I would probably opt to use the 
panel-lvds for an entirely new LVDS display, but as the innolux,g101ice-l01 is 
already supported in panel-simple, imho there should be no harm in supporting 
the jeida-18 operating mode as well. Also other displays in panel-simple 
_might_ benefit from supporting non-default LVDS mapping modes, though I have 
not researched whether they have actual hardware support for doing so.





Signed-off-by: Johannes Zink 

---

Changes:

   v1 -> v2: - fix missing unwind goto found by test robot
   Reported-by: kernel test robot 
   Reported-by: Dan Carpenter 
   Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
  drivers/gpu/drm/panel/panel-simple.c | 39 +++-
  1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 2a9c1a785a5c..0a35fdb49ccb 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
  #include 
  #include 
  #include 
+#include 
  
  /**

   * struct panel_desc - Describes a simple panel.
@@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;
  
  	panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);

if (!panel)
@@ -605,6 +606,42 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
  
+


Double blank line.


ack, gonna fix in v3.




+   /* optional data-mapping property for overriding bus format */


s/optional/Optional/


ack, gonna fix in v3.




+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret == -EINVAL) {
+   dev_warn(dev, "Ignore invalid data-mapping property");
+   } else if (ret != -ENODEV) {


If someone incorrectly sets the property in DT for a non-LVDS panel,
the result won't be nice. That's of course a DT issue, but I wonder if
we could/should protect against it. You could move this code to a
separate function (which would have the added benefit of lowering the
indentation level as you can return early in error cases), and call it
from panel_simple_probe() only if the panel is an LVDS panel (as
reported by its desc->bus_format value).



that's a good idea, gonna change it for v3.


+   int bpc;
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (desc->bpc != bpc || desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, desc, sizeof(*desc), 
GFP_KERNEL);
+   if (!override_desc) {
+   err = -ENOMEM;
+   goto free_ddc;
+   }
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {




--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH v2 3/3] drm/panel-simple: allow LVDS format override

2023-06-02 Thread Johannes Zink

Hi,

gentle ping here - Do you have any feedback for me on this patch?

Thanks and best regards
Johannes

On 5/23/23 10:19, Johannes Zink wrote:

Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

   v1 -> v2: - fix missing unwind goto found by test robot
   Reported-by: kernel test robot 
   Reported-by: Dan Carpenter 
   Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
  drivers/gpu/drm/panel/panel-simple.c | 39 +++-
  1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 2a9c1a785a5c..0a35fdb49ccb 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
  #include 
  #include 
  #include 
+#include 
  
  /**

   * struct panel_desc - Describes a simple panel.
@@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;
  
  	panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);

if (!panel)
@@ -605,6 +606,42 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
  
+

+   /* optional data-mapping property for overriding bus format */
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret == -EINVAL) {
+   dev_warn(dev, "Ignore invalid data-mapping property");
+   } else if (ret != -ENODEV) {
+   int bpc;
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (desc->bpc != bpc || desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, desc, sizeof(*desc), 
GFP_KERNEL);
+   if (!override_desc) {
+   err = -ENOMEM;
+   goto free_ddc;
+   }
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {



--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



[PATCH v2 2/3] dt-bindings: display: simple: support non-default data-mapping

2023-05-23 Thread Johannes Zink
Some Displays support more than just a single default lvds data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property to allow overriding the default
data mapping. As it does not generally apply to any display and bus: use
it selectively on the innolux,g101ice-l01, which supports changing the
data mapping via a strapping pin.

Signed-off-by: Johannes Zink 

---

Changes:

v1 -> v2: - worked in Rob's review findings (thanks for reviewing my
work): use extracted common property instead of duplicating
the property
  - refined commit message
  - add an example dts for automated checking
---
 .../bindings/display/panel/panel-simple.yaml   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index ec50dd268314..698301c8c920 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -21,9 +21,9 @@ description: |
 
 allOf:
   - $ref: panel-common.yaml#
+  - $ref: ../lvds-data-mapping.yaml#
 
 properties:
-
   compatible:
 enum:
 # compatible must be listed in alphabetical order, ordered by compatible.
@@ -353,6 +353,17 @@ properties:
   power-supply: true
   no-hpd: true
   hpd-gpios: true
+  data-mapping: true
+
+if:
+  not:
+properties:
+  compatible:
+contains:
+  const: innolux,g101ice-l01
+then:
+  properties:
+data-mapping: false
 
 additionalProperties: false
 
@@ -372,3 +383,16 @@ examples:
 };
   };
 };
+  - |
+panel_lvds: panel-lvds {
+  compatible = "innolux,g101ice-l01";
+  power-supply = <_lcd_reg>;
+
+  data-mapping = "jeida-24";
+
+  port {
+panel_in_lvds: endpoint {
+  remote-endpoint = <_out_lvds>;
+};
+  };
+};

-- 
2.39.2



[PATCH v2 3/3] drm/panel-simple: allow LVDS format override

2023-05-23 Thread Johannes Zink
Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 

---

Changes:

  v1 -> v2: - fix missing unwind goto found by test robot
  Reported-by: kernel test robot 
  Reported-by: Dan Carpenter 
  Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/
---
 drivers/gpu/drm/panel/panel-simple.c | 39 +++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 2a9c1a785a5c..0a35fdb49ccb 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;
 
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
if (!panel)
@@ -605,6 +606,42 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+
+   /* optional data-mapping property for overriding bus format */
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret == -EINVAL) {
+   dev_warn(dev, "Ignore invalid data-mapping property");
+   } else if (ret != -ENODEV) {
+   int bpc;
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (desc->bpc != bpc || desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, desc, sizeof(*desc), 
GFP_KERNEL);
+   if (!override_desc) {
+   err = -ENOMEM;
+   goto free_ddc;
+   }
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {

-- 
2.39.2



[PATCH v2 0/3] Support non-default LVDS data mapping for simple panel

2023-05-23 Thread Johannes Zink
Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series moves the data-mapping property for LVDS panels in a
separate file and optionally adds it to simple-panel when matching to
the innolux,g101ice-l01 compatible. This property allows to override
the default data mapping set in the panel description in simple-panel.

The last patch in this series actually adds the driver support for
parsing the data format override device tree property and modifying the
corresponding values for bit per color and media bus format in the panel
descriptor.

Best regards
Johannes

---

Changelog:

v1 -> v2:  - dt bindings: Worked in Rob's review findings (thanks for your
 review), refactored to use common include instead of duplication
   - driver: added missing error unwinding goto, as found by Dan
 Carpenter's test robot:
 Reported-by: kernel test robot 
 Reported-by: Dan Carpenter 
 Link: 
https://lore.kernel.org/r/202304160359.4lhmfolu-...@intel.com/

To: David Airlie 
To: Daniel Vetter 
To: Rob Herring 
To: Krzysztof Kozlowski 
To: Conor Dooley 
To: Laurent Pinchart 
To: Thierry Reding 
To: Neil Armstrong 
To: Sam Ravnborg 
Cc: patchwork-...@pengutronix.de
Cc: ker...@pengutronix.de
Cc: Laurent Pinchart 
Cc: dri-devel@lists.freedesktop.org
Cc: devicet...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Johannes Zink 

---
Johannes Zink (3):
  dt-bindings: display: move LVDS data-mapping definition to separate file
  dt-bindings: display: simple: support non-default data-mapping
  drm/panel-simple: allow LVDS format override

 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 75 +++
 .../bindings/display/panel/panel-simple.yaml   | 26 ++-
 drivers/gpu/drm/panel/panel-simple.c   | 39 +-
 4 files changed, 155 insertions(+), 69 deletions(-)
---
base-commit: 33a86170888b7e4aa0cea94ebb9c67180139cea9
change-id: 20230523-simplepanel_support_nondefault_datamapping-13c3f2ea28f8

Best regards,
-- 
Johannes Zink 



[PATCH v2 1/3] dt-bindings: display: move LVDS data-mapping definition to separate file

2023-05-23 Thread Johannes Zink
As the LVDS data-mapping property is required in multiple bindings: move
it to separate file and include instead of duplicating it.

Signed-off-by: Johannes Zink 

---

Changes:

v1 -> v2: worked in Rob's review findings (thank you for reviewing my
  work): extract common properties to
  file and include it instead of duplicating it
---
 .../bindings/display/lvds-data-mapping.yaml| 84 ++
 .../devicetree/bindings/display/lvds.yaml  | 75 +++
 2 files changed, 92 insertions(+), 67 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml 
b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
new file mode 100644
index ..17ef5c9a5a90
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/lvds-data-mapping.yaml
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/lvds-data-mapping.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LVDS Data Mapping
+
+maintainers:
+  - Laurent Pinchart 
+  - Thierry Reding 
+
+description: |+
+  LVDS is a physical layer specification defined in ANSI/TIA/EIA-644-A. 
Multiple
+  incompatible data link layers have been used over time to transmit image data
+  to LVDS devices. This bindings supports devices compatible with the following
+  specifications.
+
+  [JEIDA] "Digital Interface Standards for Monitor", JEIDA-59-1999, February
+  1999 (Version 1.0), Japan Electronic Industry Development Association (JEIDA)
+  [LDI] "Open LVDS Display Interface", May 1999 (Version 0.95), National
+  Semiconductor
+  [VESA] "VESA Notebook Panel Standard", October 2007 (Version 1.0), Video
+  Electronics Standards Association (VESA)
+
+  Device compatible with those specifications have been marketed under the
+  FPD-Link and FlatLink brands.
+
+properties:
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6__><__G7__><__G6__><__R7__><__R6__><
+
+  Control signals are mapped as follows.
+
+  CTL0: HSync
+  CTL1: VSync
+  CTL2: Data Enable
+  CTL3: 0
+

Re: [PATCH 1/2] dt-bindings: display: simple: support non-default data-mapping

2023-05-04 Thread Johannes Zink

Hi Rob,

On 4/19/23 08:29, Johannes Zink wrote:
[snip]




Why do you duplicate what's in display/lvds.yaml?


I don't think any of the other properties from display/lvds.yaml 
currently make any sense to be put into simple-panel, thus I selectively 
picked this one.


If there is a way to selectively pick only the data_mapping, please let 
me know and I send a V2




This also just made 'data-mapping' valid on non-LVDS panels.


what is the canonical way of restricting the data-mapping property to 
LVDS panels only? Or ist the proper way to go to move the panel I use 
(innolux,g101ice-l01) to its own yaml file, include panel-simple.yaml 
and leave the others alone? I think other LVDS panels might benefit from 
this series though, which is why I think it makes sense to add the 
property to all LVDS panels.




gentle ping. How do you suggest should I proceed here? Maybe pulling the 
data-mapping definition in a separate file and include it in both files?


Can I enable the property selectively, e.g. only on the 
innolux,g101ice-l01 panel, in order not to enable it on non-LVDS panels 
or on LVDS-panels which might not support it?


Best regards
Johannes

[snip]
--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



Re: [PATCH 1/2] dt-bindings: display: simple: support non-default data-mapping

2023-04-20 Thread Johannes Zink

Hi Rob,

On 4/18/23 23:20, Rob Herring wrote:

On Fri, Apr 14, 2023 at 06:11:15PM +0200, Johannes Zink wrote:

Some Displays support more than just a single default lvds data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property, analogously to panel-lvds, to
allow overriding the default data mapping.

Signed-off-by: Johannes Zink 
---
  .../bindings/display/panel/panel-simple.yaml  | 51 +++
  1 file changed, 51 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 18241f4051d2..6e219f67dd67 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -349,6 +349,57 @@ properties:
power-supply: true
no-hpd: true
hpd-gpios: true
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6__><__G7__><__G6__><__R7__><__R6__><
+
+  Control signals are mapped as follows.
+
+  CTL0: HSync
+  CTL1: VSync
+  CTL2: Data Enable
+  CTL3: 0


Why do you duplicate what's in display/lvds.yaml?


I don't think any of the other properties from display/lvds.yaml 
currently make any sense to be put into simple-panel, thus I selectively 
picked this one.


If there is a way to selectively pick only the data_mapping, please let 
me know and I send a V2




This also just made 'data-mapping' valid on non-LVDS panels.


what is the canonical way of restricting the data-mapping property to 
LVDS panels only? Or ist the proper way to go to move the panel I use 
(innolux,g101ice-l01) to its own yaml file, include panel-simple.yaml 
and leave the others alone? I think other LVDS panels might benefit from 
this series though, which is why I think it makes sense to add the 
property to all LVDS panels.


Best regards
Johannes



Rob



--
Pengutronix e.K.| Johannes Zink  |
Steuerwalder Str. 21| https://www.pengutronix.de/|
31137 Hildesheim, Germany   | Phone: +49-5121-206917-0   |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-|



[PATCH 0/2] Support non-default LVDS data mapping for simple

2023-04-17 Thread Johannes Zink
Some LVDS panels, such as the innolux,g101ice-l01 support multiple LVDS
data mapping modes, which can be configured by strapping a dataformat
pin on the display to a specific voltage.

This can be particularly useful for using the jeida-18 format, which
requires only 3 instead of 4 LVDS lanes.

This series adds an optional data-mapping property, analogously to the
property on lvds-panel, which overrides the default data mapping set in
the panel description in simple-panel.

Best regards
Johannes

Johannes Zink (2):
  dt-bindings: display: simple: support non-default data-mapping
  drm/panel-simple: allow LVDS format override

 .../bindings/display/panel/panel-simple.yaml  | 51 +++
 drivers/gpu/drm/panel/panel-simple.c  | 37 +-
 2 files changed, 87 insertions(+), 1 deletion(-)

-- 
2.39.2



[PATCH 2/2] drm/panel-simple: allow LVDS format override

2023-04-17 Thread Johannes Zink
Some panels support multiple LVDS data mapping formats, which can be
used e.g. run displays on jeida-18 format when only 3 LVDS lanes are
available.

Add parsing of an optional data-mapping devicetree property, which also
touches up the bits per color to match the bus format.

Signed-off-by: Johannes Zink 
---
 drivers/gpu/drm/panel/panel-simple.c | 37 +++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 065f378bba9d..7366ad13b3f1 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct panel_desc - Describes a simple panel.
@@ -559,7 +560,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
struct device_node *ddc;
int connector_type;
u32 bus_flags;
-   int err;
+   int err, ret;
 
panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
if (!panel)
@@ -605,6 +606,40 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
panel_simple_parse_panel_timing_node(dev, panel, );
}
 
+
+   /* optional data-mapping property for overriding bus format */
+   ret = drm_of_lvds_get_data_mapping(dev->of_node);
+   if (ret == -EINVAL) {
+   dev_warn(dev, "Ignore invalid data-mapping property");
+   } else if (ret != -ENODEV) {
+   int bpc;
+
+   switch (ret) {
+   default:
+   WARN_ON(1);
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
+   fallthrough;
+   case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
+   bpc = 8;
+   break;
+   case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
+   bpc = 6;
+   }
+
+   if (desc->bpc != bpc || desc->bus_format != ret) {
+   struct panel_desc *override_desc;
+
+   override_desc = devm_kmemdup(dev, desc, sizeof(*desc), 
GFP_KERNEL);
+   if (!override_desc)
+   return -ENOMEM;
+
+   override_desc->bus_format = ret;
+   override_desc->bpc = bpc;
+   panel->desc = override_desc;
+   }
+   }
+
connector_type = desc->connector_type;
/* Catch common mistakes for panels. */
switch (connector_type) {
-- 
2.39.2



[PATCH 1/2] dt-bindings: display: simple: support non-default data-mapping

2023-04-17 Thread Johannes Zink
Some Displays support more than just a single default lvds data mapping,
which can be used to run displays on only 3 LVDS lanes in the jeida-18
data-mapping mode.

Add an optional data-mapping property, analogously to panel-lvds, to
allow overriding the default data mapping.

Signed-off-by: Johannes Zink 
---
 .../bindings/display/panel/panel-simple.yaml  | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index 18241f4051d2..6e219f67dd67 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -349,6 +349,57 @@ properties:
   power-supply: true
   no-hpd: true
   hpd-gpios: true
+  data-mapping:
+enum:
+  - jeida-18
+  - jeida-24
+  - vesa-24
+description: |
+  The color signals mapping order.
+
+  LVDS data mappings are defined as follows.
+
+  - "jeida-18" - 18-bit data mapping compatible with the [JEIDA], [LDI] and
+[VESA] specifications. Data are transferred as follows on 3 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+
+  - "jeida-24" - 24-bit data mapping compatible with the [DSIM] and [LDI]
+specifications. Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G2__><__R7__><__R6__><__R5__><__R4__><__R3__><__R2__><
+  DATA1 ><__B3__><__B2__><__G7__><__G6__><__G5__><__G4__><__G3__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B7__><__B6__><__B5__><__B4__><
+  DATA3 ><_CTL3_><__B1__><__B0__><__G1__><__G0__><__R1__><__R0__><
+
+  - "vesa-24" - 24-bit data mapping compatible with the [VESA] 
specification.
+Data are transferred as follows on 4 LVDS lanes.
+
+  Slot  0   1   2   3   4   5   6
+ _
+  Clock \___/
+  __  __  __  __  __  __  __
+  DATA0 ><__G0__><__R5__><__R4__><__R3__><__R2__><__R1__><__R0__><
+  DATA1 ><__B1__><__B0__><__G5__><__G4__><__G3__><__G2__><__G1__><
+  DATA2 ><_CTL2_><_CTL1_><_CTL0_><__B5__><__B4__><__B3__><__B2__><
+  DATA3 ><_CTL3_><__B7__><__B6__><__G7__><__G6__><__R7__><__R6__><
+
+  Control signals are mapped as follows.
+
+  CTL0: HSync
+  CTL1: VSync
+  CTL2: Data Enable
+  CTL3: 0
 
 additionalProperties: false
 
-- 
2.39.2