blob: a0e4a5810be7f0ca671c404b3e9bdfd32786fddb [file] [log] [blame]
/*
* Copyright 2016 Google Inc.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <stdint.h>
#include "base/cleanup.h"
#include "base/container_of.h"
#include "base/io.h"
#include "base/xalloc.h"
#include "drivers/framebuffer/exynos5.h"
enum {
Exynos5FimdVidcon0Envid = 2,
Exynos5FimdVidcon0EnvidF = 1
};
enum {
Exynos5FimdWinconEnwinF = 1
};
static int exynos5_framebuffer_prepare(FrameBufferOps *me, FrameBuffer *buf)
{
Exynos5Framebuffer *fb = container_of(me, Exynos5Framebuffer, ops);
if (!fb->initialized) {
cleanup_add(&fb->cleanup);
fb->initialized = 1;
}
return framebuffer_read_from_fwdb(buf);
}
int exynos5_framebuffer_disable(Exynos5Framebuffer *fb)
{
uint32_t *fimd_vidcon0 = (uint32_t *)(fb->base + 0);
uint32_t *fimd_shadowcon = (uint32_t *)(fb->base + 0x34);
// Disable video output and control signals.
uint32_t vidcon0 = read32(fimd_vidcon0);
vidcon0 &= ~(Exynos5FimdVidcon0Envid | Exynos5FimdVidcon0EnvidF);
write32(fimd_vidcon0, vidcon0);
// Disable all channels.
write32(fimd_shadowcon, 0);
fb->initialized = 0;
return 0;
}
static int exynos5_framebuffer_cleanup(DcEvent *me)
{
Exynos5Framebuffer *fb =
container_of(me, Exynos5Framebuffer, cleanup.event);
return exynos5_framebuffer_disable(fb);
}
Exynos5Framebuffer *new_exynos5_framebuffer(uintptr_t base)
{
Exynos5Framebuffer *fb = xzalloc(sizeof(*fb));
fb->ops.prepare = &exynos5_framebuffer_prepare;
fb->cleanup.types = CleanupOnHandoff | CleanupOnLegacy;
fb->cleanup.event.trigger = &exynos5_framebuffer_cleanup;
fb->base = base;
return fb;
}