dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Robert Foss <rfoss@kernel.org>, Jonas Karlman <jonas@kwiboo.se>,
	dri-devel@lists.freedesktop.org,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>
Subject: Re: [PATCH 1/2] drm/bridge: add ->edid_read hook and drm_bridge_edid_read()
Date: Wed, 27 Dec 2023 13:45:34 +0200	[thread overview]
Message-ID: <877ckzswbl.fsf@intel.com> (raw)
In-Reply-To: <CAA8EJprSKWXZ20-=1-Wx+TkG+6BnYMvqTwtqFA1nwFr=6Rn1Xw@mail.gmail.com>

On Fri, 22 Dec 2023, Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:
> On Thu, 26 Oct 2023 at 12:40, Jani Nikula <jani.nikula@intel.com> wrote:
>>
>> Add new struct drm_edid based ->edid_read hook and
>> drm_bridge_edid_read() function to call the hook.
>>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/drm_bridge.c | 46 +++++++++++++++++++++++++++++++++++-
>>  include/drm/drm_bridge.h     | 33 ++++++++++++++++++++++++++
>>  2 files changed, 78 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
>> index 30d66bee0ec6..e1cfba2ff583 100644
>> --- a/drivers/gpu/drm/drm_bridge.c
>> +++ b/drivers/gpu/drm/drm_bridge.c
>> @@ -27,8 +27,9 @@
>>  #include <linux/mutex.h>
>>
>>  #include <drm/drm_atomic_state_helper.h>
>> -#include <drm/drm_debugfs.h>
>>  #include <drm/drm_bridge.h>
>> +#include <drm/drm_debugfs.h>
>> +#include <drm/drm_edid.h>
>>  #include <drm/drm_encoder.h>
>>  #include <drm/drm_file.h>
>>  #include <drm/drm_of.h>
>> @@ -1206,6 +1207,47 @@ int drm_bridge_get_modes(struct drm_bridge *bridge,
>>  }
>>  EXPORT_SYMBOL_GPL(drm_bridge_get_modes);
>>
>> +/**
>> + * drm_bridge_edid_read - read the EDID data of the connected display
>> + * @bridge: bridge control structure
>> + * @connector: the connector to read EDID for
>> + *
>> + * If the bridge supports output EDID retrieval, as reported by the
>> + * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.edid_read to get
>> + * the EDID and return it. Otherwise return NULL.
>> + *
>> + * If &drm_bridge_funcs.edid_read is not set, fall back to using
>> + * drm_bridge_get_edid() and wrapping it in struct drm_edid.
>> + *
>> + * RETURNS:
>> + * The retrieved EDID on success, or NULL otherwise.
>
> Wouldn't it be better to return an ERR_PTR instead of NULL?

I don't think so. The existing drm_bridge_get_edid() returns NULL on
errors. The ->get_edid hook returns NULL on errors. The new ->edid_read
returns NULL on errors. The drm_get_edid() and drm_edid_read() functions
return NULL on errors.

It would be surprising if one of the functions started returning error
pointers.

I don't see any added benefit with error pointers here. The ->edid_read
hook could be made to return error pointers too, but then there's quite
the burden in making all drivers return sensible values where the
difference in error code actually matters. And which error scenarios do
we want to differentiate here? How should we handle them differently?


BR,
Jani.


>
>> + */
>> +const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge,
>> +                                           struct drm_connector *connector)
>> +{
>> +       if (!(bridge->ops & DRM_BRIDGE_OP_EDID))
>> +               return NULL;
>> +
>> +       /* Transitional: Fall back to ->get_edid. */
>> +       if (!bridge->funcs->edid_read) {
>> +               const struct drm_edid *drm_edid;
>> +               struct edid *edid;
>> +
>> +               edid = drm_bridge_get_edid(bridge, connector);
>> +               if (!edid)
>> +                       return NULL;
>> +
>> +               drm_edid = drm_edid_alloc(edid, (edid->extensions + 1) * EDID_LENGTH);
>> +
>> +               kfree(edid);
>> +
>> +               return drm_edid;
>> +       }
>> +
>> +       return bridge->funcs->edid_read(bridge, connector);
>> +}
>> +EXPORT_SYMBOL_GPL(drm_bridge_edid_read);
>
> [skipped the rest]

-- 
Jani Nikula, Intel

  reply	other threads:[~2023-12-27 11:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  9:39 [PATCH 0/2] drm/bridge: start moving towards struct drm_edid Jani Nikula
2023-10-26  9:39 ` [PATCH 1/2] drm/bridge: add ->edid_read hook and drm_bridge_edid_read() Jani Nikula
2023-12-22 19:27   ` Dmitry Baryshkov
2023-12-27 11:45     ` Jani Nikula [this message]
2023-10-26  9:39 ` [PATCH 2/2] drm/bridge: switch to drm_bridge_read_edid() Jani Nikula
2023-11-14 11:53 ` [PATCH 0/2] drm/bridge: start moving towards struct drm_edid Jani Nikula
2023-12-19 12:15   ` Jani Nikula
2023-12-22  8:09     ` Neil Armstrong
2023-12-22  9:24       ` Jani Nikula
2023-12-22 15:53         ` Jani Nikula
2024-01-03 10:13           ` Jani Nikula

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=877ckzswbl.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.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).