Commit b0d0bf58 authored by Philipp Zabel's avatar Philipp Zabel

drm/imx: imx-ldb: use drm managed resources

Use drmm_simple_encoder_alloc() to align encoder memory lifetime with
the drm device. drm_encoder_cleanup() is called automatically before
the memory is freed.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent a495301a
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h> #include <drm/drm_bridge.h>
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_of.h> #include <drm/drm_of.h>
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
#include <drm/drm_print.h> #include <drm/drm_print.h>
...@@ -47,12 +48,18 @@ ...@@ -47,12 +48,18 @@
#define LDB_DI1_VS_POL_ACT_LOW (1 << 10) #define LDB_DI1_VS_POL_ACT_LOW (1 << 10)
#define LDB_BGREF_RMODE_INT (1 << 15) #define LDB_BGREF_RMODE_INT (1 << 15)
struct imx_ldb_channel;
struct imx_ldb_encoder {
struct drm_connector connector;
struct drm_encoder encoder;
struct imx_ldb_channel *channel;
};
struct imx_ldb; struct imx_ldb;
struct imx_ldb_channel { struct imx_ldb_channel {
struct imx_ldb *ldb; struct imx_ldb *ldb;
struct drm_connector connector;
struct drm_encoder encoder;
/* Defines what is connected to the ldb, only one at a time */ /* Defines what is connected to the ldb, only one at a time */
struct drm_panel *panel; struct drm_panel *panel;
...@@ -70,12 +77,12 @@ struct imx_ldb_channel { ...@@ -70,12 +77,12 @@ struct imx_ldb_channel {
static inline struct imx_ldb_channel *con_to_imx_ldb_ch(struct drm_connector *c) static inline struct imx_ldb_channel *con_to_imx_ldb_ch(struct drm_connector *c)
{ {
return container_of(c, struct imx_ldb_channel, connector); return container_of(c, struct imx_ldb_encoder, connector)->channel;
} }
static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e) static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e)
{ {
return container_of(e, struct imx_ldb_channel, encoder); return container_of(e, struct imx_ldb_encoder, encoder)->channel;
} }
struct bus_mux { struct bus_mux {
...@@ -411,12 +418,19 @@ static int imx_ldb_register(struct drm_device *drm, ...@@ -411,12 +418,19 @@ static int imx_ldb_register(struct drm_device *drm,
struct imx_ldb_channel *imx_ldb_ch) struct imx_ldb_channel *imx_ldb_ch)
{ {
struct imx_ldb *ldb = imx_ldb_ch->ldb; struct imx_ldb *ldb = imx_ldb_ch->ldb;
struct drm_connector *connector = &imx_ldb_ch->connector; struct imx_ldb_encoder *ldb_encoder;
struct drm_encoder *encoder = &imx_ldb_ch->encoder; struct drm_connector *connector;
struct drm_encoder *encoder;
int ret; int ret;
memset(connector, 0, sizeof(*connector)); ldb_encoder = drmm_simple_encoder_alloc(drm, struct imx_ldb_encoder,
memset(encoder, 0, sizeof(*encoder)); encoder, DRM_MODE_ENCODER_LVDS);
if (IS_ERR(ldb_encoder))
return PTR_ERR(ldb_encoder);
ldb_encoder->channel = imx_ldb_ch;
connector = &ldb_encoder->connector;
encoder = &ldb_encoder->encoder;
ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child); ret = imx_drm_encoder_parse_of(drm, encoder, imx_ldb_ch->child);
if (ret) if (ret)
...@@ -433,7 +447,6 @@ static int imx_ldb_register(struct drm_device *drm, ...@@ -433,7 +447,6 @@ static int imx_ldb_register(struct drm_device *drm,
} }
drm_encoder_helper_add(encoder, &imx_ldb_encoder_helper_funcs); drm_encoder_helper_add(encoder, &imx_ldb_encoder_helper_funcs);
drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_LVDS);
if (imx_ldb_ch->bridge) { if (imx_ldb_ch->bridge) {
ret = drm_bridge_attach(encoder, imx_ldb_ch->bridge, NULL, 0); ret = drm_bridge_attach(encoder, imx_ldb_ch->bridge, NULL, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment