devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Sandeep Panda <spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ryadav-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	nganji-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	abhinavk-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	hoegsberg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	chandanu-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
Subject: Re: [[RFC]DPU PATCH 3/4] drm/panel: add Innolux TV123WAM eDP panel driver
Date: Fri, 20 Apr 2018 15:43:02 -0400	[thread overview]
Message-ID: <20180420194302.GJ73214@art_vandelay> (raw)
In-Reply-To: <1524160568-27583-4-git-send-email-spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

On Thu, Apr 19, 2018 at 11:26:07PM +0530, Sandeep Panda wrote:
> Add support for Innolux TV123WAM 12.3" panel which
> is an eDP panel.

It seems like you could just use the panel-simple driver, no? Given that this
driver doesn't have any power timing, that will probably work better since the
warranty won't be voided :)

Sean

> 
> Signed-off-by: Sandeep Panda <spanda@codeaurora.org>
> ---
>  drivers/gpu/drm/panel/panel-innolux-tv123wam.c | 293 +++++++++++++++++++++++++
>  1 file changed, 293 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-innolux-tv123wam.c
> 
> diff --git a/drivers/gpu/drm/panel/panel-innolux-tv123wam.c b/drivers/gpu/drm/panel/panel-innolux-tv123wam.c
> new file mode 100644
> index 0000000..5632b02
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-innolux-tv123wam.c
> @@ -0,0 +1,293 @@
> +/*
> + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <drm/drmP.h>
> +#include <drm/drm_panel.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/platform_device.h>
> +#include <linux/regulator/consumer.h>
> +
> +struct innolux_edp_2k_panel_desc {
> +	const struct drm_display_mode *modes;
> +	unsigned int num_modes;
> +	u32 bpc;
> +	u32 bus_flags;
> +};
> +
> +struct innolux_edp_2k_panel {
> +	struct drm_panel base;
> +	bool enabled;
> +	bool prepared;
> +	const struct innolux_edp_2k_panel_desc *desc;
> +	struct regulator *supply;
> +	struct gpio_desc *enable_gpio;
> +	struct backlight_device *backlight;
> +};
> +
> +static const struct drm_display_mode innolux_edp_2k_mode = {
> +	.clock = 206016,
> +	.hdisplay = 2160,
> +	.hsync_start = 2160 + 48,
> +	.hsync_end = 2160 + 48 + 32,
> +	.htotal = 2160 + 48 + 32 + 80,
> +	.vdisplay = 1440,
> +	.vsync_start = 1440 + 3,
> +	.vsync_end = 1440 + 3 + 10,
> +	.vtotal = 1440 + 3 + 10 + 27,
> +	.vrefresh = 60,
> +	.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC,
> +};
> +
> +static const struct innolux_edp_2k_panel_desc innolux_edp_2k = {
> +	.modes = &innolux_edp_2k_mode,
> +	.num_modes = 1,
> +	.bpc = 8,
> +	.bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE,
> +};
> +
> +static const struct of_device_id platform_of_match[] = {
> +	{
> +		.compatible = "innolux, edp_2k_panel",
> +		.data = &innolux_edp_2k,
> +	},
> +};
> +
> +static inline struct innolux_edp_2k_panel *
> +to_innolux_edp_2k_panel(struct drm_panel *panel)
> +{
> +	return container_of(panel, struct innolux_edp_2k_panel, base);
> +}
> +
> +static int innolux_edp_2k_panel_disable(struct drm_panel *panel)
> +{
> +	struct innolux_edp_2k_panel *pdata = to_innolux_edp_2k_panel(panel);
> +
> +	if (!pdata->enabled)
> +		return 0;
> +
> +	if (pdata->backlight) {
> +		pdata->backlight->props.power = FB_BLANK_POWERDOWN;
> +		pdata->backlight->props.state |= BL_CORE_FBBLANK;
> +		backlight_update_status(pdata->backlight);
> +	}
> +
> +	pdata->enabled = false;
> +
> +	return 0;
> +}
> +
> +static int innolux_edp_2k_panel_unprepare(struct drm_panel *panel)
> +{
> +	struct innolux_edp_2k_panel *pdata = to_innolux_edp_2k_panel(panel);
> +
> +	if (!pdata->prepared)
> +		return 0;
> +
> +	if (pdata->enable_gpio)
> +		gpiod_set_value_cansleep(pdata->enable_gpio, 0);
> +
> +	regulator_disable(pdata->supply);
> +
> +	pdata->prepared = false;
> +
> +	return 0;
> +}
> +
> +static int innolux_edp_2k_panel_prepare(struct drm_panel *panel)
> +{
> +	struct innolux_edp_2k_panel *pdata = to_innolux_edp_2k_panel(panel);
> +	int ret;
> +
> +	if (pdata->prepared)
> +		return 0;
> +
> +	ret = regulator_enable(pdata->supply);
> +	if (ret < 0) {
> +		dev_err(panel->dev, "failed to enable supply: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (pdata->enable_gpio)
> +		gpiod_set_value_cansleep(pdata->enable_gpio, 1);
> +
> +	pdata->prepared = true;
> +
> +	return 0;
> +}
> +
> +static int innolux_edp_2k_panel_enable(struct drm_panel *panel)
> +{
> +	struct innolux_edp_2k_panel *pdata = to_innolux_edp_2k_panel(panel);
> +
> +	if (pdata->enabled)
> +		return 0;
> +
> +	if (pdata->backlight) {
> +		pdata->backlight->props.state &= ~BL_CORE_FBBLANK;
> +		pdata->backlight->props.power = FB_BLANK_UNBLANK;
> +		backlight_update_status(pdata->backlight);
> +	}
> +
> +	pdata->enabled = true;
> +
> +	return 0;
> +}
> +
> +static int innolux_edp_2k_panel_get_modes(struct drm_panel *panel)
> +{
> +	struct innolux_edp_2k_panel *pdata = to_innolux_edp_2k_panel(panel);
> +	struct drm_connector *connector = pdata->base.connector;
> +	struct drm_device *drm = pdata->base.drm;
> +	struct drm_display_mode *mode;
> +	unsigned int i, num = 0;
> +
> +	if (!pdata->desc || !connector || !drm)
> +		return 0;
> +
> +	for (i = 0; i < pdata->desc->num_modes; i++) {
> +		const struct drm_display_mode *m = &pdata->desc->modes[i];
> +
> +		mode = drm_mode_duplicate(drm, m);
> +		if (!mode) {
> +			dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
> +				m->hdisplay, m->vdisplay, m->vrefresh);
> +			continue;
> +		}
> +
> +		mode->type |= DRM_MODE_TYPE_DRIVER;
> +
> +		if (pdata->desc->num_modes == 1)
> +			mode->type |= DRM_MODE_TYPE_PREFERRED;
> +
> +		drm_mode_set_name(mode);
> +
> +		drm_mode_probed_add(connector, mode);
> +		num++;
> +	}
> +
> +	connector->display_info.bpc = pdata->desc->bpc;
> +	connector->display_info.bus_flags = pdata->desc->bus_flags;
> +
> +	return num;
> +}
> +
> +static const struct drm_panel_funcs innolux_edp_2k_panel_funcs = {
> +	.disable = innolux_edp_2k_panel_disable,
> +	.unprepare = innolux_edp_2k_panel_unprepare,
> +	.prepare = innolux_edp_2k_panel_prepare,
> +	.enable = innolux_edp_2k_panel_enable,
> +	.get_modes = innolux_edp_2k_panel_get_modes,
> +};
> +
> +static int innolux_edp_2k_panel_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	const struct of_device_id *id;
> +	struct device_node *backlight;
> +	struct innolux_edp_2k_panel *pdata;
> +	int ret;
> +
> +	id = of_match_node(platform_of_match, pdev->dev.of_node);
> +	if (!id)
> +		return -ENODEV;
> +
> +	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata)
> +		return -ENOMEM;
> +
> +	pdata->enabled = false;
> +	pdata->prepared = false;
> +	pdata->desc = id->data;
> +
> +	pdata->supply = devm_regulator_get(dev, "power");
> +	if (IS_ERR(pdata->supply))
> +		return PTR_ERR(pdata->supply);
> +
> +	pdata->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
> +	if (IS_ERR(pdata->enable_gpio))
> +		return PTR_ERR(pdata->enable_gpio);
> +
> +	backlight = of_parse_phandle(dev->of_node, "backlight", 0);
> +	if (backlight) {
> +		pdata->backlight = of_find_backlight_by_node(backlight);
> +		of_node_put(backlight);
> +
> +		if (!pdata->backlight)
> +			return -EPROBE_DEFER;
> +	}
> +
> +	drm_panel_init(&pdata->base);
> +	pdata->base.dev = dev;
> +	pdata->base.funcs = &innolux_edp_2k_panel_funcs;
> +
> +	ret = drm_panel_add(&pdata->base);
> +	if (ret < 0)
> +		goto free_backlight;
> +
> +	dev_set_drvdata(dev, pdata);
> +
> +	return 0;
> +
> +free_backlight:
> +	if (pdata->backlight)
> +		put_device(&pdata->backlight->dev);
> +
> +	return ret;
> +}
> +
> +static int innolux_edp_2k_panel_remove(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct innolux_edp_2k_panel *pdata = dev_get_drvdata(dev);
> +
> +	drm_panel_detach(&pdata->base);
> +	drm_panel_remove(&pdata->base);
> +
> +	innolux_edp_2k_panel_disable(&pdata->base);
> +	innolux_edp_2k_panel_unprepare(&pdata->base);
> +
> +	if (pdata->backlight)
> +		put_device(&pdata->backlight->dev);
> +
> +	return 0;
> +}
> +
> +static struct platform_driver innolux_edp_2k_panel_driver = {
> +	.driver = {
> +		.name = "innolux-2k-edp-panel",
> +		.of_match_table = platform_of_match,
> +	},
> +	.probe = innolux_edp_2k_panel_probe,
> +	.remove = innolux_edp_2k_panel_remove,
> +};
> +
> +static int __init innolux_edp_2k_panel_init(void)
> +{
> +	int ret;
> +
> +	ret = platform_driver_register(&innolux_edp_2k_panel_driver);
> +	if (ret < 0)
> +		return ret;
> +
> +	return 0;
> +}
> +module_init(innolux_edp_2k_panel_init);
> +
> +static void __exit innolux_edp_2k_panel_exit(void)
> +{
> +	platform_driver_unregister(&innolux_edp_2k_panel_driver);
> +}
> +module_exit(innolux_edp_2k_panel_exit);
> +
> +MODULE_DESCRIPTION("Innolux 2k eDP panel driver");
> +MODULE_LICENSE("GPL");
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2018-04-20 19:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 17:56 [[RFC]DPU PATCH 0/4] Add suppport for sn65dsi86 bridge chip and Innolux 2k edp panel driver Sandeep Panda
     [not found] ` <1524160568-27583-1-git-send-email-spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-19 17:56   ` [[RFC]DPU PATCH 1/4] drm/bridge: add support for sn65dsi86 bridge driver Sandeep Panda
2018-04-20 19:36     ` Sean Paul
2018-04-24  9:48       ` spanda-sgV2jX0FEOL9JmXXK+q4OQ
2018-04-19 17:56   ` [[RFC]DPU PATCH 2/4] dt-bindings: drm/bridge: Document sn65dsi86 bridge bindings Sandeep Panda
     [not found]     ` <1524160568-27583-3-git-send-email-spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-25 23:45       ` Stephen Boyd
     [not found]         ` <152469995691.46528.3834882157254635250-n1Xw8LXHxjTHt/MElyovVYaSKrA+ACpX0E9HWUfgJXw@public.gmane.org>
2018-04-26  0:46           ` Rob Clark
     [not found]             ` <CAF6AEGuWo9U5OU5nKSSwzRV_FWszTj_8S3Hns9hFHWBPsepnVw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-04-27  3:13               ` Rob Herring
2018-04-27  7:02                 ` spanda-sgV2jX0FEOL9JmXXK+q4OQ
     [not found]                   ` <0522b749900b3a54508abef6bd15252f-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-27 17:07                     ` Rob Clark
2018-04-19 17:56   ` [[RFC]DPU PATCH 3/4] drm/panel: add Innolux TV123WAM eDP panel driver Sandeep Panda
     [not found]     ` <1524160568-27583-4-git-send-email-spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-20 19:43       ` Sean Paul [this message]
2018-04-24  9:53         ` spanda-sgV2jX0FEOL9JmXXK+q4OQ
2018-04-19 17:56   ` [[RFC]DPU PATCH 4/4] dt-bindings: drm/panel: Document Innolux TV123WAM panel bindings Sandeep Panda
  -- strict thread matches above, loose matches on Subject: below --
2018-04-18 12:19 [[RFC]DPU PATCH 0/4] Add suppport for sn65dsi86 bridge chip and Innolux 2k edp panel driver Sandeep Panda
     [not found] ` <1524054002-17869-1-git-send-email-spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-04-18 12:20   ` [[RFC]DPU PATCH 3/4] drm/panel: add Innolux TV123WAM eDP " Sandeep Panda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180420194302.GJ73214@art_vandelay \
    --to=seanpaul-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=abhinavk-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=chandanu-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=hoegsberg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nganji-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ryadav-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=spanda-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).