Commit 2388693e authored by Thierry Reding's avatar Thierry Reding Committed by Vincent Abriou

drm/sti: Use drm_crtc_vblank_*() API

Non-legacy drivers should only use this API to allow per-CRTC data to be
eventually moved into struct drm_crtc.

Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vincent Abriou <vincent.abriou@st.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Reviewed-by: default avatarVincent Abriou <vincent.abriou@st.com>
parent df00d029
...@@ -254,15 +254,17 @@ static int sti_crtc_set_property(struct drm_crtc *crtc, ...@@ -254,15 +254,17 @@ static int sti_crtc_set_property(struct drm_crtc *crtc,
int sti_crtc_vblank_cb(struct notifier_block *nb, int sti_crtc_vblank_cb(struct notifier_block *nb,
unsigned long event, void *data) unsigned long event, void *data)
{ {
struct drm_device *drm_dev;
struct sti_compositor *compo = struct sti_compositor *compo =
container_of(nb, struct sti_compositor, vtg_vblank_nb); container_of(nb, struct sti_compositor, vtg_vblank_nb);
int *crtc = data; struct drm_crtc *crtc = data;
struct sti_mixer *mixer;
unsigned long flags; unsigned long flags;
struct sti_private *priv; struct sti_private *priv;
unsigned int pipe;
drm_dev = compo->mixer[*crtc]->drm_crtc.dev; priv = crtc->dev->dev_private;
priv = drm_dev->dev_private; pipe = drm_crtc_index(crtc);
mixer = compo->mixer[pipe];
if ((event != VTG_TOP_FIELD_EVENT) && if ((event != VTG_TOP_FIELD_EVENT) &&
(event != VTG_BOTTOM_FIELD_EVENT)) { (event != VTG_BOTTOM_FIELD_EVENT)) {
...@@ -270,30 +272,30 @@ int sti_crtc_vblank_cb(struct notifier_block *nb, ...@@ -270,30 +272,30 @@ int sti_crtc_vblank_cb(struct notifier_block *nb,
return -EINVAL; return -EINVAL;
} }
drm_handle_vblank(drm_dev, *crtc); drm_crtc_handle_vblank(crtc);
spin_lock_irqsave(&drm_dev->event_lock, flags); spin_lock_irqsave(&crtc->dev->event_lock, flags);
if (compo->mixer[*crtc]->pending_event) { if (mixer->pending_event) {
drm_send_vblank_event(drm_dev, *crtc, drm_crtc_send_vblank_event(crtc, mixer->pending_event);
compo->mixer[*crtc]->pending_event); drm_crtc_vblank_put(crtc);
drm_vblank_put(drm_dev, *crtc); mixer->pending_event = NULL;
compo->mixer[*crtc]->pending_event = NULL;
} }
spin_unlock_irqrestore(&drm_dev->event_lock, flags); spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
if (compo->mixer[*crtc]->status == STI_MIXER_DISABLING) { if (mixer->status == STI_MIXER_DISABLING) {
struct drm_plane *p; struct drm_plane *p;
/* Disable mixer only if all overlay planes (GDP and VDP) /* Disable mixer only if all overlay planes (GDP and VDP)
* are disabled */ * are disabled */
list_for_each_entry(p, &drm_dev->mode_config.plane_list, head) { list_for_each_entry(p, &crtc->dev->mode_config.plane_list,
head) {
struct sti_plane *plane = to_sti_plane(p); struct sti_plane *plane = to_sti_plane(p);
if ((plane->desc & STI_PLANE_TYPE_MASK) <= STI_VDP) if ((plane->desc & STI_PLANE_TYPE_MASK) <= STI_VDP)
if (plane->status != STI_PLANE_DISABLED) if (plane->status != STI_PLANE_DISABLED)
return 0; return 0;
} }
sti_crtc_disable(&compo->mixer[*crtc]->drm_crtc); sti_crtc_disable(crtc);
} }
return 0; return 0;
...@@ -304,12 +306,13 @@ int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe) ...@@ -304,12 +306,13 @@ int sti_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
struct sti_private *dev_priv = dev->dev_private; struct sti_private *dev_priv = dev->dev_private;
struct sti_compositor *compo = dev_priv->compo; struct sti_compositor *compo = dev_priv->compo;
struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb;
struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
DRM_DEBUG_DRIVER("\n"); DRM_DEBUG_DRIVER("\n");
if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ? if (sti_vtg_register_client(pipe == STI_MIXER_MAIN ?
compo->vtg_main : compo->vtg_aux, compo->vtg_main : compo->vtg_aux,
vtg_vblank_nb, pipe)) { vtg_vblank_nb, crtc)) {
DRM_ERROR("Cannot register VTG notifier\n"); DRM_ERROR("Cannot register VTG notifier\n");
return -EINVAL; return -EINVAL;
} }
...@@ -323,6 +326,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe) ...@@ -323,6 +326,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
struct sti_private *priv = drm_dev->dev_private; struct sti_private *priv = drm_dev->dev_private;
struct sti_compositor *compo = priv->compo; struct sti_compositor *compo = priv->compo;
struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb; struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb;
struct drm_crtc *crtc = &compo->mixer[pipe]->drm_crtc;
DRM_DEBUG_DRIVER("\n"); DRM_DEBUG_DRIVER("\n");
...@@ -332,7 +336,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe) ...@@ -332,7 +336,7 @@ void sti_crtc_disable_vblank(struct drm_device *drm_dev, unsigned int pipe)
/* free the resources of the pending requests */ /* free the resources of the pending requests */
if (compo->mixer[pipe]->pending_event) { if (compo->mixer[pipe]->pending_event) {
drm_vblank_put(drm_dev, pipe); drm_crtc_vblank_put(crtc);
compo->mixer[pipe]->pending_event = NULL; compo->mixer[pipe]->pending_event = NULL;
} }
} }
......
...@@ -492,7 +492,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane, ...@@ -492,7 +492,7 @@ static void sti_gdp_atomic_update(struct drm_plane *drm_plane,
/* Register gdp callback */ /* Register gdp callback */
if (sti_vtg_register_client(mixer->id == STI_MIXER_MAIN ? if (sti_vtg_register_client(mixer->id == STI_MIXER_MAIN ?
compo->vtg_main : compo->vtg_aux, compo->vtg_main : compo->vtg_aux,
&gdp->vtg_field_nb, mixer->id)) { &gdp->vtg_field_nb, crtc)) {
DRM_ERROR("Cannot register VTG notifier\n"); DRM_ERROR("Cannot register VTG notifier\n");
return; return;
} }
......
...@@ -763,7 +763,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane, ...@@ -763,7 +763,7 @@ static void sti_hqvdp_atomic_update(struct drm_plane *drm_plane,
/* Register VTG Vsync callback to handle bottom fields */ /* Register VTG Vsync callback to handle bottom fields */
if (sti_vtg_register_client(hqvdp->vtg, if (sti_vtg_register_client(hqvdp->vtg,
&hqvdp->vtg_nb, &hqvdp->vtg_nb,
mixer->id)) { crtc)) {
DRM_ERROR("Cannot register VTG notifier\n"); DRM_ERROR("Cannot register VTG notifier\n");
return; return;
} }
......
...@@ -79,7 +79,7 @@ LIST_HEAD(vtg_lookup); ...@@ -79,7 +79,7 @@ LIST_HEAD(vtg_lookup);
* @irq: VTG irq * @irq: VTG irq
* @type: VTG type (main or aux) * @type: VTG type (main or aux)
* @notifier_list: notifier callback * @notifier_list: notifier callback
* @crtc_id: the crtc id for vblank event * @crtc: the CRTC for vblank event
* @slave: slave vtg * @slave: slave vtg
* @link: List node to link the structure in lookup list * @link: List node to link the structure in lookup list
*/ */
...@@ -90,7 +90,7 @@ struct sti_vtg { ...@@ -90,7 +90,7 @@ struct sti_vtg {
int irq; int irq;
u32 irq_status; u32 irq_status;
struct raw_notifier_head notifier_list; struct raw_notifier_head notifier_list;
int crtc_id; struct drm_crtc *crtc;
struct sti_vtg *slave; struct sti_vtg *slave;
struct list_head link; struct list_head link;
}; };
...@@ -283,13 +283,13 @@ u32 sti_vtg_get_pixel_number(struct drm_display_mode mode, int x) ...@@ -283,13 +283,13 @@ u32 sti_vtg_get_pixel_number(struct drm_display_mode mode, int x)
} }
EXPORT_SYMBOL(sti_vtg_get_pixel_number); EXPORT_SYMBOL(sti_vtg_get_pixel_number);
int sti_vtg_register_client(struct sti_vtg *vtg, int sti_vtg_register_client(struct sti_vtg *vtg, struct notifier_block *nb,
struct notifier_block *nb, int crtc_id) struct drm_crtc *crtc)
{ {
if (vtg->slave) if (vtg->slave)
return sti_vtg_register_client(vtg->slave, nb, crtc_id); return sti_vtg_register_client(vtg->slave, nb, crtc);
vtg->crtc_id = crtc_id; vtg->crtc = crtc;
return raw_notifier_chain_register(&vtg->notifier_list, nb); return raw_notifier_chain_register(&vtg->notifier_list, nb);
} }
EXPORT_SYMBOL(sti_vtg_register_client); EXPORT_SYMBOL(sti_vtg_register_client);
...@@ -311,7 +311,7 @@ static irqreturn_t vtg_irq_thread(int irq, void *arg) ...@@ -311,7 +311,7 @@ static irqreturn_t vtg_irq_thread(int irq, void *arg)
event = (vtg->irq_status & VTG_IRQ_TOP) ? event = (vtg->irq_status & VTG_IRQ_TOP) ?
VTG_TOP_FIELD_EVENT : VTG_BOTTOM_FIELD_EVENT; VTG_TOP_FIELD_EVENT : VTG_BOTTOM_FIELD_EVENT;
raw_notifier_call_chain(&vtg->notifier_list, event, &vtg->crtc_id); raw_notifier_call_chain(&vtg->notifier_list, event, vtg->crtc);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -17,8 +17,8 @@ struct notifier_block; ...@@ -17,8 +17,8 @@ struct notifier_block;
struct sti_vtg *of_vtg_find(struct device_node *np); struct sti_vtg *of_vtg_find(struct device_node *np);
void sti_vtg_set_config(struct sti_vtg *vtg, void sti_vtg_set_config(struct sti_vtg *vtg,
const struct drm_display_mode *mode); const struct drm_display_mode *mode);
int sti_vtg_register_client(struct sti_vtg *vtg, int sti_vtg_register_client(struct sti_vtg *vtg, struct notifier_block *nb,
struct notifier_block *nb, int crtc_id); struct drm_crtc *crtc);
int sti_vtg_unregister_client(struct sti_vtg *vtg, int sti_vtg_unregister_client(struct sti_vtg *vtg,
struct notifier_block *nb); struct notifier_block *nb);
......
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