LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Peter Rosin <peda@axentia.se>
Cc: Mark Rutland <mark.rutland@arm.com>,
devicetree@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Andrzej Hajda <a.hajda@samsung.com>,
David Airlie <airlied@linux.ie>, Jyri Sarha <jsarha@ti.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Boris Brezillon <boris.brezillon@bootlin.com>,
Rob Herring <robh+dt@kernel.org>,
Jacopo Mondi <jacopo+renesas@jmondi.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Daniel Vetter <daniel@ffwll.ch>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] drm/i2c: tda998x: convert to bridge driver
Date: Fri, 06 Jul 2018 15:59:04 +0100 [thread overview]
Message-ID: <E1fbSCO-00076p-OV@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20180706145748.GA17271@n2100.armlinux.org.uk>
Convert tda998x to a bridge driver with built-in encoder support for
compatibility with existing component drivers.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/gpu/drm/i2c/tda998x_drv.c | 147 +++++++++++++++++++-------------------
1 file changed, 75 insertions(+), 72 deletions(-)
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index 931135db979c..53f110e7d433 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -69,6 +69,7 @@ struct tda998x_priv {
bool edid_delay_active;
struct drm_encoder encoder;
+ struct drm_bridge bridge;
struct drm_connector connector;
struct tda998x_audio_port audio_port[2];
@@ -79,9 +80,10 @@ struct tda998x_priv {
#define conn_to_tda998x_priv(x) \
container_of(x, struct tda998x_priv, connector)
-
#define enc_to_tda998x_priv(x) \
container_of(x, struct tda998x_priv, encoder)
+#define bridge_to_tda998x_priv(x) \
+ container_of(x, struct tda998x_priv, bridge)
/* The TDA9988 series of devices use a paged register scheme.. to simplify
* things we encode the page # in upper bits of the register #. To read/
@@ -1297,10 +1299,24 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
return 0;
}
-/* DRM encoder functions */
+/* DRM bridge functions */
+
+static int tda998x_bridge_attach(struct drm_bridge *bridge)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+
+ return tda998x_connector_init(priv, bridge->dev);
+}
-static void tda998x_enable(struct tda998x_priv *priv)
+static void tda998x_bridge_detach(struct drm_bridge *bridge)
{
+ /* We should remove the connector for symmetry with _attach() */
+}
+
+static void tda998x_bridge_enable(struct drm_bridge *bridge)
+{
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
+
if (!priv->is_on) {
/* enable video ports, audio will be enabled later */
reg_write(priv, REG_ENA_VP_0, 0xff);
@@ -1315,7 +1331,7 @@ static void tda998x_enable(struct tda998x_priv *priv)
}
}
-static void tda998x_disable(struct tda998x_priv *priv)
+static void tda998x_bridge_disable(struct drm_bridge *bridge)
{
if (!priv->is_on) {
/* disable video ports */
@@ -1327,29 +1343,11 @@ static void tda998x_disable(struct tda998x_priv *priv)
}
}
-static void tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)
+static void tda998x_bridge_mode_set(struct drm_bridge *bridge,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
{
- struct tda998x_priv *priv = enc_to_tda998x_priv(encoder);
- bool on;
-
- /* we only care about on or off: */
- on = mode == DRM_MODE_DPMS_ON;
-
- if (on == priv->is_on)
- return;
-
- if (on)
- tda998x_enable(priv);
- else
- tda998x_disable(priv);
-}
-
-static void
-tda998x_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
-{
- struct tda998x_priv *priv = enc_to_tda998x_priv(encoder);
+ struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
u16 ref_pix, ref_line, n_pix, n_line;
u16 hs_pix_s, hs_pix_e;
u16 vs1_pix_s, vs1_pix_e, vs1_line_s, vs1_line_e;
@@ -1556,8 +1554,18 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,
mutex_unlock(&priv->audio_mutex);
}
+static const struct drm_bridge_funcs tda998x_bridge_funcs = {
+ .attach = tda998x_bridge_attach,
+ .detach = tda998x_bridge_detach,
+ .disable = tda998x_bridge_disable,
+ .mode_set = tda998x_bridge_mode_set,
+ .enable = tda998x_bridge_enable,
+};
+
static void tda998x_destroy(struct tda998x_priv *priv)
{
+ drm_bridge_remove(&priv->bridge);
+
/* disable all IRQs and free the IRQ handler */
cec_write(priv, REG_CEC_RXSHPDINTENA, 0);
reg_clear(priv, REG_INT_FLAGS_2, INT_FLAGS_2_EDID_BLK_RD);
@@ -1650,6 +1658,7 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
mutex_init(&priv->mutex); /* protect the page access */
mutex_init(&priv->audio_mutex); /* protect access from audio thread */
mutex_init(&priv->edid_mutex);
+ INIT_LIST_HEAD(&priv->bridge.list);
init_waitqueue_head(&priv->edid_delay_waitq);
timer_setup(&priv->edid_delay_timer, tda998x_edid_delay_done, 0);
INIT_WORK(&priv->detect_work, tda998x_detect_work);
@@ -1814,44 +1823,23 @@ static int tda998x_create(struct i2c_client *client, struct tda998x_priv *priv)
tda998x_set_config(priv, params);
}
+ priv->bridge.funcs = &tda998x_bridge_funcs;
+ priv->bridge.of_node = dev->of_node;
+
+ drm_bridge_add(&priv->bridge);
+
return 0;
fail:
- /* if encoder_init fails, the encoder slave is never registered,
- * so cleanup here:
- */
- if (priv->cec)
- i2c_unregister_device(priv->cec);
- if (priv->cec_notify)
- cec_notifier_put(priv->cec_notify);
- if (client->irq)
- free_irq(client->irq, priv);
+ tda998x_destroy(priv);
err_irq:
return ret;
}
-static void tda998x_encoder_prepare(struct drm_encoder *encoder)
-{
- tda998x_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
-}
-
-static void tda998x_encoder_commit(struct drm_encoder *encoder)
-{
- tda998x_encoder_dpms(encoder, DRM_MODE_DPMS_ON);
-}
-
-static const struct drm_encoder_helper_funcs tda998x_encoder_helper_funcs = {
- .dpms = tda998x_encoder_dpms,
- .prepare = tda998x_encoder_prepare,
- .commit = tda998x_encoder_commit,
- .mode_set = tda998x_encoder_mode_set,
-};
+/* DRM encoder functions */
static void tda998x_encoder_destroy(struct drm_encoder *encoder)
{
- struct tda998x_priv *priv = enc_to_tda998x_priv(encoder);
-
- tda998x_destroy(priv);
drm_encoder_cleanup(encoder);
}
@@ -1859,20 +1847,12 @@ static const struct drm_encoder_funcs tda998x_encoder_funcs = {
.destroy = tda998x_encoder_destroy,
};
-static int tda998x_bind(struct device *dev, struct device *master, void *data)
+static int tda998x_encoder_init(struct device *dev, struct drm_device *drm)
{
- struct i2c_client *client = to_i2c_client(dev);
- struct drm_device *drm = data;
- struct tda998x_priv *priv;
+ struct tda998x_priv *priv = dev_get_drvdata(dev);
u32 crtcs = 0;
int ret;
- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
-
- dev_set_drvdata(dev, priv);
-
if (dev->of_node)
crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
@@ -1884,25 +1864,48 @@ static int tda998x_bind(struct device *dev, struct device *master, void *data)
priv->encoder.possible_crtcs = crtcs;
- ret = tda998x_create(client, priv);
- if (ret)
- return ret;
-
- drm_encoder_helper_add(&priv->encoder, &tda998x_encoder_helper_funcs);
ret = drm_encoder_init(drm, &priv->encoder, &tda998x_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
if (ret)
goto err_encoder;
- ret = tda998x_connector_init(priv, drm);
+ ret = drm_bridge_attach(&priv->encoder, &priv->bridge, NULL);
if (ret)
- goto err_connector;
+ goto err_bridge;
return 0;
-err_connector:
+err_bridge:
drm_encoder_cleanup(&priv->encoder);
err_encoder:
+ return ret;
+}
+
+static int tda998x_bind(struct device *dev, struct device *master, void *data)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct drm_device *drm = data;
+ struct tda998x_priv *priv;
+ int ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ dev_set_drvdata(dev, priv);
+
+ ret = tda998x_create(client, priv);
+ if (ret)
+ return ret;
+
+ ret = tda998x_encoder_init(dev, drm);
+ if (ret) {
+ tda998x_destroy(priv);
+ return ret;
+ }
+ return 0;
+
+err_encoder:
tda998x_destroy(priv);
return ret;
}
--
2.7.4
next prev parent reply other threads:[~2018-07-06 14:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 9:31 [PATCH v5 0/7] Add tda998x (HDMI) support to atmel-hlcdc Peter Rosin
2018-05-23 9:31 ` [PATCH v5 1/7] dt-bindings: display: bridge: lvds-transmitter: add ti,ds90c185 Peter Rosin
2018-05-23 9:31 ` [PATCH v5 2/7] dt-bindings: display: atmel: optional video-interface of endpoints Peter Rosin
2018-05-23 9:31 ` [PATCH v5 3/7] drm/atmel-hlcdc: support bus-width (12/16/18/24) in endpoint nodes Peter Rosin
2018-05-23 9:31 ` [PATCH v5 4/7] drm/i2c: tda998x: find the drm_device via the drm_connector Peter Rosin
2018-05-23 9:31 ` [PATCH v5 5/7] drm/i2c: tda998x: split tda998x_encoder_dpms into enable/disable Peter Rosin
2018-07-06 10:57 ` Russell King - ARM Linux
2018-05-23 9:31 ` [PATCH v5 6/7] drm/i2c: tda998x: split encoder and component functions from the work Peter Rosin
2018-05-23 9:31 ` [PATCH v5 7/7] drm/i2c: tda998x: register as a drm bridge Peter Rosin
2018-07-06 13:36 ` Russell King - ARM Linux
2018-07-06 14:57 ` Russell King - ARM Linux
2018-07-06 14:58 ` [PATCH 1/6] drm/i2c: tda998x: find the drm_device via the drm_connector Russell King
2018-07-06 14:58 ` [PATCH 2/6] drm/i2c: tda998x: split tda998x_encoder_dpms into enable/disable Russell King
2018-07-06 14:58 ` [PATCH 3/6] drm/i2c: tda998x: move tda998x_set_config() into tda998x_create() Russell King
2018-07-06 14:59 ` Russell King [this message]
2018-07-07 6:19 ` [PATCH 4/6] drm/i2c: tda998x: convert to bridge driver kbuild test robot
2018-07-07 7:08 ` kbuild test robot
2018-07-06 14:59 ` [PATCH 5/6] drm/i2c: tda998x: allocate tda998x_priv inside tda998x_create() Russell King
2018-07-06 14:59 ` [PATCH 6/6] drm/i2c: tda998x: cleanup from previous changes Russell King
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=E1fbSCO-00076p-OV@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=a.hajda@samsung.com \
--cc=airlied@linux.ie \
--cc=alexandre.belloni@bootlin.com \
--cc=boris.brezillon@bootlin.com \
--cc=daniel@ffwll.ch \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacopo+renesas@jmondi.org \
--cc=jsarha@ti.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=peda@axentia.se \
--cc=robh+dt@kernel.org \
--subject='Re: [PATCH 4/6] drm/i2c: tda998x: convert to bridge driver' \
/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
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).