Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42238da8 authored by Rob Clark's avatar Rob Clark
Browse files

drm/msm/mdp5: don't use void * for opaque types



For example, use 'struct mdp5_smp *' everywhere instead of 'void *', but
only declare it as 'struct mdp5_smp;' in common headers, so the struct
body is still private.  The accomplishes the desired modularity while
still letting the compiler provide some type checking for us.

Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 0deed25b
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -121,35 +121,27 @@ static const struct mdp5_cfg_handler cfg_handlers[] = {

static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev);

const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(void *cfg_hnd)
const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_handler)
{
	struct mdp5_cfg_handler *cfg_handler = cfg_hnd;

	return cfg_handler->config.hw;
}

struct mdp5_cfg *mdp5_cfg_get_config(void *cfg_hnd)
struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_handler)
{
	struct mdp5_cfg_handler *cfg_handler = cfg_hnd;

	return &cfg_handler->config;
}

int mdp5_cfg_get_hw_rev(void *cfg_hnd)
int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_handler)
{
	struct mdp5_cfg_handler *cfg_handler = cfg_hnd;

	return cfg_handler->revision;
}

void mdp5_cfg_destroy(void *cfg_hnd)
void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_handler)
{
	struct mdp5_cfg_handler *cfg_handler = cfg_hnd;

	kfree(cfg_handler);
}

void *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
		uint32_t major, uint32_t minor)
{
	struct drm_device *dev = mdp5_kms->dev;
+7 −5
Original line number Diff line number Diff line
@@ -78,12 +78,14 @@ struct mdp5_cfg {
};

struct mdp5_kms;
struct mdp5_cfg_handler;

const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(void *cfg_hnd);
struct mdp5_cfg *mdp5_cfg_get_config(void *cfg_hnd);
int mdp5_cfg_get_hw_rev(void *cfg_hnd);
const struct mdp5_cfg_hw *mdp5_cfg_get_hw_config(struct mdp5_cfg_handler *cfg_hnd);
struct mdp5_cfg *mdp5_cfg_get_config(struct mdp5_cfg_handler *cfg_hnd);
int mdp5_cfg_get_hw_rev(struct mdp5_cfg_handler *cfg_hnd);

void *mdp5_cfg_init(struct mdp5_kms *mdp5_kms, uint32_t major, uint32_t minor);
void mdp5_cfg_destroy(void *cfg_hnd);
struct mdp5_cfg_handler *mdp5_cfg_init(struct mdp5_kms *mdp5_kms,
		uint32_t major, uint32_t minor);
void mdp5_cfg_destroy(struct mdp5_cfg_handler *cfg_hnd);

#endif /* __MDP5_CFG_H__ */
+4 −4
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ struct mdp5_crtc {
	spinlock_t lm_lock;	/* protect REG_MDP5_LM_* registers */

	/* CTL used for this CRTC: */
	void *ctl;
	struct mdp5_ctl *ctl;

	/* if there is a pending flip, these will be non-null: */
	struct drm_pending_vblank_event *event;
@@ -261,7 +261,7 @@ static void blend_setup(struct drm_crtc *crtc)
	unsigned long flags;
#define blender(stage)	((stage) - STAGE_BASE)

	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg_priv);
	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);

	spin_lock_irqsave(&mdp5_crtc->lm_lock, flags);

@@ -327,7 +327,7 @@ static int mdp5_crtc_mode_set(struct drm_crtc *crtc,

	/* request a free CTL, if none is already allocated for this CRTC */
	if (!mdp5_crtc->ctl) {
		mdp5_crtc->ctl = mdp5_ctl_request(mdp5_kms->ctl_priv, crtc);
		mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc);
		if (!mdp5_crtc->ctl)
			return -EBUSY;
	}
@@ -595,7 +595,7 @@ int mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane)
	enum mdp_mixer_stage_id stage = STAGE_BASE;
	int max_nb_planes;

	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg_priv);
	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
	max_nb_planes = hw_cfg->lm.nb_stages;

	if (count_planes(crtc) >= max_nb_planes) {
+14 −23
Original line number Diff line number Diff line
@@ -50,7 +50,8 @@ struct mdp5_ctl {
	u32 flush_mask;

	bool cursor_on;
	void *crtc;

	struct drm_crtc *crtc;
};

struct mdp5_ctl_manager {
@@ -96,9 +97,8 @@ u32 ctl_read(struct mdp5_ctl *ctl, u32 reg)
}


int mdp5_ctl_set_intf(void *c, enum mdp5_intf intf)
int mdp5_ctl_set_intf(struct mdp5_ctl *ctl, enum mdp5_intf intf)
{
	struct mdp5_ctl *ctl = c;
	unsigned long flags;
	static const enum mdp5_intfnum intfnum[] = {
			INTF0, INTF1, INTF2, INTF3,
@@ -113,10 +113,9 @@ int mdp5_ctl_set_intf(void *c, enum mdp5_intf intf)
	return 0;
}

int mdp5_ctl_set_cursor(void *c, bool enable)
int mdp5_ctl_set_cursor(struct mdp5_ctl *ctl, bool enable)
{
	struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
	struct mdp5_ctl *ctl = c;
	unsigned long flags;
	u32 blend_cfg;
	int lm;
@@ -147,9 +146,8 @@ int mdp5_ctl_set_cursor(void *c, bool enable)
}


int mdp5_ctl_blend(void *c, u32 lm, u32 blend_cfg)
int mdp5_ctl_blend(struct mdp5_ctl *ctl, u32 lm, u32 blend_cfg)
{
	struct mdp5_ctl *ctl = c;
	unsigned long flags;

	if (ctl->cursor_on)
@@ -164,10 +162,9 @@ int mdp5_ctl_blend(void *c, u32 lm, u32 blend_cfg)
	return 0;
}

int mdp5_ctl_commit(void *c, u32 flush_mask)
int mdp5_ctl_commit(struct mdp5_ctl *ctl, u32 flush_mask)
{
	struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
	struct mdp5_ctl *ctl = c;
	unsigned long flags;

	if (flush_mask & MDP5_CTL_FLUSH_CURSOR_DUMMY) {
@@ -190,17 +187,14 @@ int mdp5_ctl_commit(void *c, u32 flush_mask)
	return 0;
}

u32 mdp5_ctl_get_flush(void *c)
u32 mdp5_ctl_get_flush(struct mdp5_ctl *ctl)
{
	struct mdp5_ctl *ctl = c;

	return ctl->flush_mask;
}

void mdp5_ctl_release(void *c)
void mdp5_ctl_release(struct mdp5_ctl *ctl)
{
	struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
	struct mdp5_ctl *ctl = c;
	unsigned long flags;

	if (unlikely(WARN_ON(ctl->id >= MAX_CTL) || !ctl->busy)) {
@@ -223,9 +217,9 @@ void mdp5_ctl_release(void *c)
 *
 * @return first free CTL
 */
void *mdp5_ctl_request(void *ctlm, void *crtc)
struct mdp5_ctl *mdp5_ctlm_request(struct mdp5_ctl_manager *ctl_mgr,
		struct drm_crtc *crtc)
{
	struct mdp5_ctl_manager *ctl_mgr = ctlm;
	struct mdp5_ctl *ctl = NULL;
	unsigned long flags;
	int c;
@@ -252,9 +246,8 @@ void *mdp5_ctl_request(void *ctlm, void *crtc)
	return ctl;
}

void mdp5_ctlm_hw_reset(void *ctlm)
void mdp5_ctlm_hw_reset(struct mdp5_ctl_manager *ctl_mgr)
{
	struct mdp5_ctl_manager *ctl_mgr = ctlm;
	unsigned long flags;
	int c;

@@ -267,15 +260,13 @@ void mdp5_ctlm_hw_reset(void *ctlm)
	}
}

void mdp5_ctlm_destroy(void *ctlm)
void mdp5_ctlm_destroy(struct mdp5_ctl_manager *ctl_mgr)
{
	struct mdp5_ctl_manager *ctl_mgr = ctlm;

	kfree(ctl_mgr);
}

void *mdp5_ctlm_init(struct drm_device *dev, void __iomem *mmio_base,
		const struct mdp5_cfg_hw *hw_cfg)
struct mdp5_ctl_manager *mdp5_ctlm_init(struct drm_device *dev,
		void __iomem *mmio_base, const struct mdp5_cfg_hw *hw_cfg)
{
	struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
	const struct mdp5_sub_block *ctl_cfg = &hw_cfg->ctl;
+12 −11
Original line number Diff line number Diff line
@@ -21,30 +21,31 @@
 * mdp5_ctlm_init() returns a ctlm (CTL Manager) handler,
 * which is then used to call the other mdp5_ctlm_*(ctlm, ...) functions.
 */
void *mdp5_ctlm_init(struct drm_device *dev, void __iomem *mmio_base,
		const struct mdp5_cfg_hw *hw_cfg);
void  mdp5_ctlm_hw_reset(void *ctlm);
void  mdp5_ctlm_destroy(void *ctlm);
struct mdp5_ctl_manager;
struct mdp5_ctl_manager *mdp5_ctlm_init(struct drm_device *dev,
		void __iomem *mmio_base, const struct mdp5_cfg_hw *hw_cfg);
void mdp5_ctlm_hw_reset(struct mdp5_ctl_manager *ctlm);
void mdp5_ctlm_destroy(struct mdp5_ctl_manager *ctlm);

/*
 * CTL prototypes:
 * mdp5_ctl_request(ctlm, ...) returns a ctl (CTL resource) handler,
 * which is then used to call the other mdp5_ctl_*(ctl, ...) functions.
 */
void *mdp5_ctl_request(void *ctlm, void *crtc);
struct mdp5_ctl *mdp5_ctlm_request(struct mdp5_ctl_manager *ctlm, struct drm_crtc *crtc);

int mdp5_ctl_set_intf(void *ctl, enum mdp5_intf intf);
int mdp5_ctl_set_intf(struct mdp5_ctl *ctl, enum mdp5_intf intf);

int mdp5_ctl_set_cursor(void *ctl, bool enable);
int mdp5_ctl_set_cursor(struct mdp5_ctl *ctl, bool enable);

/* @blend_cfg: see LM blender config definition below */
int mdp5_ctl_blend(void *ctl, u32 lm, u32 blend_cfg);
int mdp5_ctl_blend(struct mdp5_ctl *ctl, u32 lm, u32 blend_cfg);

/* @flush_mask: see CTL flush masks definitions below */
int mdp5_ctl_commit(void *ctl, u32 flush_mask);
u32 mdp5_ctl_get_flush(void *ctl);
int mdp5_ctl_commit(struct mdp5_ctl *ctl, u32 flush_mask);
u32 mdp5_ctl_get_flush(struct mdp5_ctl *ctl);

void mdp5_ctl_release(void *ctl);
void mdp5_ctl_release(struct mdp5_ctl *ctl);

/*
 * blend_cfg (LM blender config):
Loading