# Copyright (c) 2023 Mr Beam Lasers GmbH.
# Copyright (c) 2023 Amrith Venkat Kesavamoorthi <amrith@mr-beam.org>
# Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
# SPDX-License-Identifier: Apache-2.0

description: |
  GC9X01X display driver.

  This driver implements support for various GC9X01X graphics
  controllers and different display sizes. It has been validated
  for following controllers:
   - GC9101A: (Waveshare 240x240, 1.28inch round lcd display 240x240)

  Here is an example to define a display interface:

  / {
      my_mipi_dbi {
          compatible = "zephyr,mipi-dbi-spi";
          status = "okay";
          #address-cells = <1>;
          #size-cells = <0>;
          spi-dev = <&spi2>;
          dc-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
          reset-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;

          gc9x01x_lcd: gc9x01x_lcd@0 {
              compatible = "galaxycore,gc9x01x";
              reg = <0>;
              mipi-max-frequency = <DT_FREQ_M(100)>;
              pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>;
              width = <240>;
              height = <240>;
              display-inversion;
          };
      };
  };


compatible: "galaxycore,gc9x01x"

include: [mipi-dbi-spi-device.yaml, display-controller.yaml, lcd-controller.yaml]

properties:
  orientation:
    type: string
    default: "normal"
    enum:
      - "normal"
      - "90"
      - "180"
      - "270"
    description: Display orientation (CW) in degrees.

  display-inversion:
    type: boolean
    description: |
      Display inversion mode. Every bit is inverted from the frame memory to
      the display.

  pwrctrl1:
    type: uint8-array
    default: [
      0x00
    ]
    description: Power-control 1 register value

  pwrctrl2:
    type: uint8-array
    default: [
      0x13
    ]
    description: Power-control 2 register value

  pwrctrl3:
    type: uint8-array
    default: [
      0x13
    ]
    description: Power-control 3 register value

  pwrctrl4:
    type: uint8-array
    default: [
      0x22
    ]
    description: Power-control 4 register value

  gamma1:
    type: uint8-array
    default: [
      0x45,
      0x09,
      0x08,
      0x08,
      0x26,
      0x2A
    ]
    description: Gamma correction 1 register values (negative polarity)

  gamma2:
    type: uint8-array
    default: [
      0x43,
      0x70,
      0x72,
      0x36,
      0x37,
      0x6F
    ]
    description: Gamma correction 3 register values

  gamma3:
    type: uint8-array
    default: [
      0x45,
      0x09,
      0x08,
      0x08,
      0x26,
      0x2A
    ]
    description: Gamma correction 3 register values (positive polarity)

  gamma4:
    type: uint8-array
    default: [
      0x43,
      0x70,
      0x72,
      0x36,
      0x37,
      0x6F
    ]
    description: Gamma correction 4 register values

  framerate:
    type: uint8-array
    default: [
      0x34
    ]
    description: Framerate register value
