Commit 1ce6f91c authored by Maxime Ripard's avatar Maxime Ripard

drm/sun4i: Move the panel pointer from the TCON to the encoders

The TCON driver used to need the panel pointer in order to configure the
tcon according to the various parameters of the panel. However, this has
evolved over time (especially to support bridges), and therefore the panel
pointer isn't needed anymore by the TCON driver.

Move that pointer to the LVDS and RGB encoders drivers.
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Vasily Khoruzhick <anarsoul@gmail.com> # tested on pinebook
Reviewed-by: default avatarPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/13288b6b8f27b614a6c9aef348923c34b2803ad4.1551191081.git-series.maxime.ripard@bootlin.com
parent f741b28f
...@@ -20,7 +20,7 @@ struct sun4i_lvds { ...@@ -20,7 +20,7 @@ struct sun4i_lvds {
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct drm_encoder encoder;
struct sun4i_tcon *tcon; struct drm_panel *panel;
}; };
static inline struct sun4i_lvds * static inline struct sun4i_lvds *
...@@ -41,9 +41,8 @@ static int sun4i_lvds_get_modes(struct drm_connector *connector) ...@@ -41,9 +41,8 @@ static int sun4i_lvds_get_modes(struct drm_connector *connector)
{ {
struct sun4i_lvds *lvds = struct sun4i_lvds *lvds =
drm_connector_to_sun4i_lvds(connector); drm_connector_to_sun4i_lvds(connector);
struct sun4i_tcon *tcon = lvds->tcon;
return drm_panel_get_modes(tcon->panel); return drm_panel_get_modes(lvds->panel);
} }
static struct drm_connector_helper_funcs sun4i_lvds_con_helper_funcs = { static struct drm_connector_helper_funcs sun4i_lvds_con_helper_funcs = {
...@@ -54,9 +53,8 @@ static void ...@@ -54,9 +53,8 @@ static void
sun4i_lvds_connector_destroy(struct drm_connector *connector) sun4i_lvds_connector_destroy(struct drm_connector *connector)
{ {
struct sun4i_lvds *lvds = drm_connector_to_sun4i_lvds(connector); struct sun4i_lvds *lvds = drm_connector_to_sun4i_lvds(connector);
struct sun4i_tcon *tcon = lvds->tcon;
drm_panel_detach(tcon->panel); drm_panel_detach(lvds->panel);
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
} }
...@@ -71,26 +69,24 @@ static const struct drm_connector_funcs sun4i_lvds_con_funcs = { ...@@ -71,26 +69,24 @@ static const struct drm_connector_funcs sun4i_lvds_con_funcs = {
static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder) static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder)
{ {
struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder); struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder);
struct sun4i_tcon *tcon = lvds->tcon;
DRM_DEBUG_DRIVER("Enabling LVDS output\n"); DRM_DEBUG_DRIVER("Enabling LVDS output\n");
if (tcon->panel) { if (lvds->panel) {
drm_panel_prepare(tcon->panel); drm_panel_prepare(lvds->panel);
drm_panel_enable(tcon->panel); drm_panel_enable(lvds->panel);
} }
} }
static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder) static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder)
{ {
struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder); struct sun4i_lvds *lvds = drm_encoder_to_sun4i_lvds(encoder);
struct sun4i_tcon *tcon = lvds->tcon;
DRM_DEBUG_DRIVER("Disabling LVDS output\n"); DRM_DEBUG_DRIVER("Disabling LVDS output\n");
if (tcon->panel) { if (lvds->panel) {
drm_panel_disable(tcon->panel); drm_panel_disable(lvds->panel);
drm_panel_unprepare(tcon->panel); drm_panel_unprepare(lvds->panel);
} }
} }
...@@ -113,11 +109,10 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -113,11 +109,10 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
lvds = devm_kzalloc(drm->dev, sizeof(*lvds), GFP_KERNEL); lvds = devm_kzalloc(drm->dev, sizeof(*lvds), GFP_KERNEL);
if (!lvds) if (!lvds)
return -ENOMEM; return -ENOMEM;
lvds->tcon = tcon;
encoder = &lvds->encoder; encoder = &lvds->encoder;
ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0, ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0,
&tcon->panel, &bridge); &lvds->panel, &bridge);
if (ret) { if (ret) {
dev_info(drm->dev, "No panel or bridge found... LVDS output disabled\n"); dev_info(drm->dev, "No panel or bridge found... LVDS output disabled\n");
return 0; return 0;
...@@ -138,7 +133,7 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -138,7 +133,7 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
/* The LVDS encoder can only work with the TCON channel 0 */ /* The LVDS encoder can only work with the TCON channel 0 */
lvds->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc); lvds->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc);
if (tcon->panel) { if (lvds->panel) {
drm_connector_helper_add(&lvds->connector, drm_connector_helper_add(&lvds->connector,
&sun4i_lvds_con_helper_funcs); &sun4i_lvds_con_helper_funcs);
ret = drm_connector_init(drm, &lvds->connector, ret = drm_connector_init(drm, &lvds->connector,
...@@ -152,7 +147,7 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -152,7 +147,7 @@ int sun4i_lvds_init(struct drm_device *drm, struct sun4i_tcon *tcon)
drm_connector_attach_encoder(&lvds->connector, drm_connector_attach_encoder(&lvds->connector,
&lvds->encoder); &lvds->encoder);
ret = drm_panel_attach(tcon->panel, &lvds->connector); ret = drm_panel_attach(lvds->panel, &lvds->connector);
if (ret) { if (ret) {
dev_err(drm->dev, "Couldn't attach our panel\n"); dev_err(drm->dev, "Couldn't attach our panel\n");
goto err_cleanup_connector; goto err_cleanup_connector;
......
...@@ -27,6 +27,7 @@ struct sun4i_rgb { ...@@ -27,6 +27,7 @@ struct sun4i_rgb {
struct drm_encoder encoder; struct drm_encoder encoder;
struct sun4i_tcon *tcon; struct sun4i_tcon *tcon;
struct drm_panel *panel;
}; };
static inline struct sun4i_rgb * static inline struct sun4i_rgb *
...@@ -47,9 +48,8 @@ static int sun4i_rgb_get_modes(struct drm_connector *connector) ...@@ -47,9 +48,8 @@ static int sun4i_rgb_get_modes(struct drm_connector *connector)
{ {
struct sun4i_rgb *rgb = struct sun4i_rgb *rgb =
drm_connector_to_sun4i_rgb(connector); drm_connector_to_sun4i_rgb(connector);
struct sun4i_tcon *tcon = rgb->tcon;
return drm_panel_get_modes(tcon->panel); return drm_panel_get_modes(rgb->panel);
} }
static enum drm_mode_status sun4i_rgb_mode_valid(struct drm_encoder *crtc, static enum drm_mode_status sun4i_rgb_mode_valid(struct drm_encoder *crtc,
...@@ -114,9 +114,8 @@ static void ...@@ -114,9 +114,8 @@ static void
sun4i_rgb_connector_destroy(struct drm_connector *connector) sun4i_rgb_connector_destroy(struct drm_connector *connector)
{ {
struct sun4i_rgb *rgb = drm_connector_to_sun4i_rgb(connector); struct sun4i_rgb *rgb = drm_connector_to_sun4i_rgb(connector);
struct sun4i_tcon *tcon = rgb->tcon;
drm_panel_detach(tcon->panel); drm_panel_detach(rgb->panel);
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
} }
...@@ -131,26 +130,24 @@ static const struct drm_connector_funcs sun4i_rgb_con_funcs = { ...@@ -131,26 +130,24 @@ static const struct drm_connector_funcs sun4i_rgb_con_funcs = {
static void sun4i_rgb_encoder_enable(struct drm_encoder *encoder) static void sun4i_rgb_encoder_enable(struct drm_encoder *encoder)
{ {
struct sun4i_rgb *rgb = drm_encoder_to_sun4i_rgb(encoder); struct sun4i_rgb *rgb = drm_encoder_to_sun4i_rgb(encoder);
struct sun4i_tcon *tcon = rgb->tcon;
DRM_DEBUG_DRIVER("Enabling RGB output\n"); DRM_DEBUG_DRIVER("Enabling RGB output\n");
if (tcon->panel) { if (rgb->panel) {
drm_panel_prepare(tcon->panel); drm_panel_prepare(rgb->panel);
drm_panel_enable(tcon->panel); drm_panel_enable(rgb->panel);
} }
} }
static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder) static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder)
{ {
struct sun4i_rgb *rgb = drm_encoder_to_sun4i_rgb(encoder); struct sun4i_rgb *rgb = drm_encoder_to_sun4i_rgb(encoder);
struct sun4i_tcon *tcon = rgb->tcon;
DRM_DEBUG_DRIVER("Disabling RGB output\n"); DRM_DEBUG_DRIVER("Disabling RGB output\n");
if (tcon->panel) { if (rgb->panel) {
drm_panel_disable(tcon->panel); drm_panel_disable(rgb->panel);
drm_panel_unprepare(tcon->panel); drm_panel_unprepare(rgb->panel);
} }
} }
...@@ -183,7 +180,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -183,7 +180,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon)
encoder = &rgb->encoder; encoder = &rgb->encoder;
ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0, ret = drm_of_find_panel_or_bridge(tcon->dev->of_node, 1, 0,
&tcon->panel, &bridge); &rgb->panel, &bridge);
if (ret) { if (ret) {
dev_info(drm->dev, "No panel or bridge found... RGB output disabled\n"); dev_info(drm->dev, "No panel or bridge found... RGB output disabled\n");
return 0; return 0;
...@@ -204,7 +201,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -204,7 +201,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon)
/* The RGB encoder can only work with the TCON channel 0 */ /* The RGB encoder can only work with the TCON channel 0 */
rgb->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc); rgb->encoder.possible_crtcs = drm_crtc_mask(&tcon->crtc->crtc);
if (tcon->panel) { if (rgb->panel) {
drm_connector_helper_add(&rgb->connector, drm_connector_helper_add(&rgb->connector,
&sun4i_rgb_con_helper_funcs); &sun4i_rgb_con_helper_funcs);
ret = drm_connector_init(drm, &rgb->connector, ret = drm_connector_init(drm, &rgb->connector,
...@@ -218,7 +215,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon) ...@@ -218,7 +215,7 @@ int sun4i_rgb_init(struct drm_device *drm, struct sun4i_tcon *tcon)
drm_connector_attach_encoder(&rgb->connector, drm_connector_attach_encoder(&rgb->connector,
&rgb->encoder); &rgb->encoder);
ret = drm_panel_attach(tcon->panel, &rgb->connector); ret = drm_panel_attach(rgb->panel, &rgb->connector);
if (ret) { if (ret) {
dev_err(drm->dev, "Couldn't attach our panel\n"); dev_err(drm->dev, "Couldn't attach our panel\n");
goto err_cleanup_connector; goto err_cleanup_connector;
......
...@@ -257,8 +257,6 @@ struct sun4i_tcon { ...@@ -257,8 +257,6 @@ struct sun4i_tcon {
struct reset_control *lcd_rst; struct reset_control *lcd_rst;
struct reset_control *lvds_rst; struct reset_control *lvds_rst;
struct drm_panel *panel;
/* Platform adjustments */ /* Platform adjustments */
const struct sun4i_tcon_quirks *quirks; const struct sun4i_tcon_quirks *quirks;
......
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