2007-07-29 21:57:26 +04:00
|
|
|
/*
|
|
|
|
* OMAP LCD controller.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006-2007 Andrzej Zaborowski <balrog@zabor.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2009-01-05 01:05:52 +03:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
2009-07-17 00:47:01 +04:00
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
2007-07-29 21:57:26 +04:00
|
|
|
*/
|
2019-08-12 08:23:42 +03:00
|
|
|
|
2016-01-26 21:17:13 +03:00
|
|
|
#include "qemu/osdep.h"
|
2019-08-12 08:23:42 +03:00
|
|
|
#include "hw/irq.h"
|
2012-11-28 15:06:30 +04:00
|
|
|
#include "ui/console.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/arm/omap.h"
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "framebuffer.h"
|
2012-11-28 15:06:30 +04:00
|
|
|
#include "ui/pixel_ops.h"
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
struct omap_lcd_panel_s {
|
2011-12-08 18:00:54 +04:00
|
|
|
MemoryRegion *sysmem;
|
2011-11-28 16:53:36 +04:00
|
|
|
MemoryRegion iomem;
|
2015-07-13 13:00:29 +03:00
|
|
|
MemoryRegionSection fbsection;
|
2007-07-29 21:57:26 +04:00
|
|
|
qemu_irq irq;
|
2013-03-05 18:24:14 +04:00
|
|
|
QemuConsole *con;
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
int plm;
|
|
|
|
int tft;
|
|
|
|
int mono;
|
|
|
|
int enable;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int interrupts;
|
|
|
|
uint32_t timing[3];
|
|
|
|
uint32_t subpanel;
|
|
|
|
uint32_t ctrl;
|
|
|
|
|
|
|
|
struct omap_dma_lcd_channel_s *dma;
|
|
|
|
uint16_t palette[256];
|
|
|
|
int palette_done;
|
|
|
|
int frame_done;
|
|
|
|
int invalidate;
|
|
|
|
int sync_error;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void omap_lcd_interrupts(struct omap_lcd_panel_s *s)
|
|
|
|
{
|
|
|
|
if (s->frame_done && (s->interrupts & 1)) {
|
|
|
|
qemu_irq_raise(s->irq);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->palette_done && (s->interrupts & 2)) {
|
|
|
|
qemu_irq_raise(s->irq);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->sync_error) {
|
|
|
|
qemu_irq_raise(s->irq);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qemu_irq_lower(s->irq);
|
|
|
|
}
|
|
|
|
|
2021-02-15 13:32:14 +03:00
|
|
|
/*
|
|
|
|
* 2-bit colour
|
|
|
|
*/
|
|
|
|
static void draw_line2_32(void *opaque, uint8_t *d, const uint8_t *s,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
uint16_t *pal = opaque;
|
|
|
|
uint8_t v, r, g, b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = ldub_p((void *) s);
|
|
|
|
r = (pal[v & 3] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 3] & 0xf0;
|
|
|
|
b = (pal[v & 3] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
v >>= 2;
|
|
|
|
r = (pal[v & 3] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 3] & 0xf0;
|
|
|
|
b = (pal[v & 3] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
v >>= 2;
|
|
|
|
r = (pal[v & 3] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 3] & 0xf0;
|
|
|
|
b = (pal[v & 3] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
v >>= 2;
|
|
|
|
r = (pal[v & 3] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 3] & 0xf0;
|
|
|
|
b = (pal[v & 3] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
s++;
|
|
|
|
width -= 4;
|
|
|
|
} while (width > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 4-bit colour
|
|
|
|
*/
|
|
|
|
static void draw_line4_32(void *opaque, uint8_t *d, const uint8_t *s,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
uint16_t *pal = opaque;
|
|
|
|
uint8_t v, r, g, b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = ldub_p((void *) s);
|
|
|
|
r = (pal[v & 0xf] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 0xf] & 0xf0;
|
|
|
|
b = (pal[v & 0xf] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
v >>= 4;
|
|
|
|
r = (pal[v & 0xf] >> 4) & 0xf0;
|
|
|
|
g = pal[v & 0xf] & 0xf0;
|
|
|
|
b = (pal[v & 0xf] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
d += 4;
|
|
|
|
s++;
|
|
|
|
width -= 2;
|
|
|
|
} while (width > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 8-bit colour
|
|
|
|
*/
|
|
|
|
static void draw_line8_32(void *opaque, uint8_t *d, const uint8_t *s,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
uint16_t *pal = opaque;
|
|
|
|
uint8_t v, r, g, b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = ldub_p((void *) s);
|
|
|
|
r = (pal[v] >> 4) & 0xf0;
|
|
|
|
g = pal[v] & 0xf0;
|
|
|
|
b = (pal[v] << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
s++;
|
|
|
|
d += 4;
|
|
|
|
} while (-- width != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 12-bit colour
|
|
|
|
*/
|
|
|
|
static void draw_line12_32(void *opaque, uint8_t *d, const uint8_t *s,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
uint16_t v;
|
|
|
|
uint8_t r, g, b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = lduw_le_p((void *) s);
|
|
|
|
r = (v >> 4) & 0xf0;
|
|
|
|
g = v & 0xf0;
|
|
|
|
b = (v << 4) & 0xf0;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
s += 2;
|
|
|
|
d += 4;
|
|
|
|
} while (-- width != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 16-bit colour
|
|
|
|
*/
|
|
|
|
static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s,
|
|
|
|
int width, int deststep)
|
|
|
|
{
|
|
|
|
uint16_t v;
|
|
|
|
uint8_t r, g, b;
|
|
|
|
|
|
|
|
do {
|
|
|
|
v = lduw_le_p((void *) s);
|
|
|
|
r = (v >> 8) & 0xf8;
|
|
|
|
g = (v >> 3) & 0xfc;
|
|
|
|
b = (v << 3) & 0xf8;
|
|
|
|
((uint32_t *) d)[0] = rgb_to_pixel32(r, g, b);
|
|
|
|
s += 2;
|
|
|
|
d += 4;
|
|
|
|
} while (-- width != 0);
|
|
|
|
}
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2007-11-18 04:44:38 +03:00
|
|
|
static void omap_update_display(void *opaque)
|
2007-07-29 21:57:26 +04:00
|
|
|
{
|
2023-01-09 17:02:55 +03:00
|
|
|
struct omap_lcd_panel_s *omap_lcd = opaque;
|
2020-11-02 19:52:17 +03:00
|
|
|
DisplaySurface *surface;
|
2021-02-15 13:32:15 +03:00
|
|
|
drawfn draw_line;
|
2009-04-01 16:27:59 +04:00
|
|
|
int size, height, first, last;
|
|
|
|
int width, linesize, step, bpp, frame_offset;
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr frame_base;
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2020-11-02 19:52:17 +03:00
|
|
|
if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface = qemu_console_surface(omap_lcd->con);
|
|
|
|
if (!surface_bits_per_pixel(surface)) {
|
2007-07-29 21:57:26 +04:00
|
|
|
return;
|
2013-03-05 18:24:14 +04:00
|
|
|
}
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
frame_offset = 0;
|
|
|
|
if (omap_lcd->plm != 2) {
|
2020-02-20 12:51:35 +03:00
|
|
|
cpu_physical_memory_read(
|
|
|
|
omap_lcd->dma->phys_framebuffer[omap_lcd->dma->current_frame],
|
|
|
|
omap_lcd->palette, 0x200);
|
2007-07-29 21:57:26 +04:00
|
|
|
switch (omap_lcd->palette[0] >> 12 & 7) {
|
|
|
|
case 3 ... 7:
|
|
|
|
frame_offset += 0x200;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
frame_offset += 0x20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Colour depth */
|
|
|
|
switch ((omap_lcd->palette[0] >> 12) & 7) {
|
|
|
|
case 1:
|
2016-05-12 15:22:24 +03:00
|
|
|
draw_line = draw_line2_32;
|
2007-07-29 21:57:26 +04:00
|
|
|
bpp = 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2016-05-12 15:22:24 +03:00
|
|
|
draw_line = draw_line4_32;
|
2007-07-29 21:57:26 +04:00
|
|
|
bpp = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
2016-05-12 15:22:24 +03:00
|
|
|
draw_line = draw_line8_32;
|
2007-07-29 21:57:26 +04:00
|
|
|
bpp = 8;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4 ... 7:
|
|
|
|
if (!omap_lcd->tft)
|
2016-05-12 15:22:24 +03:00
|
|
|
draw_line = draw_line12_32;
|
2007-07-29 21:57:26 +04:00
|
|
|
else
|
2016-05-12 15:22:24 +03:00
|
|
|
draw_line = draw_line16_32;
|
2007-07-29 21:57:26 +04:00
|
|
|
bpp = 16;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Unsupported at the moment. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Resolution */
|
|
|
|
width = omap_lcd->width;
|
2013-03-05 18:24:14 +04:00
|
|
|
if (width != surface_width(surface) ||
|
|
|
|
omap_lcd->height != surface_height(surface)) {
|
|
|
|
qemu_console_resize(omap_lcd->con,
|
2008-07-01 20:24:38 +04:00
|
|
|
omap_lcd->width, omap_lcd->height);
|
2013-03-05 18:24:14 +04:00
|
|
|
surface = qemu_console_surface(omap_lcd->con);
|
2007-07-29 21:57:26 +04:00
|
|
|
omap_lcd->invalidate = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (omap_lcd->dma->current_frame == 0)
|
|
|
|
size = omap_lcd->dma->src_f1_bottom - omap_lcd->dma->src_f1_top;
|
|
|
|
else
|
|
|
|
size = omap_lcd->dma->src_f2_bottom - omap_lcd->dma->src_f2_top;
|
|
|
|
|
|
|
|
if (frame_offset + ((width * omap_lcd->height * bpp) >> 3) > size + 2) {
|
|
|
|
omap_lcd->sync_error = 1;
|
|
|
|
omap_lcd_interrupts(omap_lcd);
|
|
|
|
omap_lcd->enable = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Content */
|
|
|
|
frame_base = omap_lcd->dma->phys_framebuffer[
|
|
|
|
omap_lcd->dma->current_frame] + frame_offset;
|
|
|
|
omap_lcd->dma->condition |= 1 << omap_lcd->dma->current_frame;
|
|
|
|
if (omap_lcd->dma->interrupts & 1)
|
|
|
|
qemu_irq_raise(omap_lcd->dma->irq);
|
|
|
|
if (omap_lcd->dma->dual)
|
|
|
|
omap_lcd->dma->current_frame ^= 1;
|
|
|
|
|
2013-03-05 18:24:14 +04:00
|
|
|
if (!surface_bits_per_pixel(surface)) {
|
2007-07-29 21:57:26 +04:00
|
|
|
return;
|
2013-03-05 18:24:14 +04:00
|
|
|
}
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2009-04-01 16:27:59 +04:00
|
|
|
first = 0;
|
2007-07-29 21:57:26 +04:00
|
|
|
height = omap_lcd->height;
|
|
|
|
if (omap_lcd->subpanel & (1 << 31)) {
|
|
|
|
if (omap_lcd->subpanel & (1 << 29))
|
2009-04-01 16:27:59 +04:00
|
|
|
first = (omap_lcd->subpanel >> 16) & 0x3ff;
|
2007-07-29 21:57:26 +04:00
|
|
|
else
|
|
|
|
height = (omap_lcd->subpanel >> 16) & 0x3ff;
|
|
|
|
/* TODO: fill the rest of the panel with DPD */
|
|
|
|
}
|
2009-04-01 16:27:59 +04:00
|
|
|
|
2007-07-29 21:57:26 +04:00
|
|
|
step = width * bpp >> 3;
|
2013-03-05 18:24:14 +04:00
|
|
|
linesize = surface_stride(surface);
|
2015-07-13 13:00:29 +03:00
|
|
|
if (omap_lcd->invalidate) {
|
|
|
|
framebuffer_update_memory_section(&omap_lcd->fbsection,
|
|
|
|
omap_lcd->sysmem, frame_base,
|
|
|
|
height, step);
|
|
|
|
}
|
|
|
|
|
|
|
|
framebuffer_update_display(surface, &omap_lcd->fbsection,
|
|
|
|
width, height,
|
2009-04-01 16:27:59 +04:00
|
|
|
step, linesize, 0,
|
|
|
|
omap_lcd->invalidate,
|
|
|
|
draw_line, omap_lcd->palette,
|
|
|
|
&first, &last);
|
2015-07-13 13:00:29 +03:00
|
|
|
|
2009-04-01 16:27:59 +04:00
|
|
|
if (first >= 0) {
|
2013-03-05 18:24:14 +04:00
|
|
|
dpy_gfx_update(omap_lcd->con, 0, first, width, last - first + 1);
|
2007-07-29 21:57:26 +04:00
|
|
|
}
|
2009-04-01 16:27:59 +04:00
|
|
|
omap_lcd->invalidate = 0;
|
2007-07-29 21:57:26 +04:00
|
|
|
}
|
|
|
|
|
2007-11-18 04:44:38 +03:00
|
|
|
static void omap_invalidate_display(void *opaque) {
|
2007-07-29 21:57:26 +04:00
|
|
|
struct omap_lcd_panel_s *omap_lcd = opaque;
|
|
|
|
omap_lcd->invalidate = 1;
|
|
|
|
}
|
|
|
|
|
2007-11-18 04:44:38 +03:00
|
|
|
static void omap_lcd_update(struct omap_lcd_panel_s *s) {
|
2007-07-29 21:57:26 +04:00
|
|
|
if (!s->enable) {
|
|
|
|
s->dma->current_frame = -1;
|
|
|
|
s->sync_error = 0;
|
|
|
|
if (s->plm != 1)
|
|
|
|
s->frame_done = 1;
|
|
|
|
omap_lcd_interrupts(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s->dma->current_frame == -1) {
|
|
|
|
s->frame_done = 0;
|
|
|
|
s->palette_done = 0;
|
|
|
|
s->dma->current_frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!s->dma->mpu->port[s->dma->src].addr_valid(s->dma->mpu,
|
|
|
|
s->dma->src_f1_top) ||
|
|
|
|
!s->dma->mpu->port[
|
|
|
|
s->dma->src].addr_valid(s->dma->mpu,
|
|
|
|
s->dma->src_f1_bottom) ||
|
|
|
|
(s->dma->dual &&
|
|
|
|
(!s->dma->mpu->port[
|
|
|
|
s->dma->src].addr_valid(s->dma->mpu,
|
|
|
|
s->dma->src_f2_top) ||
|
|
|
|
!s->dma->mpu->port[
|
|
|
|
s->dma->src].addr_valid(s->dma->mpu,
|
|
|
|
s->dma->src_f2_bottom)))) {
|
|
|
|
s->dma->condition |= 1 << 2;
|
|
|
|
if (s->dma->interrupts & (1 << 1))
|
|
|
|
qemu_irq_raise(s->dma->irq);
|
|
|
|
s->enable = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-01 16:27:59 +04:00
|
|
|
s->dma->phys_framebuffer[0] = s->dma->src_f1_top;
|
|
|
|
s->dma->phys_framebuffer[1] = s->dma->src_f2_top;
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
if (s->plm != 2 && !s->palette_done) {
|
2009-04-01 16:27:59 +04:00
|
|
|
cpu_physical_memory_read(
|
2020-02-20 12:51:35 +03:00
|
|
|
s->dma->phys_framebuffer[s->dma->current_frame],
|
|
|
|
s->palette, 0x200);
|
2007-07-29 21:57:26 +04:00
|
|
|
s->palette_done = 1;
|
|
|
|
omap_lcd_interrupts(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-09 17:02:55 +03:00
|
|
|
static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, unsigned size)
|
2007-07-29 21:57:26 +04:00
|
|
|
{
|
2023-01-09 17:02:55 +03:00
|
|
|
struct omap_lcd_panel_s *s = opaque;
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2008-12-01 21:59:50 +03:00
|
|
|
switch (addr) {
|
2007-07-29 21:57:26 +04:00
|
|
|
case 0x00: /* LCD_CONTROL */
|
|
|
|
return (s->tft << 23) | (s->plm << 20) |
|
|
|
|
(s->tft << 7) | (s->interrupts << 3) |
|
|
|
|
(s->mono << 1) | s->enable | s->ctrl | 0xfe000c34;
|
|
|
|
|
|
|
|
case 0x04: /* LCD_TIMING0 */
|
|
|
|
return (s->timing[0] << 10) | (s->width - 1) | 0x0000000f;
|
|
|
|
|
|
|
|
case 0x08: /* LCD_TIMING1 */
|
|
|
|
return (s->timing[1] << 10) | (s->height - 1);
|
|
|
|
|
|
|
|
case 0x0c: /* LCD_TIMING2 */
|
|
|
|
return s->timing[2] | 0xfc000000;
|
|
|
|
|
|
|
|
case 0x10: /* LCD_STATUS */
|
|
|
|
return (s->palette_done << 6) | (s->sync_error << 2) | s->frame_done;
|
|
|
|
|
|
|
|
case 0x14: /* LCD_SUBPANEL */
|
|
|
|
return s->subpanel;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
OMAP_BAD_REG(addr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 14:30:10 +04:00
|
|
|
static void omap_lcdc_write(void *opaque, hwaddr addr,
|
2011-11-28 16:53:36 +04:00
|
|
|
uint64_t value, unsigned size)
|
2007-07-29 21:57:26 +04:00
|
|
|
{
|
2023-01-09 17:02:55 +03:00
|
|
|
struct omap_lcd_panel_s *s = opaque;
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2008-12-01 21:59:50 +03:00
|
|
|
switch (addr) {
|
2007-07-29 21:57:26 +04:00
|
|
|
case 0x00: /* LCD_CONTROL */
|
|
|
|
s->plm = (value >> 20) & 3;
|
|
|
|
s->tft = (value >> 7) & 1;
|
|
|
|
s->interrupts = (value >> 3) & 3;
|
|
|
|
s->mono = (value >> 1) & 1;
|
|
|
|
s->ctrl = value & 0x01cff300;
|
|
|
|
if (s->enable != (value & 1)) {
|
|
|
|
s->enable = value & 1;
|
|
|
|
omap_lcd_update(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x04: /* LCD_TIMING0 */
|
|
|
|
s->timing[0] = value >> 10;
|
|
|
|
s->width = (value & 0x3ff) + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x08: /* LCD_TIMING1 */
|
|
|
|
s->timing[1] = value >> 10;
|
|
|
|
s->height = (value & 0x3ff) + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0c: /* LCD_TIMING2 */
|
|
|
|
s->timing[2] = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x10: /* LCD_STATUS */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x14: /* LCD_SUBPANEL */
|
|
|
|
s->subpanel = value & 0xa1ffffff;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
OMAP_BAD_REG(addr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-28 16:53:36 +04:00
|
|
|
static const MemoryRegionOps omap_lcdc_ops = {
|
|
|
|
.read = omap_lcdc_read,
|
|
|
|
.write = omap_lcdc_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
2007-07-29 21:57:26 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void omap_lcdc_reset(struct omap_lcd_panel_s *s)
|
|
|
|
{
|
|
|
|
s->dma->current_frame = -1;
|
|
|
|
s->plm = 0;
|
|
|
|
s->tft = 0;
|
|
|
|
s->mono = 0;
|
|
|
|
s->enable = 0;
|
|
|
|
s->width = 0;
|
|
|
|
s->height = 0;
|
|
|
|
s->interrupts = 0;
|
|
|
|
s->timing[0] = 0;
|
|
|
|
s->timing[1] = 0;
|
|
|
|
s->timing[2] = 0;
|
|
|
|
s->subpanel = 0;
|
|
|
|
s->palette_done = 0;
|
|
|
|
s->frame_done = 0;
|
|
|
|
s->sync_error = 0;
|
|
|
|
s->invalidate = 1;
|
|
|
|
s->subpanel = 0;
|
|
|
|
s->ctrl = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-13 17:04:18 +04:00
|
|
|
static const GraphicHwOps omap_ops = {
|
|
|
|
.invalidate = omap_invalidate_display,
|
|
|
|
.gfx_update = omap_update_display,
|
|
|
|
};
|
|
|
|
|
2011-11-28 16:53:36 +04:00
|
|
|
struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem,
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr base,
|
2011-11-28 16:53:36 +04:00
|
|
|
qemu_irq irq,
|
|
|
|
struct omap_dma_lcd_channel_s *dma,
|
|
|
|
omap_clk clk)
|
2007-07-29 21:57:26 +04:00
|
|
|
{
|
arm: Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer,
for two reasons. One, it catches multiplication overflowing size_t.
Two, it returns T * rather than void *, which lets the compiler catch
more type errors.
This commit only touches allocations with size arguments of the form
sizeof(T).
Coccinelle semantic patch:
@@
type T;
@@
-g_malloc(sizeof(T))
+g_new(T, 1)
@@
type T;
@@
-g_try_malloc(sizeof(T))
+g_try_new(T, 1)
@@
type T;
@@
-g_malloc0(sizeof(T))
+g_new0(T, 1)
@@
type T;
@@
-g_try_malloc0(sizeof(T))
+g_try_new0(T, 1)
@@
type T;
expression n;
@@
-g_malloc(sizeof(T) * (n))
+g_new(T, n)
@@
type T;
expression n;
@@
-g_try_malloc(sizeof(T) * (n))
+g_try_new(T, n)
@@
type T;
expression n;
@@
-g_malloc0(sizeof(T) * (n))
+g_new0(T, n)
@@
type T;
expression n;
@@
-g_try_malloc0(sizeof(T) * (n))
+g_try_new0(T, n)
@@
type T;
expression p, n;
@@
-g_realloc(p, sizeof(T) * (n))
+g_renew(T, p, n)
@@
type T;
expression p, n;
@@
-g_try_realloc(p, sizeof(T) * (n))
+g_try_renew(T, p, n)
@@
type T;
expression n;
@@
-(T *)g_new(T, n)
+g_new(T, n)
@@
type T;
expression n;
@@
-(T *)g_new0(T, n)
+g_new0(T, n)
@@
type T;
expression p, n;
@@
-(T *)g_renew(T, p, n)
+g_renew(T, p, n)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1440524394-15640-1-git-send-email-armbru@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-09-07 12:39:27 +03:00
|
|
|
struct omap_lcd_panel_s *s = g_new0(struct omap_lcd_panel_s, 1);
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
s->irq = irq;
|
|
|
|
s->dma = dma;
|
2011-12-08 18:00:54 +04:00
|
|
|
s->sysmem = sysmem;
|
2007-07-29 21:57:26 +04:00
|
|
|
omap_lcdc_reset(s);
|
|
|
|
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init_io(&s->iomem, NULL, &omap_lcdc_ops, s, "omap.lcdc", 0x100);
|
2011-11-28 16:53:36 +04:00
|
|
|
memory_region_add_subregion(sysmem, base, &s->iomem);
|
2007-07-29 21:57:26 +04:00
|
|
|
|
2014-01-24 18:35:21 +04:00
|
|
|
s->con = graphic_console_init(NULL, 0, &omap_ops, s);
|
2007-07-29 21:57:26 +04:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|