|
@@ -68,6 +68,7 @@ struct fimd_win_data {
|
|
void __iomem *vaddr;
|
|
void __iomem *vaddr;
|
|
unsigned int buf_offsize;
|
|
unsigned int buf_offsize;
|
|
unsigned int line_size; /* bytes */
|
|
unsigned int line_size; /* bytes */
|
|
|
|
+ bool enabled;
|
|
};
|
|
};
|
|
|
|
|
|
struct fimd_context {
|
|
struct fimd_context {
|
|
@@ -119,7 +120,7 @@ static int fimd_display_power_on(struct device *dev, int mode)
|
|
{
|
|
{
|
|
DRM_DEBUG_KMS("%s\n", __FILE__);
|
|
DRM_DEBUG_KMS("%s\n", __FILE__);
|
|
|
|
|
|
- /* TODO. */
|
|
|
|
|
|
+ /* TODO */
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -132,6 +133,31 @@ static struct exynos_drm_display_ops fimd_display_ops = {
|
|
.power_on = fimd_display_power_on,
|
|
.power_on = fimd_display_power_on,
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+static void fimd_dpms(struct device *subdrv_dev, int mode)
|
|
|
|
+{
|
|
|
|
+ DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode);
|
|
|
|
+
|
|
|
|
+ /* TODO */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void fimd_apply(struct device *subdrv_dev)
|
|
|
|
+{
|
|
|
|
+ struct fimd_context *ctx = get_fimd_context(subdrv_dev);
|
|
|
|
+ struct exynos_drm_manager *mgr = &ctx->subdrv.manager;
|
|
|
|
+ struct exynos_drm_manager_ops *mgr_ops = mgr->ops;
|
|
|
|
+ struct exynos_drm_overlay_ops *ovl_ops = mgr->overlay_ops;
|
|
|
|
+ struct fimd_win_data *win_data;
|
|
|
|
+
|
|
|
|
+ DRM_DEBUG_KMS("%s\n", __FILE__);
|
|
|
|
+
|
|
|
|
+ win_data = &ctx->win_data[ctx->default_win];
|
|
|
|
+ if (win_data->enabled && (ovl_ops && ovl_ops->commit))
|
|
|
|
+ ovl_ops->commit(subdrv_dev);
|
|
|
|
+
|
|
|
|
+ if (mgr_ops && mgr_ops->commit)
|
|
|
|
+ mgr_ops->commit(subdrv_dev);
|
|
|
|
+}
|
|
|
|
+
|
|
static void fimd_commit(struct device *dev)
|
|
static void fimd_commit(struct device *dev)
|
|
{
|
|
{
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
@@ -177,40 +203,6 @@ static void fimd_commit(struct device *dev)
|
|
writel(val, ctx->regs + VIDCON0);
|
|
writel(val, ctx->regs + VIDCON0);
|
|
}
|
|
}
|
|
|
|
|
|
-static void fimd_disable(struct device *dev)
|
|
|
|
-{
|
|
|
|
- struct fimd_context *ctx = get_fimd_context(dev);
|
|
|
|
- struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
|
|
|
|
- struct drm_device *drm_dev = subdrv->drm_dev;
|
|
|
|
- struct exynos_drm_manager *manager = &subdrv->manager;
|
|
|
|
- u32 val;
|
|
|
|
-
|
|
|
|
- DRM_DEBUG_KMS("%s\n", __FILE__);
|
|
|
|
-
|
|
|
|
- /* fimd dma off */
|
|
|
|
- val = readl(ctx->regs + VIDCON0);
|
|
|
|
- val &= ~(VIDCON0_ENVID | VIDCON0_ENVID_F);
|
|
|
|
- writel(val, ctx->regs + VIDCON0);
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * if vblank is enabled status with dma off then
|
|
|
|
- * it disables vsync interrupt.
|
|
|
|
- */
|
|
|
|
- if (drm_dev->vblank_enabled[manager->pipe] &&
|
|
|
|
- atomic_read(&drm_dev->vblank_refcount[manager->pipe])) {
|
|
|
|
- drm_vblank_put(drm_dev, manager->pipe);
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * if vblank_disable_allowed is 0 then disable
|
|
|
|
- * vsync interrupt right now else the vsync interrupt
|
|
|
|
- * would be disabled by drm timer once a current process
|
|
|
|
- * gives up ownershop of vblank event.
|
|
|
|
- */
|
|
|
|
- if (!drm_dev->vblank_disable_allowed)
|
|
|
|
- drm_vblank_off(drm_dev, manager->pipe);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int fimd_enable_vblank(struct device *dev)
|
|
static int fimd_enable_vblank(struct device *dev)
|
|
{
|
|
{
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
@@ -253,8 +245,9 @@ static void fimd_disable_vblank(struct device *dev)
|
|
}
|
|
}
|
|
|
|
|
|
static struct exynos_drm_manager_ops fimd_manager_ops = {
|
|
static struct exynos_drm_manager_ops fimd_manager_ops = {
|
|
|
|
+ .dpms = fimd_dpms,
|
|
|
|
+ .apply = fimd_apply,
|
|
.commit = fimd_commit,
|
|
.commit = fimd_commit,
|
|
- .disable = fimd_disable,
|
|
|
|
.enable_vblank = fimd_enable_vblank,
|
|
.enable_vblank = fimd_enable_vblank,
|
|
.disable_vblank = fimd_disable_vblank,
|
|
.disable_vblank = fimd_disable_vblank,
|
|
};
|
|
};
|
|
@@ -472,16 +465,24 @@ static void fimd_win_commit(struct device *dev)
|
|
if (win != 0)
|
|
if (win != 0)
|
|
fimd_win_set_colkey(dev, win);
|
|
fimd_win_set_colkey(dev, win);
|
|
|
|
|
|
|
|
+ /* wincon */
|
|
|
|
+ val = readl(ctx->regs + WINCON(win));
|
|
|
|
+ val |= WINCONx_ENWIN;
|
|
|
|
+ writel(val, ctx->regs + WINCON(win));
|
|
|
|
+
|
|
/* Enable DMA channel and unprotect windows */
|
|
/* Enable DMA channel and unprotect windows */
|
|
val = readl(ctx->regs + SHADOWCON);
|
|
val = readl(ctx->regs + SHADOWCON);
|
|
val |= SHADOWCON_CHx_ENABLE(win);
|
|
val |= SHADOWCON_CHx_ENABLE(win);
|
|
val &= ~SHADOWCON_WINx_PROTECT(win);
|
|
val &= ~SHADOWCON_WINx_PROTECT(win);
|
|
writel(val, ctx->regs + SHADOWCON);
|
|
writel(val, ctx->regs + SHADOWCON);
|
|
|
|
+
|
|
|
|
+ win_data->enabled = true;
|
|
}
|
|
}
|
|
|
|
|
|
static void fimd_win_disable(struct device *dev)
|
|
static void fimd_win_disable(struct device *dev)
|
|
{
|
|
{
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
struct fimd_context *ctx = get_fimd_context(dev);
|
|
|
|
+ struct fimd_win_data *win_data;
|
|
int win = ctx->default_win;
|
|
int win = ctx->default_win;
|
|
u32 val;
|
|
u32 val;
|
|
|
|
|
|
@@ -490,6 +491,8 @@ static void fimd_win_disable(struct device *dev)
|
|
if (win < 0 || win > WINDOWS_NR)
|
|
if (win < 0 || win > WINDOWS_NR)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ win_data = &ctx->win_data[win];
|
|
|
|
+
|
|
/* protect windows */
|
|
/* protect windows */
|
|
val = readl(ctx->regs + SHADOWCON);
|
|
val = readl(ctx->regs + SHADOWCON);
|
|
val |= SHADOWCON_WINx_PROTECT(win);
|
|
val |= SHADOWCON_WINx_PROTECT(win);
|
|
@@ -505,6 +508,8 @@ static void fimd_win_disable(struct device *dev)
|
|
val &= ~SHADOWCON_CHx_ENABLE(win);
|
|
val &= ~SHADOWCON_CHx_ENABLE(win);
|
|
val &= ~SHADOWCON_WINx_PROTECT(win);
|
|
val &= ~SHADOWCON_WINx_PROTECT(win);
|
|
writel(val, ctx->regs + SHADOWCON);
|
|
writel(val, ctx->regs + SHADOWCON);
|
|
|
|
+
|
|
|
|
+ win_data->enabled = false;
|
|
}
|
|
}
|
|
|
|
|
|
static struct exynos_drm_overlay_ops fimd_overlay_ops = {
|
|
static struct exynos_drm_overlay_ops fimd_overlay_ops = {
|
|
@@ -540,9 +545,17 @@ static void fimd_finish_pageflip(struct drm_device *drm_dev, int crtc)
|
|
wake_up_interruptible(&e->base.file_priv->event_wait);
|
|
wake_up_interruptible(&e->base.file_priv->event_wait);
|
|
}
|
|
}
|
|
|
|
|
|
- if (is_checked)
|
|
|
|
|
|
+ if (is_checked) {
|
|
drm_vblank_put(drm_dev, crtc);
|
|
drm_vblank_put(drm_dev, crtc);
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * don't off vblank if vblank_disable_allowed is 1,
|
|
|
|
+ * because vblank would be off by timer handler.
|
|
|
|
+ */
|
|
|
|
+ if (!drm_dev->vblank_disable_allowed)
|
|
|
|
+ drm_vblank_off(drm_dev, crtc);
|
|
|
|
+ }
|
|
|
|
+
|
|
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
|
|
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -560,19 +573,14 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
|
|
/* VSYNC interrupt */
|
|
/* VSYNC interrupt */
|
|
writel(VIDINTCON1_INT_FRAME, ctx->regs + VIDINTCON1);
|
|
writel(VIDINTCON1_INT_FRAME, ctx->regs + VIDINTCON1);
|
|
|
|
|
|
- /*
|
|
|
|
- * in case that vblank_disable_allowed is 1, it could induce
|
|
|
|
- * the problem that manager->pipe could be -1 because with
|
|
|
|
- * disable callback, vsync interrupt isn't disabled and at this moment,
|
|
|
|
- * vsync interrupt could occur. the vsync interrupt would be disabled
|
|
|
|
- * by timer handler later.
|
|
|
|
- */
|
|
|
|
- if (manager->pipe == -1)
|
|
|
|
- return IRQ_HANDLED;
|
|
|
|
|
|
+ /* check the crtc is detached already from encoder */
|
|
|
|
+ if (manager->pipe < 0)
|
|
|
|
+ goto out;
|
|
|
|
|
|
drm_handle_vblank(drm_dev, manager->pipe);
|
|
drm_handle_vblank(drm_dev, manager->pipe);
|
|
fimd_finish_pageflip(drm_dev, manager->pipe);
|
|
fimd_finish_pageflip(drm_dev, manager->pipe);
|
|
|
|
|
|
|
|
+out:
|
|
return IRQ_HANDLED;
|
|
return IRQ_HANDLED;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -590,6 +598,13 @@ static int fimd_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
|
|
*/
|
|
*/
|
|
drm_dev->irq_enabled = 1;
|
|
drm_dev->irq_enabled = 1;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * with vblank_disable_allowed = 1, vblank interrupt will be disabled
|
|
|
|
+ * by drm timer once a current process gives up ownership of
|
|
|
|
+ * vblank event.(after drm_vblank_put function is called)
|
|
|
|
+ */
|
|
|
|
+ drm_dev->vblank_disable_allowed = 1;
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -739,15 +754,15 @@ static int __devinit fimd_probe(struct platform_device *pdev)
|
|
|
|
|
|
ctx->irq = res->start;
|
|
ctx->irq = res->start;
|
|
|
|
|
|
- for (win = 0; win < WINDOWS_NR; win++)
|
|
|
|
- fimd_clear_win(ctx, win);
|
|
|
|
-
|
|
|
|
ret = request_irq(ctx->irq, fimd_irq_handler, 0, "drm_fimd", ctx);
|
|
ret = request_irq(ctx->irq, fimd_irq_handler, 0, "drm_fimd", ctx);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
dev_err(dev, "irq request failed.\n");
|
|
dev_err(dev, "irq request failed.\n");
|
|
goto err_req_irq;
|
|
goto err_req_irq;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ for (win = 0; win < WINDOWS_NR; win++)
|
|
|
|
+ fimd_clear_win(ctx, win);
|
|
|
|
+
|
|
ctx->clkdiv = fimd_calc_clkdiv(ctx, timing);
|
|
ctx->clkdiv = fimd_calc_clkdiv(ctx, timing);
|
|
ctx->vidcon0 = pdata->vidcon0;
|
|
ctx->vidcon0 = pdata->vidcon0;
|
|
ctx->vidcon1 = pdata->vidcon1;
|
|
ctx->vidcon1 = pdata->vidcon1;
|