From: Jani Nikula <jani.nikula@linux.intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>,
airlied@redhat.com, jfalempe@redhat.com, daniel@ffwll.ch,
airlied@linux.ie, mripard@kernel.org,
maarten.lankhorst@linux.intel.com
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: [PATCH v3 3/7] drm/mgag200: Implement connector's get_modes with helper
Date: Tue, 07 Jun 2022 12:41:40 +0300 [thread overview]
Message-ID: <87sfogq08b.fsf@intel.com> (raw)
In-Reply-To: <20220516134343.6085-4-tzimmermann@suse.de>
On Mon, 16 May 2022, Thomas Zimmermann <tzimmermann@suse.de> wrote:
> Provide drm_connector_helper_get_modes_from_ddc() to implement the
> connector's get_modes callback. The new helper updates the connector
> from DDC-provided EDID data.
When adding drm core code, please do *not* prefix with "drm/mgag200".
I, and I believe many people, totally ignore changes to a lot of
drivers, while trying to closely follow drm core changes.
Going forward, I'll be slightly changing what the .get_modes hook is
supposed to do, so this feels like a bit of a detour to me. Anyone
picking this up is up for another refactor later on. Oh well.
BR,
Jani.
PS. There's a // comment in there.
>
> v2:
> * clear property if EDID is NULL in helper
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
> Tested-by: Jocelyn Falempe <jfalempe@redhat.com>
> ---
> drivers/gpu/drm/drm_probe_helper.c | 36 ++++++++++++++++++++++++++
> drivers/gpu/drm/mgag200/mgag200_mode.c | 17 +++---------
> include/drm/drm_probe_helper.h | 2 ++
> 3 files changed, 42 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
> index 682359512996..d77f17867195 100644
> --- a/drivers/gpu/drm/drm_probe_helper.c
> +++ b/drivers/gpu/drm/drm_probe_helper.c
> @@ -964,3 +964,39 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
> return changed;
> }
> EXPORT_SYMBOL(drm_helper_hpd_irq_event);
> +
> +/**
> + * drm_connector_helper_get_modes_from_ddc - Updates the connector's EDID
> + * property from the connector's
> + * DDC channel
> + * @connector: The connector
> + *
> + * Returns:
> + * The number of detected display modes.
> + *
> + * Uses a connector's DDC channel to retrieve EDID data and update the
> + * connector's EDID property and display modes. Drivers can use this
> + * function to implement struct &drm_connector_helper_funcs.get_modes
> + * for connectors with a DDC channel.
> + */
> +int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
> +{
> + struct edid *edid;
> + int count = 0;
> +
> + if (!connector->ddc)
> + return 0;
> +
> + edid = drm_get_edid(connector, connector->ddc);
> +
> + // clears property if EDID is NULL
> + drm_connector_update_edid_property(connector, edid);
> +
> + if (edid) {
> + count = drm_add_edid_modes(connector, edid);
> + kfree(edid);
> + }
> +
> + return count;
> +}
> +EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc);
> diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
> index b227891d01ec..4c0680dd1a78 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
> @@ -689,26 +689,17 @@ static void mgag200_disable_display(struct mga_device *mdev)
> * Connector
> */
>
> -static int mga_vga_get_modes(struct drm_connector *connector)
> +static int mgag200_vga_connector_helper_get_modes(struct drm_connector *connector)
> {
> struct mga_device *mdev = to_mga_device(connector->dev);
> - struct mga_connector *mga_connector = to_mga_connector(connector);
> - struct edid *edid;
> - int ret = 0;
> + int ret;
>
> /*
> * Protect access to I/O registers from concurrent modesetting
> * by acquiring the I/O-register lock.
> */
> mutex_lock(&mdev->rmmio_lock);
> -
> - edid = drm_get_edid(connector, &mga_connector->i2c->adapter);
> - if (edid) {
> - drm_connector_update_edid_property(connector, edid);
> - ret = drm_add_edid_modes(connector, edid);
> - kfree(edid);
> - }
> -
> + ret = drm_connector_helper_get_modes_from_ddc(connector);
> mutex_unlock(&mdev->rmmio_lock);
>
> return ret;
> @@ -828,7 +819,7 @@ static void mga_connector_destroy(struct drm_connector *connector)
> }
>
> static const struct drm_connector_helper_funcs mga_vga_connector_helper_funcs = {
> - .get_modes = mga_vga_get_modes,
> + .get_modes = mgag200_vga_connector_helper_get_modes,
> .mode_valid = mga_vga_mode_valid,
> };
>
> diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h
> index 48300aa6ca71..c80cab7a53b7 100644
> --- a/include/drm/drm_probe_helper.h
> +++ b/include/drm/drm_probe_helper.h
> @@ -26,4 +26,6 @@ void drm_kms_helper_poll_disable(struct drm_device *dev);
> void drm_kms_helper_poll_enable(struct drm_device *dev);
> bool drm_kms_helper_is_poll_worker(void);
>
> +int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector);
> +
> #endif
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2022-06-07 9:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 13:43 [PATCH v3 0/7] drm/mgag200: Various cleanups Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 1/7] drm/mgag200: Acquire I/O lock while reading EDID Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 2/7] drm/mgag200: Fail on I2C initialization errors Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 3/7] drm/mgag200: Implement connector's get_modes with helper Thomas Zimmermann
2022-06-07 9:41 ` Jani Nikula [this message]
2022-05-16 13:43 ` [PATCH v3 4/7] drm/mgag200: Switch I2C code to managed cleanup Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 5/7] drm/mgag200: Remove struct mga_connector Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 6/7] drm/mgag200: Test memory requirements in drm_mode_config_funcs.mode_valid Thomas Zimmermann
2022-05-16 13:43 ` [PATCH v3 7/7] drm/mgag200: Split up connector's mode_valid helper Thomas Zimmermann
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=87sfogq08b.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@linux.ie \
--cc=airlied@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jfalempe@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.