2 * Copyright (C) 2013 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
22 void mdp4_set_irqmask(struct mdp_kms
*mdp_kms
, uint32_t irqmask
)
24 mdp4_write(to_mdp4_kms(mdp_kms
), REG_MDP4_INTR_ENABLE
, irqmask
);
27 static void mdp4_irq_error_handler(struct mdp_irq
*irq
, uint32_t irqstatus
)
29 DRM_ERROR("errors: %08x\n", irqstatus
);
32 void mdp4_irq_preinstall(struct msm_kms
*kms
)
34 struct mdp4_kms
*mdp4_kms
= to_mdp4_kms(to_mdp_kms(kms
));
35 mdp4_write(mdp4_kms
, REG_MDP4_INTR_CLEAR
, 0xffffffff);
38 int mdp4_irq_postinstall(struct msm_kms
*kms
)
40 struct mdp_kms
*mdp_kms
= to_mdp_kms(kms
);
41 struct mdp4_kms
*mdp4_kms
= to_mdp4_kms(mdp_kms
);
42 struct mdp_irq
*error_handler
= &mdp4_kms
->error_handler
;
44 error_handler
->irq
= mdp4_irq_error_handler
;
45 error_handler
->irqmask
= MDP4_IRQ_PRIMARY_INTF_UDERRUN
|
46 MDP4_IRQ_EXTERNAL_INTF_UDERRUN
;
48 mdp_irq_register(mdp_kms
, error_handler
);
53 void mdp4_irq_uninstall(struct msm_kms
*kms
)
55 struct mdp4_kms
*mdp4_kms
= to_mdp4_kms(to_mdp_kms(kms
));
56 mdp4_write(mdp4_kms
, REG_MDP4_INTR_ENABLE
, 0x00000000);
59 irqreturn_t
mdp4_irq(struct msm_kms
*kms
)
61 struct mdp_kms
*mdp_kms
= to_mdp_kms(kms
);
62 struct mdp4_kms
*mdp4_kms
= to_mdp4_kms(mdp_kms
);
63 struct drm_device
*dev
= mdp4_kms
->dev
;
64 struct msm_drm_private
*priv
= dev
->dev_private
;
68 status
= mdp4_read(mdp4_kms
, REG_MDP4_INTR_STATUS
);
69 mdp4_write(mdp4_kms
, REG_MDP4_INTR_CLEAR
, status
);
71 VERB("status=%08x", status
);
73 for (id
= 0; id
< priv
->num_crtcs
; id
++)
74 if (status
& mdp4_crtc_vblank(priv
->crtcs
[id
]))
75 drm_handle_vblank(dev
, id
);
77 mdp_dispatch_irqs(mdp_kms
, status
);
82 int mdp4_enable_vblank(struct msm_kms
*kms
, struct drm_crtc
*crtc
)
84 mdp_update_vblank_mask(to_mdp_kms(kms
),
85 mdp4_crtc_vblank(crtc
), true);
89 void mdp4_disable_vblank(struct msm_kms
*kms
, struct drm_crtc
*crtc
)
91 mdp_update_vblank_mask(to_mdp_kms(kms
),
92 mdp4_crtc_vblank(crtc
), false);