From: Inki Dae <inki.dae@samsung.com>
To: Ajay Kumar <ajaykumar.rs@samsung.com>
Cc: dri-devel@lists.freedesktop.org,
linux-samsung-soc@vger.kernel.org, robdclark@gmail.com,
daniel.vetter@ffwll.ch, thierry.reding@gmail.com,
seanpaul@google.com, ajaynumb@gmail.com, jg1.han@samsung.com,
joshi@samsung.com, prashanth.g@samsung.com, javier@dowhile0.org,
cpgs@samsung.com
Subject: Re: [RESEND PATCH V5 08/12] drm/bridge: ptn3460: Support bridge chaining
Date: Mon, 21 Jul 2014 16:55:15 +0900 [thread overview]
Message-ID: <53CCC763.30607@samsung.com> (raw)
In-Reply-To: <1405629839-12086-9-git-send-email-ajaykumar.rs@samsung.com>
On 2014년 07월 18일 05:43, Ajay Kumar wrote:
> Modify the driver to invoke callbacks for the next bridge
> in the bridge chain.
> Also, remove the drm_connector implementation from ptn3460,
> since the same is implemented using panel_binder.
>
> Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
> ---
> drivers/gpu/drm/bridge/ptn3460.c | 137 +++++--------------------------
> drivers/gpu/drm/exynos/exynos_dp_core.c | 16 ++--
> include/drm/bridge/ptn3460.h | 15 ++--
> 3 files changed, 39 insertions(+), 129 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c
> index d466696..5fe16c6 100644
> --- a/drivers/gpu/drm/bridge/ptn3460.c
> +++ b/drivers/gpu/drm/bridge/ptn3460.c
> @@ -34,37 +34,15 @@
> #define PTN3460_EDID_SRAM_LOAD_ADDR 0x85
>
> struct ptn3460_bridge {
> - struct drm_connector connector;
> struct i2c_client *client;
> struct drm_encoder *encoder;
> struct drm_bridge *bridge;
> - struct edid *edid;
> int gpio_pd_n;
> int gpio_rst_n;
> u32 edid_emulation;
> bool enabled;
> };
>
> -static int ptn3460_read_bytes(struct ptn3460_bridge *ptn_bridge, char addr,
> - u8 *buf, int len)
> -{
> - int ret;
> -
> - ret = i2c_master_send(ptn_bridge->client, &addr, 1);
> - if (ret <= 0) {
> - DRM_ERROR("Failed to send i2c command, ret=%d\n", ret);
> - return ret;
> - }
> -
> - ret = i2c_master_recv(ptn_bridge->client, buf, len);
> - if (ret <= 0) {
> - DRM_ERROR("Failed to recv i2c data, ret=%d\n", ret);
> - return ret;
> - }
> -
> - return 0;
> -}
> -
> static int ptn3460_write_byte(struct ptn3460_bridge *ptn_bridge, char addr,
> char val)
> {
> @@ -126,6 +104,8 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
> gpio_set_value(ptn_bridge->gpio_rst_n, 1);
> }
>
> + drm_next_bridge_pre_enable(bridge);
> +
> /*
> * There's a bug in the PTN chip where it falsely asserts hotplug before
> * it is fully functional. We're forced to wait for the maximum start up
> @@ -142,6 +122,7 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge)
>
> static void ptn3460_enable(struct drm_bridge *bridge)
> {
> + drm_next_bridge_enable(bridge);
> }
>
> static void ptn3460_disable(struct drm_bridge *bridge)
> @@ -153,6 +134,8 @@ static void ptn3460_disable(struct drm_bridge *bridge)
>
> ptn_bridge->enabled = false;
>
> + drm_next_bridge_disable(bridge);
> +
> if (gpio_is_valid(ptn_bridge->gpio_rst_n))
> gpio_set_value(ptn_bridge->gpio_rst_n, 1);
>
> @@ -162,6 +145,7 @@ static void ptn3460_disable(struct drm_bridge *bridge)
>
> static void ptn3460_post_disable(struct drm_bridge *bridge)
> {
> + drm_next_bridge_post_disable(bridge);
> }
>
> void ptn3460_bridge_destroy(struct drm_bridge *bridge)
> @@ -173,6 +157,9 @@ void ptn3460_bridge_destroy(struct drm_bridge *bridge)
> gpio_free(ptn_bridge->gpio_pd_n);
> if (gpio_is_valid(ptn_bridge->gpio_rst_n))
> gpio_free(ptn_bridge->gpio_rst_n);
> +
> + drm_next_bridge_destroy(bridge);
> +
> /* Nothing else to free, we've got devm allocated memory */
> }
>
> @@ -184,81 +171,10 @@ struct drm_bridge_funcs ptn3460_bridge_funcs = {
> .destroy = ptn3460_bridge_destroy,
> };
>
> -int ptn3460_get_modes(struct drm_connector *connector)
> -{
> - struct ptn3460_bridge *ptn_bridge;
> - u8 *edid;
> - int ret, num_modes;
> - bool power_off;
> -
> - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
> -
> - if (ptn_bridge->edid)
> - return drm_add_edid_modes(connector, ptn_bridge->edid);
> -
> - power_off = !ptn_bridge->enabled;
> - ptn3460_pre_enable(ptn_bridge->bridge);
> -
> - edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
> - if (!edid) {
> - DRM_ERROR("Failed to allocate edid\n");
> - return 0;
> - }
> -
> - ret = ptn3460_read_bytes(ptn_bridge, PTN3460_EDID_ADDR, edid,
> - EDID_LENGTH);
> - if (ret) {
> - kfree(edid);
> - num_modes = 0;
> - goto out;
> - }
> -
> - ptn_bridge->edid = (struct edid *)edid;
> - drm_mode_connector_update_edid_property(connector, ptn_bridge->edid);
> -
> - num_modes = drm_add_edid_modes(connector, ptn_bridge->edid);
> -
> -out:
> - if (power_off)
> - ptn3460_disable(ptn_bridge->bridge);
> -
> - return num_modes;
> -}
> -
> -struct drm_encoder *ptn3460_best_encoder(struct drm_connector *connector)
> -{
> - struct ptn3460_bridge *ptn_bridge;
> -
> - ptn_bridge = container_of(connector, struct ptn3460_bridge, connector);
> -
> - return ptn_bridge->encoder;
> -}
> -
> -struct drm_connector_helper_funcs ptn3460_connector_helper_funcs = {
> - .get_modes = ptn3460_get_modes,
> - .best_encoder = ptn3460_best_encoder,
> -};
> -
> -enum drm_connector_status ptn3460_detect(struct drm_connector *connector,
> - bool force)
> -{
> - return connector_status_connected;
> -}
> -
> -void ptn3460_connector_destroy(struct drm_connector *connector)
> -{
> - drm_connector_cleanup(connector);
> -}
> -
> -struct drm_connector_funcs ptn3460_connector_funcs = {
> - .dpms = drm_helper_connector_dpms,
> - .fill_modes = drm_helper_probe_single_connector_modes,
> - .detect = ptn3460_detect,
> - .destroy = ptn3460_connector_destroy,
> -};
> -
> -int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
> - struct i2c_client *client, struct device_node *node)
> +struct drm_bridge *ptn3460_init(struct drm_device *dev,
> + struct drm_encoder *encoder,
> + struct i2c_client *client,
> + struct device_node *node)
> {
> int ret;
> struct drm_bridge *bridge;
> @@ -267,13 +183,13 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
> bridge = devm_kzalloc(dev->dev, sizeof(*bridge), GFP_KERNEL);
> if (!bridge) {
> DRM_ERROR("Failed to allocate drm bridge\n");
> - return -ENOMEM;
> + return NULL;
I think you could handle error case correctly. Please return
ERR_PTR(-ENOMEM) instead of NULL, and below codes also.
Thanks,
Inki Dae
> }
>
> ptn_bridge = devm_kzalloc(dev->dev, sizeof(*ptn_bridge), GFP_KERNEL);
> if (!ptn_bridge) {
> DRM_ERROR("Failed to allocate ptn bridge\n");
> - return -ENOMEM;
> + return NULL;
> }
>
> ptn_bridge->client = client;
> @@ -285,7 +201,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
> GPIOF_OUT_INIT_HIGH, "PTN3460_PD_N");
> if (ret) {
> DRM_ERROR("Request powerdown-gpio failed (%d)\n", ret);
> - return ret;
> + return NULL;
> }
> }
>
> @@ -300,7 +216,7 @@ int ptn3460_init(struct drm_device *dev, struct drm_encoder *encoder,
> if (ret) {
> DRM_ERROR("Request reset-gpio failed (%d)\n", ret);
> gpio_free(ptn_bridge->gpio_pd_n);
> - return ret;
> + return NULL;
> }
> }
>
next prev parent reply other threads:[~2014-07-21 7:55 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 20:43 [PATCH V5 00/12] drm/exynos: few patches to enhance bridge chip support Ajay Kumar
2014-07-17 20:43 ` [RESEND PATCH V5 01/12] drm/exynos: Move DP setup out of hotplug workqueue Ajay Kumar
2014-07-22 14:59 ` Sean Paul
2014-07-23 11:22 ` Ajay kumar
2014-07-23 14:42 ` Sean Paul
2014-07-23 15:18 ` Ajay kumar
2014-07-24 20:16 ` Sean Paul
2014-07-17 20:43 ` [RESEND PATCH V5 02/12] drm/panel: add prepare and unprepare routines Ajay Kumar
2014-07-17 20:43 ` [RESEND PATCH V5 03/12] drm/exynos: dp: modify driver to support drm_panel Ajay Kumar
2014-07-21 8:02 ` Thierry Reding
2014-07-21 8:14 ` Thierry Reding
2014-07-21 12:18 ` Ajay kumar
2014-07-17 20:43 ` [PATCH V5 04/12] drm/panel: Add driver for lvds/edp based panels Ajay Kumar
2014-07-17 20:43 ` [PATCH V5 05/12] Documentation: Add DT bindings for panel-lvds driver Ajay Kumar
2014-07-17 20:50 ` Ajay kumar
2014-07-17 22:48 ` Thierry Reding
2014-07-18 6:48 ` Ajay kumar
2014-07-21 7:52 ` Thierry Reding
2014-07-21 12:30 ` Ajay kumar
2014-07-17 20:43 ` [RESEND PATCH V5 06/12] drm/bridge: add helper functions to support bridge chain Ajay Kumar
2014-07-17 20:43 ` [PATCH V5 07/12] drm/bridge: Add a driver which binds drm_bridge with drm_panel Ajay Kumar
2014-07-17 20:43 ` [RESEND PATCH V5 08/12] drm/bridge: ptn3460: Support bridge chaining Ajay Kumar
2014-07-21 7:55 ` Inki Dae [this message]
2014-07-21 8:22 ` Thierry Reding
2014-07-21 11:58 ` Ajay kumar
2014-07-21 12:40 ` Thierry Reding
2014-07-22 6:21 ` Ajay kumar
2014-07-17 20:43 ` [RESEND PATCH V5 09/12] drm/exynos: dp: create bridge chain using ptn3460 and panel_binder Ajay Kumar
2014-07-17 20:43 ` [PATCH V5 10/12] drm/bridge: Add ps8622/ps8625 bridge driver Ajay Kumar
2014-07-17 20:43 ` [PATCH V5 11/12] Documentation: Add DT bindings for " Ajay Kumar
2014-07-17 20:51 ` Ajay kumar
2014-07-21 7:06 ` Thierry Reding
2014-07-21 10:54 ` Ajay kumar
2014-07-17 20:43 ` [RESEND PATCH V5 12/12] drm/exynos: Add ps8622 lvds bridge discovery to DP driver Ajay Kumar
2014-07-21 7:10 ` Thierry Reding
2014-07-21 11:28 ` Ajay kumar
2014-07-21 12:54 ` Thierry Reding
2014-07-21 14:36 ` Ajay kumar
2014-07-21 14:44 ` Thierry Reding
2014-07-22 6:05 ` Ajay kumar
2014-07-22 7:51 ` Thierry Reding
2014-07-21 7:51 ` [PATCH V5 00/12] drm/exynos: few patches to enhance bridge chip support Inki Dae
2014-07-21 11:33 ` Ajay kumar
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=53CCC763.30607@samsung.com \
--to=inki.dae@samsung.com \
--cc=ajaykumar.rs@samsung.com \
--cc=ajaynumb@gmail.com \
--cc=cpgs@samsung.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javier@dowhile0.org \
--cc=jg1.han@samsung.com \
--cc=joshi@samsung.com \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=prashanth.g@samsung.com \
--cc=robdclark@gmail.com \
--cc=seanpaul@google.com \
--cc=thierry.reding@gmail.com \
/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