devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hyun Kwon <hyun.kwon@xilinx.com>
To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Michal Simek <michal.simek@xilinx.com>,
	Hyun Kwon <hyun.kwon@xilinx.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH v3 8/8] drm: xlnx: zynqmp_dp: Add drm properties
Date: Mon, 15 Jan 2018 17:57:11 -0800	[thread overview]
Message-ID: <1516067831-11382-8-git-send-email-hyun.kwon@xilinx.com> (raw)
In-Reply-To: <1516067831-11382-1-git-send-email-hyun.kwon@xilinx.com>

Add drm properties for DisplayPort synchronous mode and bpc
configurations.

Signed-off-by: Hyun Kwon <hyun.kwon@xilinx.com>
---
v2
- Split from the original patch
---
---
 drivers/gpu/drm/xlnx/zynqmp_dp.c | 116 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 114 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 9c9f4df..e1e8237 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -302,6 +302,8 @@ struct zynqmp_dp_config {
  * struct zynqmp_dp - Xilinx DisplayPort core
  * @encoder: the drm encoder structure
  * @connector: the drm connector structure
+ * @sync_prop: synchronous mode property
+ * @bpc_prop: bpc mode property
  * @dev: device structure
  * @dpsub: Display subsystem
  * @drm: DRM core
@@ -323,6 +325,8 @@ struct zynqmp_dp_config {
 struct zynqmp_dp {
        struct drm_encoder encoder;
        struct drm_connector connector;
+       struct drm_property *sync_prop;
+       struct drm_property *bpc_prop;
        struct device *dev;
        struct zynqmp_dpsub *dpsub;
        struct drm_device *drm;
@@ -1116,6 +1120,37 @@ static void zynqmp_dp_update_misc(struct zynqmp_dp *dp)
 }

 /**
+ * zynqmp_dp_set_sync_mode - Set the sync mode bit in the software misc state
+ * @dp: DisplayPort IP core structure
+ * @mode: flag if the sync mode should be on or off
+ *
+ * Set the bit in software misc state. To apply to hardware,
+ * zynqmp_dp_update_misc() should be called.
+ */
+static void zynqmp_dp_set_sync_mode(struct zynqmp_dp *dp, bool mode)
+{
+       struct zynqmp_dp_config *config = &dp->config;
+
+       if (mode)
+               config->misc0 |= ZYNQMP_DP_TX_MAIN_STREAM_MISC0_SYNC;
+       else
+               config->misc0 &= ~ZYNQMP_DP_TX_MAIN_STREAM_MISC0_SYNC;
+}
+
+/**
+ * zynqmp_dp_get_sync_mode - Get the sync mode state
+ * @dp: DisplayPort IP core structure
+ *
+ * Return: true if the sync mode is on, or false
+ */
+static bool zynqmp_dp_get_sync_mode(struct zynqmp_dp *dp)
+{
+       struct zynqmp_dp_config *config = &dp->config;
+
+       return !!(config->misc0 & ZYNQMP_DP_TX_MAIN_STREAM_MISC0_SYNC);
+}
+
+/**
  * zynqmp_dp_set_bpc - Set bpc value in software misc state
  * @dp: DisplayPort IP core structure
  * @bpc: bits per component
@@ -1165,6 +1200,17 @@ static u8 zynqmp_dp_set_bpc(struct zynqmp_dp *dp, u8 bpc)
 }

 /**
+ * zynqmp_dp_get_bpc - Set bpc value from software state
+ * @dp: DisplayPort IP core structure
+ *
+ * Return: current bpc value
+ */
+static u8 zynqmp_dp_get_bpc(struct zynqmp_dp *dp)
+{
+       return dp->config.bpc;
+}
+
+/**
  * zynqmp_dp_encoder_mode_set_transfer_unit - Set the transfer unit values
  * @dp: DisplayPort IP core structure
  * @mode: requested display mode
@@ -1368,6 +1414,51 @@ static void zynqmp_dp_connector_destroy(struct drm_connector *connector)
        drm_connector_cleanup(connector);
 }

+static int
+zynqmp_dp_connector_atomic_set_property(struct drm_connector *connector,
+                                       struct drm_connector_state *state,
+                                       struct drm_property *property,
+                                       uint64_t val)
+{
+       struct zynqmp_dp *dp = connector_to_dp(connector);
+       int ret;
+
+       if (property == dp->sync_prop) {
+               zynqmp_dp_set_sync_mode(dp, val);
+       } else if (property == dp->bpc_prop) {
+               u8 bpc;
+
+               bpc = zynqmp_dp_set_bpc(dp, val);
+               if (bpc) {
+                       drm_object_property_set_value(&connector->base,
+                                                     property, bpc);
+                       ret = -EINVAL;
+               }
+       } else {
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int
+zynqmp_dp_connector_atomic_get_property(struct drm_connector *connector,
+                                       const struct drm_connector_state *state,
+                                       struct drm_property *property,
+                                       uint64_t *val)
+{
+       struct zynqmp_dp *dp = connector_to_dp(connector);
+
+       if (property == dp->sync_prop)
+               *val = zynqmp_dp_get_sync_mode(dp);
+       else if (property == dp->bpc_prop)
+               *val =  zynqmp_dp_get_bpc(dp);
+       else
+               return -EINVAL;
+
+       return 0;
+}
+
 static const struct drm_connector_funcs zynqmp_dp_connector_funcs = {
        .detect                 = zynqmp_dp_connector_detect,
        .fill_modes             = drm_helper_probe_single_connector_modes,
@@ -1375,6 +1466,8 @@ static const struct drm_connector_funcs zynqmp_dp_connector_funcs = {
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state   = drm_atomic_helper_connector_destroy_state,
        .reset                  = drm_atomic_helper_connector_reset,
+       .atomic_set_property    = zynqmp_dp_connector_atomic_set_property,
+       .atomic_get_property    = zynqmp_dp_connector_atomic_get_property,
 };

 static struct drm_connector_helper_funcs zynqmp_dp_connector_helper_funcs = {
@@ -1520,6 +1613,13 @@ static void zynqmp_dp_hpd_work_func(struct work_struct *work)
                drm_helper_hpd_irq_event(dp->drm);
 }

+static struct drm_prop_enum_list zynqmp_dp_bpc_enum[] = {
+       { 6, "6BPC" },
+       { 8, "8BPC" },
+       { 10, "10BPC" },
+       { 12, "12BPC" },
+};
+
 int zynqmp_dp_bind(struct device *dev, struct device *master, void *data)
 {
        struct zynqmp_dpsub *dpsub = dev_get_drvdata(dev);
@@ -1556,21 +1656,31 @@ int zynqmp_dp_bind(struct device *dev, struct device *master, void *data)
        connector->dpms = DRM_MODE_DPMS_OFF;

        dp->drm = drm;
+       dp->sync_prop = drm_property_create_bool(drm, 0, "sync");
+       dp->bpc_prop = drm_property_create_enum(drm, 0, "bpc",
+                                               zynqmp_dp_bpc_enum,
+                                               ARRAY_SIZE(zynqmp_dp_bpc_enum));
+
        dp->config.misc0 &= ~ZYNQMP_DP_TX_MAIN_STREAM_MISC0_SYNC;
+       drm_object_attach_property(&connector->base, dp->sync_prop, false);
        ret = zynqmp_dp_set_bpc(dp, 8);
+       drm_object_attach_property(&connector->base, dp->bpc_prop,
+                                  ret ? ret : 8);
        zynqmp_dp_update_bpp(dp);

        /* This enables interrupts, so should be called after DRM init */
        ret = zynqmp_dp_init_aux(dp);
        if (ret) {
                dev_err(dp->dev, "failed to initialize DP aux");
-               goto error_connector;
+               goto error_prop;
        }
        INIT_DELAYED_WORK(&dp->hpd_work, zynqmp_dp_hpd_work_func);

        return 0;

-error_connector:
+error_prop:
+       drm_property_destroy(dp->drm, dp->bpc_prop);
+       drm_property_destroy(dp->drm, dp->sync_prop);
        zynqmp_dp_connector_destroy(&dp->connector);
 error_encoder:
        drm_encoder_cleanup(&dp->encoder);
@@ -1585,6 +1695,8 @@ void zynqmp_dp_unbind(struct device *dev, struct device *master, void *data)
        cancel_delayed_work_sync(&dp->hpd_work);
        disable_irq(dp->irq);
        zynqmp_dp_exit_aux(dp);
+       drm_property_destroy(dp->drm, dp->bpc_prop);
+       drm_property_destroy(dp->drm, dp->sync_prop);
        zynqmp_dp_connector_destroy(&dp->connector);
        drm_encoder_cleanup(&dp->encoder);
 }
--
2.7.4

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-01-16  1:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16  1:57 [PATCH v3 1/8] dt-bindings: display: xlnx: Add bindings for Xilinx display pipeline Hyun Kwon
     [not found] ` <1516067831-11382-1-git-send-email-hyun.kwon-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2018-01-16  1:57   ` [PATCH v3 2/8] drm: xlnx: Xilinx DRM KMS driver Hyun Kwon
     [not found]     ` <1516067831-11382-2-git-send-email-hyun.kwon-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2018-01-17  8:11       ` Daniel Vetter
2018-01-17  8:20     ` Daniel Vetter
2018-01-19 23:33       ` Rob Herring
     [not found]       ` <20180117082028.GC2759-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2018-01-26  1:36         ` Hyun Kwon
2018-01-16  1:57   ` [PATCH v3 3/8] dt-bindings: display: xlnx: Add ZynqMP DP subsystem bindings Hyun Kwon
     [not found]     ` <1516067831-11382-3-git-send-email-hyun.kwon-gjFFaj9aHVfQT0dZR+AlfA@public.gmane.org>
2018-01-20  0:31       ` Rob Herring
2018-01-20  2:22         ` Hyun Kwon
2018-01-22 14:36           ` Rob Herring
2018-01-16  1:57   ` [PATCH v3 4/8] drm: xlnx: DRM KMS driver for Xilinx ZynqMP DP subsystem display Hyun Kwon
2018-01-16  1:57   ` [PATCH v3 5/8] drm: xlnx: DRM KMS driver for Xilinx ZynqMP DisplayPort Hyun Kwon
2018-01-16  1:57   ` [PATCH v3 6/8] drm: xlnx: ZynqMP DP subsystem DRM KMS driver Hyun Kwon
2018-01-16  1:57 ` [PATCH v3 7/8] drm: xlnx: zynqmp_disp: Add drm properties Hyun Kwon
2018-01-16  1:57 ` Hyun Kwon [this message]
2018-01-19 23:32 ` [PATCH v3 1/8] dt-bindings: display: xlnx: Add bindings for Xilinx display pipeline Rob Herring
2018-01-20  2:22   ` Hyun Kwon

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=1516067831-11382-8-git-send-email-hyun.kwon@xilinx.com \
    --to=hyun.kwon@xilinx.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=michal.simek@xilinx.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;
as well as URLs for NNTP newsgroup(s).