dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
	Tejas Vipin <tejasvipin76@gmail.com>,
	Laurent.pinchart@ideasonboard.com, patrik.r.jakobsson@gmail.com,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	airlied@gmail.com, daniel@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/gma500: replace drm_detect_hdmi_monitor() with drm_display_info.is_hdmi
Date: Thu, 12 Sep 2024 12:30:12 +0300	[thread overview]
Message-ID: <871q1pi5i3.fsf@intel.com> (raw)
In-Reply-To: <42b27020-a68e-4c43-800e-61977324be78@suse.de>

On Thu, 12 Sep 2024, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Hi
>
> Am 12.09.24 um 10:48 schrieb Jani Nikula:
>> On Thu, 12 Sep 2024, Thomas Zimmermann <tzimmermann@suse.de> wrote:
>>> Hi
>>>
>>> Am 11.09.24 um 20:06 schrieb Tejas Vipin:
>>>> Replace drm_detect_hdmi_monitor() with drm_display_info.is_hdmi since
>>>> monitor HDMI information is available after EDID is parsed. Additionally
>>>> rewrite the code the code to have fewer indentation levels.
>>> The problem is that the entire logic is outdated. The content
>>> of cdv_hdmi_detect() should go into cdv_hdmi_get_modes(), the detect_ctx
>>> callback should be set to drm_connector_helper_detect_from_ddc() and
>>> cdv_hdmi_detect() should be deleted. The result is that ->detect_ctx
>>> will detect the presence of a display and ->get_modes will update EDID
>>> and other properties.
>> I guess I didn't get the memo on this one.
>>
>> What's the problem with reading the EDID at detect? The subsequent
>> drm_edid_connector_add_modes() called from .get_modes() does not need to
>> read the EDID again.
>
> With drm_connector_helper_detect_from_ddc() there is already a helper 
> for detection. It makes sense to use it. And if we continue to update 
> the properties in detect (instead of get_modes), what is the correct 
> connector_status on errors? Right now and with the patch applied, detect 
> returns status_disconnected on errors. But this isn't correct if there 
> actually is a display. By separating detect and get_modes cleanly, we 
> can detect the display reliably, but also handle errors better than we 
> currently do in gma500. Get_modes is already expected to update the EDID 
> property, [1] for detect it's not so clear AFAICT. I think that from a 
> design perspective, it makes sense to have a read-only function that 
> only detects the physical state of the connector and a read-write 
> function that updates the connector's properties. Best regards Thomas 
> [1] 
> https://elixir.bootlin.com/linux/v6.10.9/source/include/drm/drm_modeset_helper_vtables.h#L865 

So what if you can probe DDC but can't actually read an EDID of any
kind? IMO that's a detect failure.

Or how about things like CEC attach? Seems natural to do it at
.detect(). Doing it at .get_modes() just seems wrong. However, it needs
the EDID for physical address.

I just don't think one size fits all here.

BR,
Jani.


>
>>
>> I think it should be fine to do incremental refactors like the patch at
>> hand (modulo some issues I mention below).
>>
>> BR,
>> Jani.
>>
>>
>>> Do you have  a device for testing such a change?
>>>
>>> Best regards
>>> Thomas
>>>
>>>> Signed-off-by: Tejas Vipin <tejasvipin76@gmail.com>
>>>> ---
>>>> Changes in v2:
>>>>       - Use drm_edid instead of edid
>>>>
>>>> Link to v1: https://lore.kernel.org/all/20240910051856.700210-1-tejasvipin76@gmail.com/
>>>> ---
>>>>    drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 24 +++++++++++++-----------
>>>>    1 file changed, 13 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
>>>> index 2d95e0471291..701f8bbd5f2b 100644
>>>> --- a/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
>>>> +++ b/drivers/gpu/drm/gma500/cdv_intel_hdmi.c
>>>> @@ -128,23 +128,25 @@ static enum drm_connector_status cdv_hdmi_detect(
>>>>    {
>>>>    	struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
>>>>    	struct mid_intel_hdmi_priv *hdmi_priv = gma_encoder->dev_priv;
>>>> -	struct edid *edid = NULL;
>>>> +	const struct drm_edid *drm_edid;
>>>> +	int ret;
>>>>    	enum drm_connector_status status = connector_status_disconnected;
>>>>    
>>>> -	edid = drm_get_edid(connector, connector->ddc);
>>>> +	drm_edid = drm_edid_read_ddc(connector, connector->ddc);
>> Just drm_edid_read() is enough when you're using connector->ddc.
>>
>>>> +	ret = drm_edid_connector_update(connector, drm_edid);
>>>>    
>>>>    	hdmi_priv->has_hdmi_sink = false;
>>>>    	hdmi_priv->has_hdmi_audio = false;
>>>> -	if (edid) {
>>>> -		if (edid->input & DRM_EDID_INPUT_DIGITAL) {
>>>> -			status = connector_status_connected;
>>>> -			hdmi_priv->has_hdmi_sink =
>>>> -						drm_detect_hdmi_monitor(edid);
>>>> -			hdmi_priv->has_hdmi_audio =
>>>> -						drm_detect_monitor_audio(edid);
>>>> -		}
>>>> -		kfree(edid);
>>>> +	if (ret)
>> This error path leaks the EDID.
>>
>>>> +		return status;
>>>> +
>>>> +	if (drm_edid_is_digital(drm_edid)) {
>>>> +		status = connector_status_connected;
>>>> +		hdmi_priv->has_hdmi_sink = connector->display_info.is_hdmi;
>>>> +		hdmi_priv->has_hdmi_audio = connector->display_info.has_audio;
>>>>    	}
>>>> +	drm_edid_free(drm_edid);
>>>> +
>>>>    	return status;
>>>>    }
>>>>    

-- 
Jani Nikula, Intel

  reply	other threads:[~2024-09-12  9:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 18:06 [PATCH v2] drm/gma500: replace drm_detect_hdmi_monitor() with drm_display_info.is_hdmi Tejas Vipin
2024-09-12  7:19 ` Thomas Zimmermann
2024-09-12  8:48   ` Jani Nikula
2024-09-12  8:56     ` Jani Nikula
2024-09-12  9:26       ` Thomas Zimmermann
2024-09-12  9:38         ` Jani Nikula
2024-09-12 10:45           ` Thomas Zimmermann
2024-09-12 11:25             ` Jani Nikula
2024-09-12 13:10               ` Thomas Zimmermann
2024-09-12 13:25                 ` Jani Nikula
2024-09-12  9:18     ` Thomas Zimmermann
2024-09-12  9:30       ` Jani Nikula [this message]
2024-09-12 11:08         ` Thomas Zimmermann
2024-09-12 13:30           ` Ville Syrjälä
2024-09-12 14:29   ` Tejas Vipin
2024-09-23  9:36     ` 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=871q1pi5i3.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=tejasvipin76@gmail.com \
    --cc=tzimmermann@suse.de \
    /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).