Skip to content

Commit

Permalink
fixup! drm/panel: Add support for xiaomi-jasmine nt36672 panel
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Mason <[email protected]>
  • Loading branch information
buddyjojo authored and minlexx committed Aug 6, 2024
1 parent d7a3a40 commit 2618992
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions drivers/gpu/drm/panel/panel-novatek-nt36672-tianma-jasmine.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2022 FIXME
// Copyright (c) 2024 FIXME
// Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree:
// Copyright (c) 2013, The Linux Foundation. All rights reserved. (FIXME)

Expand All @@ -14,13 +14,13 @@
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h>

struct nt36672_tianma {
struct drm_panel panel;
struct mipi_dsi_device *dsi;
struct regulator *supply;
struct gpio_desc *reset_gpio;
bool prepared;
};

static inline struct nt36672_tianma *to_nt36672_tianma(struct drm_panel *panel)
Expand Down Expand Up @@ -111,9 +111,6 @@ static int nt36672_tianma_prepare(struct drm_panel *panel)
struct device *dev = &ctx->dsi->dev;
int ret;

if (ctx->prepared)
return 0;

ret = regulator_enable(ctx->supply);
if (ret < 0) {
dev_err(dev, "Failed to enable regulator: %d\n", ret);
Expand All @@ -130,7 +127,6 @@ static int nt36672_tianma_prepare(struct drm_panel *panel)
return ret;
}

ctx->prepared = true;
return 0;
}

Expand All @@ -140,17 +136,13 @@ static int nt36672_tianma_unprepare(struct drm_panel *panel)
struct device *dev = &ctx->dsi->dev;
int ret;

if (!ctx->prepared)
return 0;

ret = nt36672_tianma_off(ctx);
if (ret < 0)
dev_err(dev, "Failed to un-initialize panel: %d\n", ret);

gpiod_set_value_cansleep(ctx->reset_gpio, 1);
regulator_disable(ctx->supply);

ctx->prepared = false;
return 0;
}

Expand All @@ -166,25 +158,13 @@ static const struct drm_display_mode nt36672_tianma_mode = {
.vtotal = 2160 + 4 + 2 + 33,
.width_mm = 68,
.height_mm = 136,
.type = DRM_MODE_TYPE_DRIVER,
};

static int nt36672_tianma_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct drm_display_mode *mode;

mode = drm_mode_duplicate(connector->dev, &nt36672_tianma_mode);
if (!mode)
return -ENOMEM;

drm_mode_set_name(mode);

mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
connector->display_info.width_mm = mode->width_mm;
connector->display_info.height_mm = mode->height_mm;
drm_mode_probed_add(connector, mode);

return 1;
return drm_connector_helper_get_modes_fixed(connector, &nt36672_tianma_mode);
}

static const struct drm_panel_funcs nt36672_tianma_panel_funcs = {
Expand Down Expand Up @@ -223,6 +203,7 @@ static int nt36672_tianma_probe(struct mipi_dsi_device *dsi)

drm_panel_init(&ctx->panel, dev, &nt36672_tianma_panel_funcs,
DRM_MODE_CONNECTOR_DSI);
ctx->panel.prepare_prev_first = true;

ret = drm_panel_of_backlight(&ctx->panel);
if (ret)
Expand All @@ -232,9 +213,8 @@ static int nt36672_tianma_probe(struct mipi_dsi_device *dsi)

ret = mipi_dsi_attach(dsi);
if (ret < 0) {
dev_err(dev, "Failed to attach to DSI host: %d\n", ret);
drm_panel_remove(&ctx->panel);
return ret;
return dev_err_probe(dev, ret, "Failed to attach to DSI host\n");
}

return 0;
Expand Down

0 comments on commit 2618992

Please sign in to comment.