|
@@ -50,25 +50,11 @@ struct mdp4_crtc {
|
|
|
|
|
|
/* if there is a pending flip, these will be non-null: */
|
|
|
struct drm_pending_vblank_event *event;
|
|
|
- struct msm_fence_cb pageflip_cb;
|
|
|
|
|
|
#define PENDING_CURSOR 0x1
|
|
|
#define PENDING_FLIP 0x2
|
|
|
atomic_t pending;
|
|
|
|
|
|
- /* the fb that we logically (from PoV of KMS API) hold a ref
|
|
|
- * to. Which we may not yet be scanning out (we may still
|
|
|
- * be scanning out previous in case of page_flip while waiting
|
|
|
- * for gpu rendering to complete:
|
|
|
- */
|
|
|
- struct drm_framebuffer *fb;
|
|
|
-
|
|
|
- /* the fb that we currently hold a scanout ref to: */
|
|
|
- struct drm_framebuffer *scanout_fb;
|
|
|
-
|
|
|
- /* for unref'ing framebuffers after scanout completes: */
|
|
|
- struct drm_flip_work unref_fb_work;
|
|
|
-
|
|
|
/* for unref'ing cursor bo's after scanout completes: */
|
|
|
struct drm_flip_work unref_cursor_work;
|
|
|
|
|
@@ -110,47 +96,6 @@ static void crtc_flush(struct drm_crtc *crtc)
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_OVERLAY_FLUSH, flush);
|
|
|
}
|
|
|
|
|
|
-static void update_fb(struct drm_crtc *crtc, struct drm_framebuffer *new_fb)
|
|
|
-{
|
|
|
- struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
- struct drm_framebuffer *old_fb = mdp4_crtc->fb;
|
|
|
-
|
|
|
- /* grab reference to incoming scanout fb: */
|
|
|
- drm_framebuffer_reference(new_fb);
|
|
|
- mdp4_crtc->base.primary->fb = new_fb;
|
|
|
- mdp4_crtc->fb = new_fb;
|
|
|
-
|
|
|
- if (old_fb)
|
|
|
- drm_flip_work_queue(&mdp4_crtc->unref_fb_work, old_fb);
|
|
|
-}
|
|
|
-
|
|
|
-/* unlike update_fb(), take a ref to the new scanout fb *before* updating
|
|
|
- * plane, then call this. Needed to ensure we don't unref the buffer that
|
|
|
- * is actually still being scanned out.
|
|
|
- *
|
|
|
- * Note that this whole thing goes away with atomic.. since we can defer
|
|
|
- * calling into driver until rendering is done.
|
|
|
- */
|
|
|
-static void update_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
|
|
|
-{
|
|
|
- struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
-
|
|
|
- /* flush updates, to make sure hw is updated to new scanout fb,
|
|
|
- * so that we can safely queue unref to current fb (ie. next
|
|
|
- * vblank we know hw is done w/ previous scanout_fb).
|
|
|
- */
|
|
|
- crtc_flush(crtc);
|
|
|
-
|
|
|
- if (mdp4_crtc->scanout_fb)
|
|
|
- drm_flip_work_queue(&mdp4_crtc->unref_fb_work,
|
|
|
- mdp4_crtc->scanout_fb);
|
|
|
-
|
|
|
- mdp4_crtc->scanout_fb = fb;
|
|
|
-
|
|
|
- /* enable vblank to complete flip: */
|
|
|
- request_pending(crtc, PENDING_FLIP);
|
|
|
-}
|
|
|
-
|
|
|
/* if file!=NULL, this is preclose potential cancel-flip path */
|
|
|
static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
|
|
|
{
|
|
@@ -168,38 +113,13 @@ static void complete_flip(struct drm_crtc *crtc, struct drm_file *file)
|
|
|
*/
|
|
|
if (!file || (event->base.file_priv == file)) {
|
|
|
mdp4_crtc->event = NULL;
|
|
|
+ DBG("%s: send event: %p", mdp4_crtc->name, event);
|
|
|
drm_send_vblank_event(dev, mdp4_crtc->id, event);
|
|
|
}
|
|
|
}
|
|
|
spin_unlock_irqrestore(&dev->event_lock, flags);
|
|
|
}
|
|
|
|
|
|
-static void pageflip_cb(struct msm_fence_cb *cb)
|
|
|
-{
|
|
|
- struct mdp4_crtc *mdp4_crtc =
|
|
|
- container_of(cb, struct mdp4_crtc, pageflip_cb);
|
|
|
- struct drm_crtc *crtc = &mdp4_crtc->base;
|
|
|
- struct drm_framebuffer *fb = crtc->primary->fb;
|
|
|
-
|
|
|
- if (!fb)
|
|
|
- return;
|
|
|
-
|
|
|
- drm_framebuffer_reference(fb);
|
|
|
- mdp4_plane_set_scanout(crtc->primary, fb);
|
|
|
- update_scanout(crtc, fb);
|
|
|
-}
|
|
|
-
|
|
|
-static void unref_fb_worker(struct drm_flip_work *work, void *val)
|
|
|
-{
|
|
|
- struct mdp4_crtc *mdp4_crtc =
|
|
|
- container_of(work, struct mdp4_crtc, unref_fb_work);
|
|
|
- struct drm_device *dev = mdp4_crtc->base.dev;
|
|
|
-
|
|
|
- mutex_lock(&dev->mode_config.mutex);
|
|
|
- drm_framebuffer_unreference(val);
|
|
|
- mutex_unlock(&dev->mode_config.mutex);
|
|
|
-}
|
|
|
-
|
|
|
static void unref_cursor_worker(struct drm_flip_work *work, void *val)
|
|
|
{
|
|
|
struct mdp4_crtc *mdp4_crtc =
|
|
@@ -215,7 +135,6 @@ static void mdp4_crtc_destroy(struct drm_crtc *crtc)
|
|
|
struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
|
|
|
drm_crtc_cleanup(crtc);
|
|
|
- drm_flip_work_cleanup(&mdp4_crtc->unref_fb_work);
|
|
|
drm_flip_work_cleanup(&mdp4_crtc->unref_cursor_work);
|
|
|
|
|
|
kfree(mdp4_crtc);
|
|
@@ -323,18 +242,18 @@ static void blend_setup(struct drm_crtc *crtc)
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_LAYERMIXER_IN_CFG, mixer_cfg);
|
|
|
}
|
|
|
|
|
|
-static int mdp4_crtc_mode_set(struct drm_crtc *crtc,
|
|
|
- struct drm_display_mode *mode,
|
|
|
- struct drm_display_mode *adjusted_mode,
|
|
|
- int x, int y,
|
|
|
- struct drm_framebuffer *old_fb)
|
|
|
+static void mdp4_crtc_mode_set_nofb(struct drm_crtc *crtc)
|
|
|
{
|
|
|
struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
struct mdp4_kms *mdp4_kms = get_kms(crtc);
|
|
|
enum mdp4_dma dma = mdp4_crtc->dma;
|
|
|
- int ret, ovlp = mdp4_crtc->ovlp;
|
|
|
+ int ovlp = mdp4_crtc->ovlp;
|
|
|
+ struct drm_display_mode *mode;
|
|
|
+
|
|
|
+ if (WARN_ON(!crtc->state))
|
|
|
+ return;
|
|
|
|
|
|
- mode = adjusted_mode;
|
|
|
+ mode = &crtc->state->adjusted_mode;
|
|
|
|
|
|
DBG("%s: set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
|
|
|
mdp4_crtc->name, mode->base.id, mode->name,
|
|
@@ -345,20 +264,6 @@ static int mdp4_crtc_mode_set(struct drm_crtc *crtc,
|
|
|
mode->vsync_end, mode->vtotal,
|
|
|
mode->type, mode->flags);
|
|
|
|
|
|
- /* grab extra ref for update_scanout() */
|
|
|
- drm_framebuffer_reference(crtc->primary->fb);
|
|
|
-
|
|
|
- ret = mdp4_plane_mode_set(crtc->primary, crtc, crtc->primary->fb,
|
|
|
- 0, 0, mode->hdisplay, mode->vdisplay,
|
|
|
- x << 16, y << 16,
|
|
|
- mode->hdisplay << 16, mode->vdisplay << 16);
|
|
|
- if (ret) {
|
|
|
- drm_framebuffer_unreference(crtc->primary->fb);
|
|
|
- dev_err(crtc->dev->dev, "%s: failed to set mode on plane: %d\n",
|
|
|
- mdp4_crtc->name, ret);
|
|
|
- return ret;
|
|
|
- }
|
|
|
-
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_DMA_SRC_SIZE(dma),
|
|
|
MDP4_DMA_SRC_SIZE_WIDTH(mode->hdisplay) |
|
|
|
MDP4_DMA_SRC_SIZE_HEIGHT(mode->vdisplay));
|
|
@@ -383,11 +288,6 @@ static int mdp4_crtc_mode_set(struct drm_crtc *crtc,
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_DMA_E_QUANT(1), 0x00ff0000);
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_DMA_E_QUANT(2), 0x00ff0000);
|
|
|
}
|
|
|
-
|
|
|
- update_fb(crtc, crtc->primary->fb);
|
|
|
- update_scanout(crtc, crtc->primary->fb);
|
|
|
-
|
|
|
- return 0;
|
|
|
}
|
|
|
|
|
|
static void mdp4_crtc_prepare(struct drm_crtc *crtc)
|
|
@@ -409,59 +309,51 @@ static void mdp4_crtc_commit(struct drm_crtc *crtc)
|
|
|
drm_crtc_vblank_put(crtc);
|
|
|
}
|
|
|
|
|
|
-static int mdp4_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
|
|
|
- struct drm_framebuffer *old_fb)
|
|
|
+static void mdp4_crtc_load_lut(struct drm_crtc *crtc)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
|
|
|
+ struct drm_crtc_state *state)
|
|
|
{
|
|
|
- struct drm_plane *plane = crtc->primary;
|
|
|
- struct drm_display_mode *mode = &crtc->mode;
|
|
|
- int ret;
|
|
|
+ struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
+ struct drm_device *dev = crtc->dev;
|
|
|
|
|
|
- /* grab extra ref for update_scanout() */
|
|
|
- drm_framebuffer_reference(crtc->primary->fb);
|
|
|
+ DBG("%s: check", mdp4_crtc->name);
|
|
|
|
|
|
- ret = mdp4_plane_mode_set(plane, crtc, crtc->primary->fb,
|
|
|
- 0, 0, mode->hdisplay, mode->vdisplay,
|
|
|
- x << 16, y << 16,
|
|
|
- mode->hdisplay << 16, mode->vdisplay << 16);
|
|
|
- if (ret) {
|
|
|
- drm_framebuffer_unreference(crtc->primary->fb);
|
|
|
- return ret;
|
|
|
+ if (mdp4_crtc->event) {
|
|
|
+ dev_err(dev->dev, "already pending flip!\n");
|
|
|
+ return -EBUSY;
|
|
|
}
|
|
|
|
|
|
- update_fb(crtc, crtc->primary->fb);
|
|
|
- update_scanout(crtc, crtc->primary->fb);
|
|
|
+ // TODO anything else to check?
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void mdp4_crtc_load_lut(struct drm_crtc *crtc)
|
|
|
+static void mdp4_crtc_atomic_begin(struct drm_crtc *crtc)
|
|
|
{
|
|
|
+ struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
+ DBG("%s: begin", mdp4_crtc->name);
|
|
|
}
|
|
|
|
|
|
-static int mdp4_crtc_page_flip(struct drm_crtc *crtc,
|
|
|
- struct drm_framebuffer *new_fb,
|
|
|
- struct drm_pending_vblank_event *event,
|
|
|
- uint32_t page_flip_flags)
|
|
|
+static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc)
|
|
|
{
|
|
|
struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
struct drm_device *dev = crtc->dev;
|
|
|
- struct drm_gem_object *obj;
|
|
|
unsigned long flags;
|
|
|
|
|
|
- if (mdp4_crtc->event) {
|
|
|
- dev_err(dev->dev, "already pending flip!\n");
|
|
|
- return -EBUSY;
|
|
|
- }
|
|
|
+ DBG("%s: flush", mdp4_crtc->name);
|
|
|
|
|
|
- obj = msm_framebuffer_bo(new_fb, 0);
|
|
|
+ WARN_ON(mdp4_crtc->event);
|
|
|
|
|
|
spin_lock_irqsave(&dev->event_lock, flags);
|
|
|
- mdp4_crtc->event = event;
|
|
|
+ mdp4_crtc->event = crtc->state->event;
|
|
|
spin_unlock_irqrestore(&dev->event_lock, flags);
|
|
|
|
|
|
- update_fb(crtc, new_fb);
|
|
|
-
|
|
|
- return msm_gem_queue_inactive_cb(obj, &mdp4_crtc->pageflip_cb);
|
|
|
+ blend_setup(crtc);
|
|
|
+ crtc_flush(crtc);
|
|
|
+ request_pending(crtc, PENDING_FLIP);
|
|
|
}
|
|
|
|
|
|
static int mdp4_crtc_set_property(struct drm_crtc *crtc,
|
|
@@ -599,22 +491,29 @@ static int mdp4_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
|
|
|
}
|
|
|
|
|
|
static const struct drm_crtc_funcs mdp4_crtc_funcs = {
|
|
|
- .set_config = drm_crtc_helper_set_config,
|
|
|
+ .set_config = drm_atomic_helper_set_config,
|
|
|
.destroy = mdp4_crtc_destroy,
|
|
|
- .page_flip = mdp4_crtc_page_flip,
|
|
|
+ .page_flip = drm_atomic_helper_page_flip,
|
|
|
.set_property = mdp4_crtc_set_property,
|
|
|
.cursor_set = mdp4_crtc_cursor_set,
|
|
|
.cursor_move = mdp4_crtc_cursor_move,
|
|
|
+ .reset = drm_atomic_helper_crtc_reset,
|
|
|
+ .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
|
|
|
+ .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
|
|
|
};
|
|
|
|
|
|
static const struct drm_crtc_helper_funcs mdp4_crtc_helper_funcs = {
|
|
|
.dpms = mdp4_crtc_dpms,
|
|
|
.mode_fixup = mdp4_crtc_mode_fixup,
|
|
|
- .mode_set = mdp4_crtc_mode_set,
|
|
|
+ .mode_set_nofb = mdp4_crtc_mode_set_nofb,
|
|
|
+ .mode_set = drm_helper_crtc_mode_set,
|
|
|
+ .mode_set_base = drm_helper_crtc_mode_set_base,
|
|
|
.prepare = mdp4_crtc_prepare,
|
|
|
.commit = mdp4_crtc_commit,
|
|
|
- .mode_set_base = mdp4_crtc_mode_set_base,
|
|
|
.load_lut = mdp4_crtc_load_lut,
|
|
|
+ .atomic_check = mdp4_crtc_atomic_check,
|
|
|
+ .atomic_begin = mdp4_crtc_atomic_begin,
|
|
|
+ .atomic_flush = mdp4_crtc_atomic_flush,
|
|
|
};
|
|
|
|
|
|
static void mdp4_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
|
|
@@ -630,7 +529,6 @@ static void mdp4_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
|
|
|
|
|
|
if (pending & PENDING_FLIP) {
|
|
|
complete_flip(crtc, NULL);
|
|
|
- drm_flip_work_commit(&mdp4_crtc->unref_fb_work, priv->wq);
|
|
|
}
|
|
|
|
|
|
if (pending & PENDING_CURSOR) {
|
|
@@ -655,7 +553,8 @@ uint32_t mdp4_crtc_vblank(struct drm_crtc *crtc)
|
|
|
|
|
|
void mdp4_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file)
|
|
|
{
|
|
|
- DBG("cancel: %p", file);
|
|
|
+ struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
+ DBG("%s: cancel: %p", mdp4_crtc->name, file);
|
|
|
complete_flip(crtc, file);
|
|
|
}
|
|
|
|
|
@@ -709,29 +608,6 @@ void mdp4_crtc_set_intf(struct drm_crtc *crtc, enum mdp4_intf intf, int mixer)
|
|
|
mdp4_write(mdp4_kms, REG_MDP4_DISP_INTF_SEL, intf_sel);
|
|
|
}
|
|
|
|
|
|
-static void set_attach(struct drm_crtc *crtc, enum mdp4_pipe pipe_id,
|
|
|
- struct drm_plane *plane)
|
|
|
-{
|
|
|
- struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
|
|
|
-
|
|
|
- blend_setup(crtc);
|
|
|
- if (mdp4_crtc->enabled && (plane != crtc->primary))
|
|
|
- crtc_flush(crtc);
|
|
|
-}
|
|
|
-
|
|
|
-void mdp4_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane)
|
|
|
-{
|
|
|
- set_attach(crtc, mdp4_plane_pipe(plane), plane);
|
|
|
-}
|
|
|
-
|
|
|
-void mdp4_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane)
|
|
|
-{
|
|
|
- /* don't actually detatch our primary plane: */
|
|
|
- if (crtc->primary == plane)
|
|
|
- return;
|
|
|
- set_attach(crtc, mdp4_plane_pipe(plane), NULL);
|
|
|
-}
|
|
|
-
|
|
|
static const char *dma_names[] = {
|
|
|
"DMA_P", "DMA_S", "DMA_E",
|
|
|
};
|
|
@@ -766,13 +642,9 @@ struct drm_crtc *mdp4_crtc_init(struct drm_device *dev,
|
|
|
|
|
|
spin_lock_init(&mdp4_crtc->cursor.lock);
|
|
|
|
|
|
- drm_flip_work_init(&mdp4_crtc->unref_fb_work,
|
|
|
- "unref fb", unref_fb_worker);
|
|
|
drm_flip_work_init(&mdp4_crtc->unref_cursor_work,
|
|
|
"unref cursor", unref_cursor_worker);
|
|
|
|
|
|
- INIT_FENCE_CB(&mdp4_crtc->pageflip_cb, pageflip_cb);
|
|
|
-
|
|
|
drm_crtc_init_with_planes(dev, crtc, plane, NULL, &mdp4_crtc_funcs);
|
|
|
drm_crtc_helper_add(crtc, &mdp4_crtc_helper_funcs);
|
|
|
plane->crtc = crtc;
|