drm/vc4: hdmi: Add container_of macros for encoders and connectors
Whenever the code needs to access the vc4_hdmi structure from a DRM connector or encoder, it first accesses the drm_device associated to the connector, then retrieve the drm_dev private data which gives it a pointer to our vc4_dev, and will finally follow the vc4_hdmi pointer in that structure. That will also give us some trouble when having multiple controllers, but now that we have our encoder and connector structures that are part of vc4_hdmi, we can simply call container_of on the DRM connector or encoder and retrieve the vc4_hdmi structure directly. Signed-off-by: Maxime Ripard <maxime@cerno.tech> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Eric Anholt <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/536ecce5898ea75839fa3788b876009d69a5ccae.1599120059.git-series.maxime@cerno.tech
This commit is contained in:
@@ -78,6 +78,22 @@ struct vc4_hdmi {
|
||||
struct debugfs_regset32 hd_regset;
|
||||
};
|
||||
|
||||
static inline struct vc4_hdmi *
|
||||
connector_to_vc4_hdmi(struct drm_connector *connector)
|
||||
{
|
||||
struct vc4_hdmi_connector *_connector = to_vc4_hdmi_connector(connector);
|
||||
|
||||
return container_of(_connector, struct vc4_hdmi, connector);
|
||||
}
|
||||
|
||||
static inline struct vc4_hdmi *
|
||||
encoder_to_vc4_hdmi(struct drm_encoder *encoder)
|
||||
{
|
||||
struct vc4_hdmi_encoder *_encoder = to_vc4_hdmi_encoder(encoder);
|
||||
|
||||
return container_of(_encoder, struct vc4_hdmi, encoder);
|
||||
}
|
||||
|
||||
#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
|
||||
#define HDMI_WRITE(offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset)
|
||||
#define HD_READ(offset) readl(vc4_hdmi->hd_regs + offset)
|
||||
|
Reference in New Issue
Block a user