From: Daniel Vetter <daniel@ffwll.ch>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: david@lechnology.com, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 03/11] drm/simple-kms-helper: Add drm_simple_connector_create()
Date: Mon, 21 Jan 2019 10:22:01 +0100 [thread overview]
Message-ID: <20190121092201.GM3271@phenom.ffwll.local> (raw)
In-Reply-To: <20190120114318.49199-4-noralf@tronnes.org>
On Sun, Jan 20, 2019 at 12:43:10PM +0100, Noralf Trønnes wrote:
> This adds a function that creates a simple connector that has only one
> static mode. Additionally add a helper to set &drm_mode_config width
> and height from the static mode.
>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
> ---
> drivers/gpu/drm/drm_simple_kms_helper.c | 122 ++++++++++++++++++++++++
> include/drm/drm_simple_kms_helper.h | 6 ++
> 2 files changed, 128 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 917812448d1b..ca29975afefe 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -11,6 +11,8 @@
> #include <drm/drm_atomic.h>
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_device.h>
> +#include <drm/drm_modes.h>
> #include <drm/drm_plane_helper.h>
> #include <drm/drm_simple_kms_helper.h>
> #include <linux/slab.h>
> @@ -299,4 +301,124 @@ int drm_simple_display_pipe_init(struct drm_device *dev,
> }
> EXPORT_SYMBOL(drm_simple_display_pipe_init);
>
> +static const struct drm_connector_helper_funcs drm_simple_connector_hfuncs = {
> + /* dummy for the atomic helper */
> +};
> +
> +static int drm_simple_connector_fill_modes(struct drm_connector *connector,
> + uint32_t maxX, uint32_t maxY)
> +{
> + return 1;
> +}
> +
> +static void drm_simple_connector_destroy(struct drm_connector *connector)
> +{
> + drm_connector_cleanup(connector);
> + kfree(connector);
> +}
> +
> +static const struct drm_connector_funcs drm_simple_connector_funcs = {
> + .reset = drm_atomic_helper_connector_reset,
> + .fill_modes = drm_simple_connector_fill_modes,
> + .destroy = drm_simple_connector_destroy,
> + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +/**
> + * drm_simple_connector_create - Create a connector with one static mode
> + * @dev: DRM device
> + * @connector_type: Connector type
> + * @mode: Supported display mode
> + * @rotation: Initial @mode rotation in degrees
We have rotation properties for this, pls don't use degress here.
Also would be good to wire this up with the rotation property Hans added
recently, for pre-rotated screens (see the kerneldoc for "panel
orientation" and drm_connector_init_panel_orientation_property()). So that
userspace knows how to rotate its rendering to make everything look
correct in the end again.
> + *
> + * This function creates a &drm_connector that has one fixed &drm_display_mode
> + * which will be rotated according to @rotation.
From a functionality pov this is very close to a panel wrapped into a
bridge. I think it would be good to differentiate a bit between these two
cases more. After all there was a really long discussion about how the
panel stuff does or does not exactly fit for tinydrm, would be good to
summarize this here and at least point at drm_panel_bridge_add().
Also would be good to explain in the overview DOC comment that this is a
fully independent part of the simple helpers, and drivers can use one or
the other.
-Daniel
> + *
> + * Returns:
> + * Pointer to connector on success, or ERR_PTR on failure.
> + */
> +struct drm_connector *
> +drm_simple_connector_create(struct drm_device *dev, int connector_type,
> + const struct drm_display_mode *mode,
> + unsigned int rotation)
> +{
> + struct drm_display_mode *mode_dup = NULL;
> + struct drm_connector *connector;
> + int ret;
> +
> + connector = kzalloc(sizeof(*connector), GFP_KERNEL);
> + if (!connector)
> + return ERR_PTR(-ENOMEM);
> +
> + drm_connector_helper_add(connector, &drm_simple_connector_hfuncs);
> + ret = drm_connector_init(dev, connector, &drm_simple_connector_funcs,
> + connector_type);
> + if (ret)
> + goto err_free;
> +
> + connector->status = connector_status_connected;
> +
> + mode_dup = drm_mode_duplicate(dev, mode);
> + if (!mode_dup) {
> + ret = -ENOMEM;
> + goto err_cleanup;
> + }
> +
> + if (rotation == 90 || rotation == 270) {
> + swap(mode_dup->hdisplay, mode_dup->vdisplay);
> + swap(mode_dup->hsync_start, mode_dup->vsync_start);
> + swap(mode_dup->hsync_end, mode_dup->vsync_end);
> + swap(mode_dup->htotal, mode_dup->vtotal);
> + swap(mode_dup->width_mm, mode_dup->height_mm);
> + } else if (rotation != 0 && rotation != 180) {
> + DRM_ERROR("Illegal rotation value %u\n", rotation);
> + ret = -EINVAL;
> + goto err_cleanup;
> + }
> +
> + mode_dup->type |= DRM_MODE_TYPE_PREFERRED;
> + if (mode_dup->name[0] == '\0')
> + drm_mode_set_name(mode_dup);
> +
> + list_add(&mode_dup->head, &connector->modes);
> +
> + connector->display_info.width_mm = mode_dup->width_mm;
> + connector->display_info.height_mm = mode_dup->height_mm;
> +
> + return connector;
> +
> +err_cleanup:
> + drm_connector_cleanup(connector);
> + drm_mode_destroy(dev, mode_dup);
> +err_free:
> + kfree(connector);
> +
> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL(drm_simple_connector_create);
> +
> +/**
> + * drm_simple_connector_set_mode_config - Set &drm_mode_config width and height
> + * @connector: Connector
> + *
> + * This function sets the &drm_mode_config min/max width and height based on the
> + * connector fixed display mode.
> + */
> +void drm_simple_connector_set_mode_config(struct drm_connector *connector)
> +{
> + struct drm_mode_config *mode_config = &connector->dev->mode_config;
> + struct drm_display_mode *mode;
> +
> + mode = list_first_entry(&connector->modes, struct drm_display_mode, head);
> + if (WARN_ON(!mode))
> + return;
> +
> + mode_config->min_width = mode->hdisplay;
> + mode_config->max_width = mode->hdisplay;
> + mode_config->min_height = mode->vdisplay;
> + mode_config->max_height = mode->vdisplay;
> +}
> +EXPORT_SYMBOL(drm_simple_connector_set_mode_config);
> +
> MODULE_LICENSE("GPL");
> diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h
> index 451960438a29..ab3d847b7713 100644
> --- a/include/drm/drm_simple_kms_helper.h
> +++ b/include/drm/drm_simple_kms_helper.h
> @@ -182,4 +182,10 @@ int drm_simple_display_pipe_init(struct drm_device *dev,
> const uint64_t *format_modifiers,
> struct drm_connector *connector);
>
> +struct drm_connector *
> +drm_simple_connector_create(struct drm_device *dev, int connector_type,
> + const struct drm_display_mode *mode,
> + unsigned int rotation);
> +void drm_simple_connector_set_mode_config(struct drm_connector *connector);
> +
> #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */
> --
> 2.20.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-01-21 9:22 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-20 11:43 [PATCH 00/11] drm/tinydrm: Remove tinydrm_device Noralf Trønnes
2019-01-20 11:43 ` [PATCH 01/11] drm: Add devm_drm_dev_init/register Noralf Trønnes
2019-01-21 6:11 ` Sam Ravnborg
2019-01-21 13:09 ` Noralf Trønnes
2019-01-21 9:10 ` Daniel Vetter
2019-01-21 9:55 ` Daniel Vetter
2019-01-21 12:21 ` Noralf Trønnes
2019-01-22 9:32 ` Daniel Vetter
2019-01-22 19:07 ` Noralf Trønnes
2019-01-22 19:30 ` Daniel Vetter
2019-01-23 10:54 ` Noralf Trønnes
2019-01-24 10:43 ` devm actions and hw clenaup (was Re: [PATCH 01/11] drm: Add devm_drm_dev_init/register) Daniel Vetter
2019-01-24 17:46 ` Greg KH
2019-01-24 17:57 ` Daniel Vetter
2019-01-29 14:34 ` Noralf Trønnes
2019-01-29 15:16 ` Greg KH
2019-01-29 16:50 ` Daniel Vetter
2019-01-29 17:26 ` Noralf Trønnes
2019-01-29 17:36 ` Greg KH
2019-01-29 18:10 ` Daniel Vetter
2019-01-29 19:27 ` Greg KH
2019-01-29 23:14 ` Daniel Vetter
2019-01-30 7:14 ` Greg KH
2019-01-22 9:35 ` [PATCH 01/11] drm: Add devm_drm_dev_init/register Daniel Vetter
2019-01-20 11:43 ` [PATCH 02/11] drm/modes: Add DRM_SIMPLE_MODE() Noralf Trønnes
2019-01-20 16:37 ` Ilia Mirkin
2019-01-20 17:27 ` Noralf Trønnes
2019-01-20 11:43 ` [PATCH 03/11] drm/simple-kms-helper: Add drm_simple_connector_create() Noralf Trønnes
2019-01-20 22:14 ` Sam Ravnborg
2019-01-21 9:22 ` Daniel Vetter [this message]
2019-01-24 14:38 ` Noralf Trønnes
2019-01-24 14:53 ` Hans de Goede
2019-01-25 12:05 ` Noralf Trønnes
2019-01-20 11:43 ` [PATCH 04/11] drm/tinydrm: Remove tinydrm_display_pipe_init() Noralf Trønnes
2019-01-21 6:30 ` Sam Ravnborg
2019-01-21 9:15 ` Daniel Vetter
2019-01-28 14:46 ` Noralf Trønnes
2019-01-20 11:43 ` [PATCH 05/11] drm/tinydrm/mipi-dbi: Add drm_to_mipi_dbi() Noralf Trønnes
2019-01-21 6:34 ` Sam Ravnborg
2019-01-20 11:43 ` [PATCH 06/11] drm/tinydrm: Remove tinydrm_shutdown() Noralf Trønnes
2019-01-21 7:12 ` Sam Ravnborg
2019-01-20 11:43 ` [PATCH 07/11] drm/tinydrm/repaper: Use devm_drm_dev_*() Noralf Trønnes
2019-01-20 22:22 ` Sam Ravnborg
2019-01-20 22:25 ` Sam Ravnborg
2019-01-21 13:15 ` Noralf Trønnes
2019-01-20 11:43 ` [PATCH 08/11] drm/tinydrm: " Noralf Trønnes
2019-01-20 11:43 ` [PATCH 09/11] drm/tinydrm: Remove tinydrm_device Noralf Trønnes
2019-01-21 8:13 ` Sam Ravnborg
2019-01-21 9:29 ` Daniel Vetter
2019-01-21 13:30 ` Noralf Trønnes
2019-01-20 11:43 ` [PATCH 10/11] drm/tinydrm: Use drm_dev_enter/exit() Noralf Trønnes
2019-01-20 11:43 ` [PATCH 11/11] drm/fb-helper: generic: Don't take module ref for fbcon Noralf Trønnes
2019-01-21 9:05 ` Daniel Vetter
2019-01-28 14:40 ` Noralf Trønnes
2019-01-29 8:45 ` Daniel Vetter
2019-01-21 8:34 ` [PATCH 00/11] drm/tinydrm: Remove tinydrm_device Sam Ravnborg
2019-01-21 13:20 ` Noralf Trønnes
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=20190121092201.GM3271@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=david@lechnology.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=noralf@tronnes.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 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.