Commit 540b8f27 authored by Sascha Hauer's avatar Sascha Hauer Committed by Heiko Stuebner

drm/rockchip: Embed drm_encoder into rockchip_decoder

The VOP2 driver needs rockchip specific information for a drm_encoder.

This patch creates a struct rockchip_encoder with a struct drm_encoder
embedded in it. This is used throughout the rockchip driver instead of
struct drm_encoder directly.

The information the VOP2 drivers needs is the of_graph endpoint node
of the encoder. To ease bisectability this is added here.

While at it convert the different encoder-to-driverdata macros to
static inline functions in order to gain type safety and readability.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Tested-by: default avatarMichael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220422072841.2206452-3-s.hauer@pengutronix.de
parent 3fa50896
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
#define PSR_WAIT_LINE_FLAG_TIMEOUT_MS 100 #define PSR_WAIT_LINE_FLAG_TIMEOUT_MS 100
#define to_dp(nm) container_of(nm, struct rockchip_dp_device, nm)
/** /**
* struct rockchip_dp_chip_data - splite the grf setting of kind of chips * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
* @lcdsel_grf_reg: grf register offset of lcdc select * @lcdsel_grf_reg: grf register offset of lcdc select
...@@ -59,7 +57,7 @@ struct rockchip_dp_chip_data { ...@@ -59,7 +57,7 @@ struct rockchip_dp_chip_data {
struct rockchip_dp_device { struct rockchip_dp_device {
struct drm_device *drm_dev; struct drm_device *drm_dev;
struct device *dev; struct device *dev;
struct drm_encoder encoder; struct rockchip_encoder encoder;
struct drm_display_mode mode; struct drm_display_mode mode;
struct clk *pclk; struct clk *pclk;
...@@ -73,6 +71,18 @@ struct rockchip_dp_device { ...@@ -73,6 +71,18 @@ struct rockchip_dp_device {
struct analogix_dp_plat_data plat_data; struct analogix_dp_plat_data plat_data;
}; };
static struct rockchip_dp_device *encoder_to_dp(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct rockchip_dp_device, encoder);
}
static struct rockchip_dp_device *pdata_encoder_to_dp(struct analogix_dp_plat_data *plat_data)
{
return container_of(plat_data, struct rockchip_dp_device, plat_data);
}
static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) static int rockchip_dp_pre_init(struct rockchip_dp_device *dp)
{ {
reset_control_assert(dp->rst); reset_control_assert(dp->rst);
...@@ -84,7 +94,7 @@ static int rockchip_dp_pre_init(struct rockchip_dp_device *dp) ...@@ -84,7 +94,7 @@ static int rockchip_dp_pre_init(struct rockchip_dp_device *dp)
static int rockchip_dp_poweron_start(struct analogix_dp_plat_data *plat_data) static int rockchip_dp_poweron_start(struct analogix_dp_plat_data *plat_data)
{ {
struct rockchip_dp_device *dp = to_dp(plat_data); struct rockchip_dp_device *dp = pdata_encoder_to_dp(plat_data);
int ret; int ret;
ret = clk_prepare_enable(dp->pclk); ret = clk_prepare_enable(dp->pclk);
...@@ -105,7 +115,7 @@ static int rockchip_dp_poweron_start(struct analogix_dp_plat_data *plat_data) ...@@ -105,7 +115,7 @@ static int rockchip_dp_poweron_start(struct analogix_dp_plat_data *plat_data)
static int rockchip_dp_powerdown(struct analogix_dp_plat_data *plat_data) static int rockchip_dp_powerdown(struct analogix_dp_plat_data *plat_data)
{ {
struct rockchip_dp_device *dp = to_dp(plat_data); struct rockchip_dp_device *dp = pdata_encoder_to_dp(plat_data);
clk_disable_unprepare(dp->pclk); clk_disable_unprepare(dp->pclk);
...@@ -166,7 +176,7 @@ struct drm_crtc *rockchip_dp_drm_get_new_crtc(struct drm_encoder *encoder, ...@@ -166,7 +176,7 @@ struct drm_crtc *rockchip_dp_drm_get_new_crtc(struct drm_encoder *encoder,
static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
struct drm_atomic_state *state) struct drm_atomic_state *state)
{ {
struct rockchip_dp_device *dp = to_dp(encoder); struct rockchip_dp_device *dp = encoder_to_dp(encoder);
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state; struct drm_crtc_state *old_crtc_state;
int ret; int ret;
...@@ -208,7 +218,7 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder, ...@@ -208,7 +218,7 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
static void rockchip_dp_drm_encoder_disable(struct drm_encoder *encoder, static void rockchip_dp_drm_encoder_disable(struct drm_encoder *encoder,
struct drm_atomic_state *state) struct drm_atomic_state *state)
{ {
struct rockchip_dp_device *dp = to_dp(encoder); struct rockchip_dp_device *dp = encoder_to_dp(encoder);
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_crtc_state *new_crtc_state = NULL; struct drm_crtc_state *new_crtc_state = NULL;
int ret; int ret;
...@@ -297,7 +307,7 @@ static int rockchip_dp_of_probe(struct rockchip_dp_device *dp) ...@@ -297,7 +307,7 @@ static int rockchip_dp_of_probe(struct rockchip_dp_device *dp)
static int rockchip_dp_drm_create_encoder(struct rockchip_dp_device *dp) static int rockchip_dp_drm_create_encoder(struct rockchip_dp_device *dp)
{ {
struct drm_encoder *encoder = &dp->encoder; struct drm_encoder *encoder = &dp->encoder.encoder;
struct drm_device *drm_dev = dp->drm_dev; struct drm_device *drm_dev = dp->drm_dev;
struct device *dev = dp->dev; struct device *dev = dp->dev;
int ret; int ret;
...@@ -333,7 +343,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, ...@@ -333,7 +343,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
return ret; return ret;
} }
dp->plat_data.encoder = &dp->encoder; dp->plat_data.encoder = &dp->encoder.encoder;
ret = analogix_dp_bind(dp->adp, drm_dev); ret = analogix_dp_bind(dp->adp, drm_dev);
if (ret) if (ret)
...@@ -341,7 +351,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, ...@@ -341,7 +351,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
return 0; return 0;
err_cleanup_encoder: err_cleanup_encoder:
dp->encoder.funcs->destroy(&dp->encoder); dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder);
return ret; return ret;
} }
...@@ -351,7 +361,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master, ...@@ -351,7 +361,7 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
struct rockchip_dp_device *dp = dev_get_drvdata(dev); struct rockchip_dp_device *dp = dev_get_drvdata(dev);
analogix_dp_unbind(dp->adp); analogix_dp_unbind(dp->adp);
dp->encoder.funcs->destroy(&dp->encoder); dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder);
} }
static const struct component_ops rockchip_dp_component_ops = { static const struct component_ops rockchip_dp_component_ops = {
......
...@@ -26,11 +26,17 @@ ...@@ -26,11 +26,17 @@
#include "cdn-dp-reg.h" #include "cdn-dp-reg.h"
#include "rockchip_drm_vop.h" #include "rockchip_drm_vop.h"
#define connector_to_dp(c) \ static inline struct cdn_dp_device *connector_to_dp(struct drm_connector *connector)
container_of(c, struct cdn_dp_device, connector) {
return container_of(connector, struct cdn_dp_device, connector);
}
#define encoder_to_dp(c) \ static inline struct cdn_dp_device *encoder_to_dp(struct drm_encoder *encoder)
container_of(c, struct cdn_dp_device, encoder) {
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct cdn_dp_device, encoder);
}
#define GRF_SOC_CON9 0x6224 #define GRF_SOC_CON9 0x6224
#define DP_SEL_VOP_LIT BIT(12) #define DP_SEL_VOP_LIT BIT(12)
...@@ -1050,7 +1056,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1050,7 +1056,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
INIT_WORK(&dp->event_work, cdn_dp_pd_event_work); INIT_WORK(&dp->event_work, cdn_dp_pd_event_work);
encoder = &dp->encoder; encoder = &dp->encoder.encoder;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,
dev->of_node); dev->of_node);
...@@ -1115,7 +1121,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -1115,7 +1121,7 @@ static int cdn_dp_bind(struct device *dev, struct device *master, void *data)
static void cdn_dp_unbind(struct device *dev, struct device *master, void *data) static void cdn_dp_unbind(struct device *dev, struct device *master, void *data)
{ {
struct cdn_dp_device *dp = dev_get_drvdata(dev); struct cdn_dp_device *dp = dev_get_drvdata(dev);
struct drm_encoder *encoder = &dp->encoder; struct drm_encoder *encoder = &dp->encoder.encoder;
struct drm_connector *connector = &dp->connector; struct drm_connector *connector = &dp->connector;
cancel_work_sync(&dp->event_work); cancel_work_sync(&dp->event_work);
......
...@@ -66,7 +66,7 @@ struct cdn_dp_device { ...@@ -66,7 +66,7 @@ struct cdn_dp_device {
struct device *dev; struct device *dev;
struct drm_device *drm_dev; struct drm_device *drm_dev;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct rockchip_encoder encoder;
struct drm_display_mode mode; struct drm_display_mode mode;
struct platform_device *audio_pdev; struct platform_device *audio_pdev;
struct work_struct event_work; struct work_struct event_work;
......
...@@ -181,8 +181,6 @@ ...@@ -181,8 +181,6 @@
#define HIWORD_UPDATE(val, mask) (val | (mask) << 16) #define HIWORD_UPDATE(val, mask) (val | (mask) << 16)
#define to_dsi(nm) container_of(nm, struct dw_mipi_dsi_rockchip, nm)
enum { enum {
DW_DSI_USAGE_IDLE, DW_DSI_USAGE_IDLE,
DW_DSI_USAGE_DSI, DW_DSI_USAGE_DSI,
...@@ -236,7 +234,7 @@ struct rockchip_dw_dsi_chip_data { ...@@ -236,7 +234,7 @@ struct rockchip_dw_dsi_chip_data {
struct dw_mipi_dsi_rockchip { struct dw_mipi_dsi_rockchip {
struct device *dev; struct device *dev;
struct drm_encoder encoder; struct rockchip_encoder encoder;
void __iomem *base; void __iomem *base;
struct regmap *grf_regmap; struct regmap *grf_regmap;
...@@ -271,6 +269,13 @@ struct dw_mipi_dsi_rockchip { ...@@ -271,6 +269,13 @@ struct dw_mipi_dsi_rockchip {
bool dsi_bound; bool dsi_bound;
}; };
static struct dw_mipi_dsi_rockchip *to_dsi(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct dw_mipi_dsi_rockchip, encoder);
}
struct dphy_pll_parameter_map { struct dphy_pll_parameter_map {
unsigned int max_mbps; unsigned int max_mbps;
u8 hsfreqrange; u8 hsfreqrange;
...@@ -770,7 +775,7 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) ...@@ -770,7 +775,7 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)
int ret, mux; int ret, mux;
mux = drm_of_encoder_active_endpoint_id(dsi->dev->of_node, mux = drm_of_encoder_active_endpoint_id(dsi->dev->of_node,
&dsi->encoder); &dsi->encoder.encoder);
if (mux < 0) if (mux < 0)
return; return;
...@@ -801,7 +806,7 @@ dw_mipi_dsi_encoder_helper_funcs = { ...@@ -801,7 +806,7 @@ dw_mipi_dsi_encoder_helper_funcs = {
static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi, static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,
struct drm_device *drm_dev) struct drm_device *drm_dev)
{ {
struct drm_encoder *encoder = &dsi->encoder; struct drm_encoder *encoder = &dsi->encoder.encoder;
int ret; int ret;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,
...@@ -959,7 +964,7 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, ...@@ -959,7 +964,7 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev,
goto out_pll_clk; goto out_pll_clk;
} }
ret = dw_mipi_dsi_bind(dsi->dmd, &dsi->encoder); ret = dw_mipi_dsi_bind(dsi->dmd, &dsi->encoder.encoder);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev, "Failed to bind: %d\n", ret); DRM_DEV_ERROR(dev, "Failed to bind: %d\n", ret);
goto out_pll_clk; goto out_pll_clk;
......
...@@ -67,7 +67,7 @@ struct rockchip_hdmi_chip_data { ...@@ -67,7 +67,7 @@ struct rockchip_hdmi_chip_data {
struct rockchip_hdmi { struct rockchip_hdmi {
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
struct drm_encoder encoder; struct rockchip_encoder encoder;
const struct rockchip_hdmi_chip_data *chip_data; const struct rockchip_hdmi_chip_data *chip_data;
struct clk *vpll_clk; struct clk *vpll_clk;
struct clk *grf_clk; struct clk *grf_clk;
...@@ -75,7 +75,12 @@ struct rockchip_hdmi { ...@@ -75,7 +75,12 @@ struct rockchip_hdmi {
struct phy *phy; struct phy *phy;
}; };
#define to_rockchip_hdmi(x) container_of(x, struct rockchip_hdmi, x) static struct rockchip_hdmi *to_rockchip_hdmi(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct rockchip_hdmi, encoder);
}
static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = { static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
{ {
...@@ -511,7 +516,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, ...@@ -511,7 +516,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
hdmi->dev = &pdev->dev; hdmi->dev = &pdev->dev;
hdmi->chip_data = plat_data->phy_data; hdmi->chip_data = plat_data->phy_data;
plat_data->phy_data = hdmi; plat_data->phy_data = hdmi;
encoder = &hdmi->encoder; encoder = &hdmi->encoder.encoder;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
/* /*
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#include "inno_hdmi.h" #include "inno_hdmi.h"
#define to_inno_hdmi(x) container_of(x, struct inno_hdmi, x)
struct hdmi_data_info { struct hdmi_data_info {
int vic; int vic;
bool sink_has_audio; bool sink_has_audio;
...@@ -55,7 +53,7 @@ struct inno_hdmi { ...@@ -55,7 +53,7 @@ struct inno_hdmi {
void __iomem *regs; void __iomem *regs;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct rockchip_encoder encoder;
struct inno_hdmi_i2c *i2c; struct inno_hdmi_i2c *i2c;
struct i2c_adapter *ddc; struct i2c_adapter *ddc;
...@@ -66,6 +64,18 @@ struct inno_hdmi { ...@@ -66,6 +64,18 @@ struct inno_hdmi {
struct drm_display_mode previous_mode; struct drm_display_mode previous_mode;
}; };
static struct inno_hdmi *encoder_to_inno_hdmi(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct inno_hdmi, encoder);
}
static struct inno_hdmi *connector_to_inno_hdmi(struct drm_connector *connector)
{
return container_of(connector, struct inno_hdmi, connector);
}
enum { enum {
CSC_ITU601_16_235_TO_RGB_0_255_8BIT, CSC_ITU601_16_235_TO_RGB_0_255_8BIT,
CSC_ITU601_0_255_TO_RGB_0_255_8BIT, CSC_ITU601_0_255_TO_RGB_0_255_8BIT,
...@@ -484,7 +494,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder, ...@@ -484,7 +494,7 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode, struct drm_display_mode *mode,
struct drm_display_mode *adj_mode) struct drm_display_mode *adj_mode)
{ {
struct inno_hdmi *hdmi = to_inno_hdmi(encoder); struct inno_hdmi *hdmi = encoder_to_inno_hdmi(encoder);
inno_hdmi_setup(hdmi, adj_mode); inno_hdmi_setup(hdmi, adj_mode);
...@@ -494,14 +504,14 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder, ...@@ -494,14 +504,14 @@ static void inno_hdmi_encoder_mode_set(struct drm_encoder *encoder,
static void inno_hdmi_encoder_enable(struct drm_encoder *encoder) static void inno_hdmi_encoder_enable(struct drm_encoder *encoder)
{ {
struct inno_hdmi *hdmi = to_inno_hdmi(encoder); struct inno_hdmi *hdmi = encoder_to_inno_hdmi(encoder);
inno_hdmi_set_pwr_mode(hdmi, NORMAL); inno_hdmi_set_pwr_mode(hdmi, NORMAL);
} }
static void inno_hdmi_encoder_disable(struct drm_encoder *encoder) static void inno_hdmi_encoder_disable(struct drm_encoder *encoder)
{ {
struct inno_hdmi *hdmi = to_inno_hdmi(encoder); struct inno_hdmi *hdmi = encoder_to_inno_hdmi(encoder);
inno_hdmi_set_pwr_mode(hdmi, LOWER_PWR); inno_hdmi_set_pwr_mode(hdmi, LOWER_PWR);
} }
...@@ -537,7 +547,7 @@ static struct drm_encoder_helper_funcs inno_hdmi_encoder_helper_funcs = { ...@@ -537,7 +547,7 @@ static struct drm_encoder_helper_funcs inno_hdmi_encoder_helper_funcs = {
static enum drm_connector_status static enum drm_connector_status
inno_hdmi_connector_detect(struct drm_connector *connector, bool force) inno_hdmi_connector_detect(struct drm_connector *connector, bool force)
{ {
struct inno_hdmi *hdmi = to_inno_hdmi(connector); struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
return (hdmi_readb(hdmi, HDMI_STATUS) & m_HOTPLUG) ? return (hdmi_readb(hdmi, HDMI_STATUS) & m_HOTPLUG) ?
connector_status_connected : connector_status_disconnected; connector_status_connected : connector_status_disconnected;
...@@ -545,7 +555,7 @@ inno_hdmi_connector_detect(struct drm_connector *connector, bool force) ...@@ -545,7 +555,7 @@ inno_hdmi_connector_detect(struct drm_connector *connector, bool force)
static int inno_hdmi_connector_get_modes(struct drm_connector *connector) static int inno_hdmi_connector_get_modes(struct drm_connector *connector)
{ {
struct inno_hdmi *hdmi = to_inno_hdmi(connector); struct inno_hdmi *hdmi = connector_to_inno_hdmi(connector);
struct edid *edid; struct edid *edid;
int ret = 0; int ret = 0;
...@@ -599,7 +609,7 @@ static struct drm_connector_helper_funcs inno_hdmi_connector_helper_funcs = { ...@@ -599,7 +609,7 @@ static struct drm_connector_helper_funcs inno_hdmi_connector_helper_funcs = {
static int inno_hdmi_register(struct drm_device *drm, struct inno_hdmi *hdmi) static int inno_hdmi_register(struct drm_device *drm, struct inno_hdmi *hdmi)
{ {
struct drm_encoder *encoder = &hdmi->encoder; struct drm_encoder *encoder = &hdmi->encoder.encoder;
struct device *dev = hdmi->dev; struct device *dev = hdmi->dev;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
...@@ -879,7 +889,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master, ...@@ -879,7 +889,7 @@ static int inno_hdmi_bind(struct device *dev, struct device *master,
return 0; return 0;
err_cleanup_hdmi: err_cleanup_hdmi:
hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder); hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder);
err_put_adapter: err_put_adapter:
i2c_put_adapter(hdmi->ddc); i2c_put_adapter(hdmi->ddc);
err_disable_clk: err_disable_clk:
...@@ -893,7 +903,7 @@ static void inno_hdmi_unbind(struct device *dev, struct device *master, ...@@ -893,7 +903,7 @@ static void inno_hdmi_unbind(struct device *dev, struct device *master,
struct inno_hdmi *hdmi = dev_get_drvdata(dev); struct inno_hdmi *hdmi = dev_get_drvdata(dev);
hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder); hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder);
i2c_put_adapter(hdmi->ddc); i2c_put_adapter(hdmi->ddc);
clk_disable_unprepare(hdmi->pclk); clk_disable_unprepare(hdmi->pclk);
......
...@@ -46,7 +46,7 @@ struct rk3066_hdmi { ...@@ -46,7 +46,7 @@ struct rk3066_hdmi {
void __iomem *regs; void __iomem *regs;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct rockchip_encoder encoder;
struct rk3066_hdmi_i2c *i2c; struct rk3066_hdmi_i2c *i2c;
struct i2c_adapter *ddc; struct i2c_adapter *ddc;
...@@ -57,7 +57,17 @@ struct rk3066_hdmi { ...@@ -57,7 +57,17 @@ struct rk3066_hdmi {
struct drm_display_mode previous_mode; struct drm_display_mode previous_mode;
}; };
#define to_rk3066_hdmi(x) container_of(x, struct rk3066_hdmi, x) static struct rk3066_hdmi *encoder_to_rk3066_hdmi(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct rk3066_hdmi, encoder);
}
static struct rk3066_hdmi *connector_to_rk3066_hdmi(struct drm_connector *connector)
{
return container_of(connector, struct rk3066_hdmi, connector);
}
static inline u8 hdmi_readb(struct rk3066_hdmi *hdmi, u16 offset) static inline u8 hdmi_readb(struct rk3066_hdmi *hdmi, u16 offset)
{ {
...@@ -381,7 +391,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder, ...@@ -381,7 +391,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode, struct drm_display_mode *mode,
struct drm_display_mode *adj_mode) struct drm_display_mode *adj_mode)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder); struct rk3066_hdmi *hdmi = encoder_to_rk3066_hdmi(encoder);
/* Store the display mode for plugin/DPMS poweron events. */ /* Store the display mode for plugin/DPMS poweron events. */
memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode)); memcpy(&hdmi->previous_mode, adj_mode, sizeof(hdmi->previous_mode));
...@@ -389,7 +399,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder, ...@@ -389,7 +399,7 @@ rk3066_hdmi_encoder_mode_set(struct drm_encoder *encoder,
static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder) static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder); struct rk3066_hdmi *hdmi = encoder_to_rk3066_hdmi(encoder);
int mux, val; int mux, val;
mux = drm_of_encoder_active_endpoint_id(hdmi->dev->of_node, encoder); mux = drm_of_encoder_active_endpoint_id(hdmi->dev->of_node, encoder);
...@@ -408,7 +418,7 @@ static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder) ...@@ -408,7 +418,7 @@ static void rk3066_hdmi_encoder_enable(struct drm_encoder *encoder)
static void rk3066_hdmi_encoder_disable(struct drm_encoder *encoder) static void rk3066_hdmi_encoder_disable(struct drm_encoder *encoder)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(encoder); struct rk3066_hdmi *hdmi = encoder_to_rk3066_hdmi(encoder);
DRM_DEV_DEBUG(hdmi->dev, "hdmi encoder disable\n"); DRM_DEV_DEBUG(hdmi->dev, "hdmi encoder disable\n");
...@@ -456,7 +466,7 @@ struct drm_encoder_helper_funcs rk3066_hdmi_encoder_helper_funcs = { ...@@ -456,7 +466,7 @@ struct drm_encoder_helper_funcs rk3066_hdmi_encoder_helper_funcs = {
static enum drm_connector_status static enum drm_connector_status
rk3066_hdmi_connector_detect(struct drm_connector *connector, bool force) rk3066_hdmi_connector_detect(struct drm_connector *connector, bool force)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(connector); struct rk3066_hdmi *hdmi = connector_to_rk3066_hdmi(connector);
return (hdmi_readb(hdmi, HDMI_HPG_MENS_STA) & HDMI_HPG_IN_STATUS_HIGH) ? return (hdmi_readb(hdmi, HDMI_HPG_MENS_STA) & HDMI_HPG_IN_STATUS_HIGH) ?
connector_status_connected : connector_status_disconnected; connector_status_connected : connector_status_disconnected;
...@@ -464,7 +474,7 @@ rk3066_hdmi_connector_detect(struct drm_connector *connector, bool force) ...@@ -464,7 +474,7 @@ rk3066_hdmi_connector_detect(struct drm_connector *connector, bool force)
static int rk3066_hdmi_connector_get_modes(struct drm_connector *connector) static int rk3066_hdmi_connector_get_modes(struct drm_connector *connector)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(connector); struct rk3066_hdmi *hdmi = connector_to_rk3066_hdmi(connector);
struct edid *edid; struct edid *edid;
int ret = 0; int ret = 0;
...@@ -496,9 +506,9 @@ rk3066_hdmi_connector_mode_valid(struct drm_connector *connector, ...@@ -496,9 +506,9 @@ rk3066_hdmi_connector_mode_valid(struct drm_connector *connector,
static struct drm_encoder * static struct drm_encoder *
rk3066_hdmi_connector_best_encoder(struct drm_connector *connector) rk3066_hdmi_connector_best_encoder(struct drm_connector *connector)
{ {
struct rk3066_hdmi *hdmi = to_rk3066_hdmi(connector); struct rk3066_hdmi *hdmi = connector_to_rk3066_hdmi(connector);
return &hdmi->encoder; return &hdmi->encoder.encoder;
} }
static int static int
...@@ -538,7 +548,7 @@ struct drm_connector_helper_funcs rk3066_hdmi_connector_helper_funcs = { ...@@ -538,7 +548,7 @@ struct drm_connector_helper_funcs rk3066_hdmi_connector_helper_funcs = {
static int static int
rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi) rk3066_hdmi_register(struct drm_device *drm, struct rk3066_hdmi *hdmi)
{ {
struct drm_encoder *encoder = &hdmi->encoder; struct drm_encoder *encoder = &hdmi->encoder.encoder;
struct device *dev = hdmi->dev; struct device *dev = hdmi->dev;
encoder->possible_crtcs = encoder->possible_crtcs =
...@@ -816,7 +826,7 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master, ...@@ -816,7 +826,7 @@ static int rk3066_hdmi_bind(struct device *dev, struct device *master,
err_cleanup_hdmi: err_cleanup_hdmi:
hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder); hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder);
err_disable_i2c: err_disable_i2c:
i2c_put_adapter(hdmi->ddc); i2c_put_adapter(hdmi->ddc);
err_disable_hclk: err_disable_hclk:
...@@ -831,7 +841,7 @@ static void rk3066_hdmi_unbind(struct device *dev, struct device *master, ...@@ -831,7 +841,7 @@ static void rk3066_hdmi_unbind(struct device *dev, struct device *master,
struct rk3066_hdmi *hdmi = dev_get_drvdata(dev); struct rk3066_hdmi *hdmi = dev_get_drvdata(dev);
hdmi->connector.funcs->destroy(&hdmi->connector); hdmi->connector.funcs->destroy(&hdmi->connector);
hdmi->encoder.funcs->destroy(&hdmi->encoder); hdmi->encoder.encoder.funcs->destroy(&hdmi->encoder.encoder);
i2c_put_adapter(hdmi->ddc); i2c_put_adapter(hdmi->ddc);
clk_disable_unprepare(hdmi->hclk); clk_disable_unprepare(hdmi->hclk);
......
...@@ -49,6 +49,10 @@ struct rockchip_drm_private { ...@@ -49,6 +49,10 @@ struct rockchip_drm_private {
struct drm_mm mm; struct drm_mm mm;
}; };
struct rockchip_encoder {
struct drm_encoder encoder;
};
int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
struct device *dev); struct device *dev);
void rockchip_drm_dma_detach_device(struct drm_device *drm_dev, void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
...@@ -66,4 +70,10 @@ extern struct platform_driver rockchip_dp_driver; ...@@ -66,4 +70,10 @@ extern struct platform_driver rockchip_dp_driver;
extern struct platform_driver rockchip_lvds_driver; extern struct platform_driver rockchip_lvds_driver;
extern struct platform_driver vop_platform_driver; extern struct platform_driver vop_platform_driver;
extern struct platform_driver rk3066_hdmi_driver; extern struct platform_driver rk3066_hdmi_driver;
static inline struct rockchip_encoder *to_rockchip_encoder(struct drm_encoder *encoder)
{
return container_of(encoder, struct rockchip_encoder, encoder);
}
#endif /* _ROCKCHIP_DRM_DRV_H_ */ #endif /* _ROCKCHIP_DRM_DRV_H_ */
...@@ -36,12 +36,6 @@ ...@@ -36,12 +36,6 @@
struct rockchip_lvds; struct rockchip_lvds;
#define connector_to_lvds(c) \
container_of(c, struct rockchip_lvds, connector)
#define encoder_to_lvds(c) \
container_of(c, struct rockchip_lvds, encoder)
/** /**
* struct rockchip_lvds_soc_data - rockchip lvds Soc private data * struct rockchip_lvds_soc_data - rockchip lvds Soc private data
* @probe: LVDS platform probe function * @probe: LVDS platform probe function
...@@ -65,10 +59,22 @@ struct rockchip_lvds { ...@@ -65,10 +59,22 @@ struct rockchip_lvds {
struct drm_panel *panel; struct drm_panel *panel;
struct drm_bridge *bridge; struct drm_bridge *bridge;
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct rockchip_encoder encoder;
struct dev_pin_info *pins; struct dev_pin_info *pins;
}; };
static inline struct rockchip_lvds *connector_to_lvds(struct drm_connector *connector)
{
return container_of(connector, struct rockchip_lvds, connector);
}
static inline struct rockchip_lvds *encoder_to_lvds(struct drm_encoder *encoder)
{
struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);
return container_of(rkencoder, struct rockchip_lvds, encoder);
}
static inline void rk3288_writel(struct rockchip_lvds *lvds, u32 offset, static inline void rk3288_writel(struct rockchip_lvds *lvds, u32 offset,
u32 val) u32 val)
{ {
...@@ -599,7 +605,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master, ...@@ -599,7 +605,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
goto err_put_remote; goto err_put_remote;
} }
encoder = &lvds->encoder; encoder = &lvds->encoder.encoder;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,
dev->of_node); dev->of_node);
...@@ -674,10 +680,10 @@ static void rockchip_lvds_unbind(struct device *dev, struct device *master, ...@@ -674,10 +680,10 @@ static void rockchip_lvds_unbind(struct device *dev, struct device *master,
const struct drm_encoder_helper_funcs *encoder_funcs; const struct drm_encoder_helper_funcs *encoder_funcs;
encoder_funcs = lvds->soc_data->helper_funcs; encoder_funcs = lvds->soc_data->helper_funcs;
encoder_funcs->disable(&lvds->encoder); encoder_funcs->disable(&lvds->encoder.encoder);
pm_runtime_disable(dev); pm_runtime_disable(dev);
drm_connector_cleanup(&lvds->connector); drm_connector_cleanup(&lvds->connector);
drm_encoder_cleanup(&lvds->encoder); drm_encoder_cleanup(&lvds->encoder.encoder);
} }
static const struct component_ops rockchip_lvds_component_ops = { static const struct component_ops rockchip_lvds_component_ops = {
......
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