Re: [RFC 2/4] drm/panel/ili9341: Rebase and some more

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Noralf,
see comment bellow.

po 29. 7. 2019 v 21:55 odesílatel Noralf Trønnes <noralf@xxxxxxxxxxx> napsal:
>
> Embed mipi_dbi in struct ili9341.
> Rebase on moved mipi-dbi, rename variable name.
> Add backlight_device to panel struct.
> mipi_dbi_hw_reset() already has a NULL check on the reset gpio.
> Prepare for more panels by reworking ili9341_config.
>
> Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx>
> ---
>  drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 104 +++++++++----------
>  1 file changed, 52 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> index 0c700b171025..a755f3e60111 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
> @@ -28,7 +28,7 @@
>  #include <drm/drm_modes.h>
>  #include <drm/drm_panel.h>
>  #include <drm/drm_print.h>
> -#include <drm/tinydrm/mipi-dbi.h>
> +#include <drm/drm_mipi_dbi.h>
>
>  /* ILI9341 extended register set (Vendor Command Set) */
>  #define ILI9341_IFMODE         0xB0 // clock polarity
> @@ -42,17 +42,18 @@
>
>  /**
>   * struct ili9341_config - the display specific configuration
> - * @width_mm: physical panel width [mm]
> - * @height_mm: physical panel height [mm]
> + * @funcs: Panel functions
> + * @mode: Display mode
>   */
>  struct ili9341_config {
> -       u32 width_mm;
> -       u32 height_mm;
> +       const struct drm_panel_funcs *funcs;
> +       const struct drm_display_mode *mode;
>  };
>
>  struct ili9341 {
>         struct drm_panel panel;
> -       struct mipi_dbi *mipi;
> +       struct mipi_dbi dbi;
> +       struct backlight_device *backlight;
>         const struct ili9341_config *conf;
>  };
>
> @@ -63,47 +64,50 @@ static inline struct ili9341 *panel_to_ili9341(struct drm_panel *panel)
>
>  static int ili9341_deinit(struct drm_panel *panel, struct ili9341 *ili)
>  {
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SET_DISPLAY_OFF);
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_ENTER_SLEEP_MODE);
> +       struct mipi_dbi *dbi = &ili->dbi;
> +
> +       mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_OFF);
> +       mipi_dbi_command(dbi, MIPI_DCS_ENTER_SLEEP_MODE);
>         msleep(5);
>         return 0;
>  }
>
> -static int ili9341_init(struct drm_panel *panel, struct ili9341 *ili)
> +static int dt024ctft_init(struct drm_panel *panel, struct ili9341 *ili)
I'd prefer to name this function something like ili9341_prgb_init.
In the future, there may be more displays with ILI9341 chip and prgb support
apart from DisplayTech DT024CTFT.
>  {
> -       /* HW / SW Reset display and wait */
> -       if (ili->mipi->reset)
> -               mipi_dbi_hw_reset(ili->mipi);
> +       struct mipi_dbi *dbi = &ili->dbi;
>
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SOFT_RESET);
> +       /* HW / SW Reset display and wait */
> +       mipi_dbi_hw_reset(dbi);
> +
> +       mipi_dbi_command(dbi, MIPI_DCS_SOFT_RESET);
>         msleep(120);
>
>         /* Polarity */
> -       mipi_dbi_command(ili->mipi, ILI9341_IFMODE, 0xC0);
> +       mipi_dbi_command(dbi, ILI9341_IFMODE, 0xC0);
>
>         /* Interface control */
> -       mipi_dbi_command(ili->mipi, ILI9341_IFCTL, 0x09, 0x01, 0x26);
> +       mipi_dbi_command(dbi, ILI9341_IFCTL, 0x09, 0x01, 0x26);
>
>         /* Pixel format */
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_18BIT << 4);
> +       mipi_dbi_command(dbi, MIPI_DCS_SET_PIXEL_FORMAT, MIPI_DCS_PIXEL_FMT_18BIT << 4);
>
>         /* Gamma */
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SET_GAMMA_CURVE, 0x01);
> -       mipi_dbi_command(ili->mipi, ILI9341_PGAMCTRL,
> +       mipi_dbi_command(dbi, MIPI_DCS_SET_GAMMA_CURVE, 0x01);
> +       mipi_dbi_command(dbi, ILI9341_PGAMCTRL,
>                 0x0f, 0x31, 0x2b, 0x0c, 0x0e, 0x08, 0x4e, 0xf1,
>                 0x37, 0x07, 0x10, 0x03, 0x0e, 0x09, 0x00);
> -       mipi_dbi_command(ili->mipi, ILI9341_NGAMCTRL,
> +       mipi_dbi_command(dbi, ILI9341_NGAMCTRL,
>                 0x00, 0x0e, 0x14, 0x03, 0x11, 0x07, 0x31, 0xc1,
>                 0x48, 0x08, 0x0f, 0x0c, 0x31, 0x36, 0x0f);
>
>         /* Rotation */
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SET_ADDRESS_MODE, ILI9341_MADCTL_MX);
> +       mipi_dbi_command(dbi, MIPI_DCS_SET_ADDRESS_MODE, ILI9341_MADCTL_MX);
>
>         /* Exit sleep mode */
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_EXIT_SLEEP_MODE);
> +       mipi_dbi_command(dbi, MIPI_DCS_EXIT_SLEEP_MODE);
>         msleep(120);
>
> -       mipi_dbi_command(ili->mipi, MIPI_DCS_SET_DISPLAY_ON);
> +       mipi_dbi_command(dbi, MIPI_DCS_SET_DISPLAY_ON);
>
>         return 0;
>  }
> @@ -115,12 +119,12 @@ static int ili9341_unprepare(struct drm_panel *panel)
>         return ili9341_deinit(panel, ili);
>  }
>
> -static int ili9341_prepare(struct drm_panel *panel)
> +static int dt024ctft_prepare(struct drm_panel *panel)
>  {
>         struct ili9341 *ili = panel_to_ili9341(panel);
>         int ret;
>
> -       ret = ili9341_init(panel, ili);
> +       ret = dt024ctft_init(panel, ili);
>         if (ret < 0)
>                 ili9341_unprepare(panel);
>         return ret;
> @@ -130,14 +134,14 @@ static int ili9341_enable(struct drm_panel *panel)
>  {
>         struct ili9341 *ili = panel_to_ili9341(panel);
>
> -       return backlight_enable(ili->mipi->backlight);
> +       return backlight_enable(ili->backlight);
>  }
>
>  static int ili9341_disable(struct drm_panel *panel)
>  {
>         struct ili9341 *ili = panel_to_ili9341(panel);
>
> -       return backlight_disable(ili->mipi->backlight);
> +       return backlight_disable(ili->backlight);
>  }
>
>  static const struct drm_display_mode prgb_240x320_mode = {
> @@ -154,7 +158,10 @@ static const struct drm_display_mode prgb_240x320_mode = {
>         .vtotal = 320 + 4 + 2 + 2,
>
>         .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
> -       .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED
> +       .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
> +
> +       .width_mm = 37,
> +       .height_mm = 49,
>  };
>
>  static int ili9341_get_modes(struct drm_panel *panel)
> @@ -163,7 +170,7 @@ static int ili9341_get_modes(struct drm_panel *panel)
>         struct ili9341 *ili = panel_to_ili9341(panel);
>         struct drm_display_mode *mode;
>
> -       mode = drm_mode_duplicate(panel->drm, &prgb_240x320_mode);
> +       mode = drm_mode_duplicate(panel->drm, ili->conf->mode);
>         if (!mode) {
>                 DRM_DEV_ERROR(panel->drm->dev, "bad mode or failed to add mode\n");
>                 return -ENOMEM;
> @@ -171,9 +178,6 @@ static int ili9341_get_modes(struct drm_panel *panel)
>
>         drm_mode_set_name(mode);
>
> -       mode->width_mm = ili->conf->width_mm;
> -       mode->height_mm = ili->conf->height_mm;
> -
>         connector->display_info.width_mm = mode->width_mm;
>         connector->display_info.height_mm = mode->height_mm;
>         connector->display_info.bus_flags |= DRM_BUS_FLAG_DE_HIGH |
> @@ -184,31 +188,32 @@ static int ili9341_get_modes(struct drm_panel *panel)
>         return 1; /* Number of modes */
>  }
>
> -static const struct drm_panel_funcs ili9341_drm_funcs = {
> +static const struct drm_panel_funcs dt024ctft_drm_funcs = {
>         .disable = ili9341_disable,
>         .unprepare = ili9341_unprepare,
> -       .prepare = ili9341_prepare,
> +       .prepare = dt024ctft_prepare,
>         .enable = ili9341_enable,
>         .get_modes = ili9341_get_modes,
>  };
>
> +static const struct ili9341_config dt024ctft_data = {
> +       .funcs = &dt024ctft_drm_funcs,
> +       .mode = &prgb_240x320_mode,
> +};
> +
>  static int ili9341_probe(struct spi_device *spi)
>  {
>         struct device *dev = &spi->dev;
>         struct ili9341 *ili;
> -       struct mipi_dbi *mipi;
> +       struct mipi_dbi *dbi;
>         struct gpio_desc *dc_gpio;
>         int ret;
>
> -       mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
> -       if (!mipi)
> -               return -ENOMEM;
> -
>         ili = devm_kzalloc(dev, sizeof(*ili), GFP_KERNEL);
>         if (!ili)
>                 return -ENOMEM;
>
> -       ili->mipi = mipi;
> +       dbi = &ili->dbi;
>
>         spi_set_drvdata(spi, ili);
>
> @@ -222,16 +227,16 @@ static int ili9341_probe(struct spi_device *spi)
>                 return -ENODEV;
>         }
>
> -       ili->mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> -       if (IS_ERR(ili->mipi->reset)) {
> +       dbi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> +       if (IS_ERR(dbi->reset)) {
>                 DRM_DEV_ERROR(dev, "failed to get gpio 'reset'\n");
> -               return PTR_ERR(ili->mipi->reset);
> +               return PTR_ERR(dbi->reset);
>         }
>
> -       ili->mipi->backlight = devm_of_find_backlight(dev);
> -       if (IS_ERR(ili->mipi->backlight)) {
> +       ili->backlight = devm_of_find_backlight(dev);
> +       if (IS_ERR(ili->backlight)) {
>                 DRM_DEV_ERROR(dev, "failed to get backlight\n");
> -               return PTR_ERR(ili->mipi->backlight);
> +               return PTR_ERR(ili->backlight);
>         }
>
>         dc_gpio = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);
> @@ -240,7 +245,7 @@ static int ili9341_probe(struct spi_device *spi)
>                 return PTR_ERR(dc_gpio);
>         }
>
> -       ret = mipi_dbi_spi_init(spi, ili->mipi, dc_gpio);
> +       ret = mipi_dbi_spi_init(spi, dbi, dc_gpio);
>         if (ret) {
>                 DRM_DEV_ERROR(dev, "MIPI-DBI SPI setup failed\n");
>                 return ret;
> @@ -248,7 +253,7 @@ static int ili9341_probe(struct spi_device *spi)
>
>         drm_panel_init(&ili->panel);
>         ili->panel.dev = dev;
> -       ili->panel.funcs = &ili9341_drm_funcs;
> +       ili->panel.funcs = ili->conf->funcs;
>
>         return drm_panel_add(&ili->panel);
>  }
> @@ -265,11 +270,6 @@ static int ili9341_remove(struct spi_device *spi)
>         return 0;
>  }
>
> -static const struct ili9341_config dt024ctft_data = {
> -       .width_mm = 37,
> -       .height_mm = 49,
> -};
> -
>  static const struct of_device_id ili9341_of_match[] = {
>         { .compatible = "displaytech,dt024ctft", .data = &dt024ctft_data },
>         { /* sentinel */ }
> --
> 2.20.1
>
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux