*/
struct mdp5_ctl {
+ struct mdp5_ctl_manager *ctlm;
+
u32 id;
/* whether this CTL has been allocated or not: */
struct mdp5_ctl ctls[MAX_CTL];
};
-static struct mdp5_ctl_manager mdp5_ctl_mgr;
-
static inline
struct mdp5_kms *get_kms(struct mdp5_ctl_manager *ctl_mgr)
{
static inline
void ctl_write(struct mdp5_ctl *ctl, u32 reg, u32 data)
{
- struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
- struct mdp5_kms *mdp5_kms = get_kms(ctl_mgr);
+ struct mdp5_kms *mdp5_kms = get_kms(ctl->ctlm);
(void)ctl->reg_offset; /* TODO use this instead of mdp5_write */
mdp5_write(mdp5_kms, reg, data);
static inline
u32 ctl_read(struct mdp5_ctl *ctl, u32 reg)
{
- struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
- struct mdp5_kms *mdp5_kms = get_kms(ctl_mgr);
+ struct mdp5_kms *mdp5_kms = get_kms(ctl->ctlm);
(void)ctl->reg_offset; /* TODO use this instead of mdp5_write */
return mdp5_read(mdp5_kms, reg);
int mdp5_ctl_set_cursor(struct mdp5_ctl *ctl, bool enable)
{
- struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
+ struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
unsigned long flags;
u32 blend_cfg;
int lm;
int mdp5_ctl_commit(struct mdp5_ctl *ctl, u32 flush_mask)
{
- struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
+ struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
unsigned long flags;
if (flush_mask & MDP5_CTL_FLUSH_CURSOR_DUMMY) {
void mdp5_ctl_release(struct mdp5_ctl *ctl)
{
- struct mdp5_ctl_manager *ctl_mgr = &mdp5_ctl_mgr;
+ struct mdp5_ctl_manager *ctl_mgr = ctl->ctlm;
unsigned long flags;
if (unlikely(WARN_ON(ctl->id >= MAX_CTL) || !ctl->busy)) {
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;
+ struct mdp5_ctl_manager *ctl_mgr;
const struct mdp5_sub_block *ctl_cfg = &hw_cfg->ctl;
unsigned long flags;
int c, ret;
+ ctl_mgr = kzalloc(sizeof(*ctl_mgr), GFP_KERNEL);
+ if (!ctl_mgr) {
+ dev_err(dev->dev, "failed to allocate CTL manager\n");
+ ret = -ENOMEM;
+ goto fail;
+ }
+
if (unlikely(WARN_ON(ctl_cfg->count > MAX_CTL))) {
dev_err(dev->dev, "Increase static pool size to at least %d\n",
ctl_cfg->count);
ret = -EINVAL;
goto fail;
}
+ ctl->ctlm = ctl_mgr;
ctl->id = c;
ctl->mode = MODE_NONE;
ctl->reg_offset = ctl_cfg->base[c];