#include "hw/i386/pc.h"
#ifdef TARGET_ARM
-#include "console.h"
+#include "ui/console.h"
#endif
#include "hw/pci/pci.h"
#include "maru_device_ids.h"
uint32_t brightness_level = BRIGHTNESS_MAX;
uint32_t brightness_off;
+pixman_color_t level_color;
+pixman_image_t *brightness_image;
/* level : 1 ~ 100, interval : 1 or 2 */
/* skip 100 level, set to default alpha */
-uint8_t brightness_tbl[] = {100, /* level 0 : for dimming */
-/* level 01 ~ 10 */ 106, 108, 109, 111, 112, 114, 115, 117, 118, 120,
-/* level 11 ~ 20 */ 121, 123, 124, 126, 127, 129, 130, 132, 133, 135,
-/* level 21 ~ 30 */ 136, 138, 139, 141, 142, 144, 145, 147, 148, 150,
-/* level 31 ~ 40 */ 151, 153, 154, 156, 157, 159, 160, 162, 163, 165,
-/* level 41 ~ 50 */ 166, 168, 169, 171, 172, 174, 175, 177, 178, 180,
-/* level 51 ~ 60 */ 181, 183, 184, 186, 187, 189, 190, 192, 193, 195,
-/* level 61 ~ 70 */ 196, 198, 199, 201, 202, 204, 205, 207, 208, 210,
-/* level 71 ~ 80 */ 211, 213, 214, 216, 217, 219, 220, 222, 223, 225,
-/* level 81 ~ 90 */ 226, 228, 229, 231, 232, 234, 235, 237, 238, 240,
-/* level 91 ~ 99 */ 241, 243, 244, 246, 247, 249, 250, 252, 253};
+uint8_t brightness_tbl[] = {155, /* level 0 : for dimming */
+/* level 01 ~ 10 */ 149, 147, 146, 144, 143, 141, 140, 138, 137, 135,
+/* level 11 ~ 20 */ 134, 132, 131, 129, 128, 126, 125, 123, 122, 120,
+/* level 21 ~ 30 */ 119, 117, 116, 114, 113, 111, 110, 108, 107, 105,
+/* level 31 ~ 40 */ 104, 102, 101, 99, 98, 96, 95, 93, 92, 90,
+/* level 41 ~ 50 */ 89, 87, 86, 84, 83, 81, 80, 78, 77, 75,
+/* level 51 ~ 60 */ 74, 72, 71, 69, 68, 66, 65, 63, 62, 60,
+/* level 61 ~ 70 */ 59, 57, 56, 54, 53, 51, 50, 48, 47, 45,
+/* level 71 ~ 80 */ 44, 42, 41, 39, 38, 36, 35, 33, 32, 30,
+/* level 81 ~ 90 */ 29, 27, 26, 24, 23, 21, 20, 18, 17, 15,
+/* level 91 ~ 99 */ 14, 12, 11, 9, 8, 6, 5, 3, 2};
QEMUBH *bh;
ERR("brightness_reg_write: Invalide brightness level.\n");
} else {
brightness_level = val;
+ if (brightness_image) {
+ pixman_image_unref(brightness_image);
+ }
+ level_color.alpha = brightness_tbl[brightness_level] << 8;
+ brightness_image = pixman_image_create_solid_fill(&level_color);
INFO("brightness_level : %lld\n", val);
#ifdef TARGET_ARM
- vga_hw_invalidate();
+ graphic_hw_invalidate(NULL);
#endif
}
return;
brightness_off = val;
#ifdef TARGET_ARM
- vga_hw_invalidate();
+ graphic_hw_invalidate(NULL);
#endif
/* notify to skin process */
if (bh) {
qemu_bh_delete(bh);
}
+ if (brightness_image) {
+ pixman_image_unref(brightness_image);
+ }
}
static void maru_brightness_bh(void *opaque)
bh = qemu_bh_new(maru_brightness_bh, s);
+ level_color.alpha = 0x0000;
+ level_color.red = 0x0000;
+ level_color.green = 0x0000;
+ level_color.blue = 0x0000;
+ brightness_image = pixman_image_create_solid_fill(&level_color);
+
return 0;
}
#define MARU_BRIGHTNESS_H_
#include "qemu-common.h"
+#include "ui/qemu-pixman.h"
#define BRIGHTNESS_MIN (0)
#define BRIGHTNESS_MAX (100)
extern uint32_t brightness_level;
extern uint32_t brightness_off;
extern uint8_t brightness_tbl[];
+extern pixman_image_t *brightness_image;
DeviceState *pci_maru_brightness_init(PCIBus *bus);
uint16_t overlay1_width;
uint16_t overlay1_height;
+pixman_image_t *overlay0_image;
+pixman_image_t *overlay1_image;
+
typedef struct OverlayState {
PCIDevice dev;
/* clear the last overlay area. */
memset(overlay_ptr, 0x00, (OVERLAY_MEM_SIZE / 2));
overlay0_left = overlay0_top = overlay0_width = overlay0_height = 0;
+ if (overlay0_image) {
+ pixman_image_unref(overlay0_image);
+ overlay0_image = NULL;
+ }
TRACE("clear the last overlay0 area\n");
+ } else {
+ overlay0_image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+ overlay0_width, overlay0_height,
+ (uint32_t *)overlay_ptr,
+ overlay0_width * 4);
+ TRACE("create the overlay0 pixman image\n");
}
break;
case OVERLAY_POSITION:
memset(overlay_ptr + OVERLAY1_REG_OFFSET,
0x00, (OVERLAY_MEM_SIZE / 2));
overlay1_left = overlay1_top = overlay1_width = overlay1_height = 0;
+ if (overlay1_image) {
+ pixman_image_unref(overlay1_image);
+ overlay1_image = NULL;
+ }
TRACE("clear the last overlay1 area\n");
+ } else {
+ overlay1_image = pixman_image_create_bits(PIXMAN_a8r8g8b8,
+ overlay1_width, overlay1_height,
+ (uint32_t *)(overlay_ptr + OVERLAY1_REG_OFFSET),
+ overlay1_width * 4);
+ TRACE("create the overlay1 pixman image\n");
}
break;
case OVERLAY1_REG_OFFSET + OVERLAY_POSITION:
#define MARU_OVERLAY_H_
#include "qemu-common.h"
+#include "ui/qemu-pixman.h"
extern uint8_t *overlay_ptr;
extern uint8_t overlay0_power;
extern uint16_t overlay1_width;
extern uint16_t overlay1_height;
+extern pixman_image_t *overlay0_image;
+extern pixman_image_t *overlay1_image;
+
DeviceState *pci_maru_overlay_init(PCIBus *bus);
#endif /* MARU_OVERLAY_H_ */
DisplayChangeListener *dcl;
dcl = g_malloc0(sizeof(DisplayChangeListener));
-// FIXME: merge
-#if 0
-#ifndef CONFIG_USE_SHM
- /* sdl library */
- dcl->dpy_update = qemu_ds_sdl_update;
- dcl->dpy_resize = qemu_ds_sdl_resize;
- dcl->dpy_refresh = qemu_ds_sdl_refresh;
-#else
- /* shared memroy */
- dcl->dpy_update = qemu_ds_shm_update;
- dcl->dpy_resize = qemu_ds_shm_resize;
- dcl->dpy_refresh = qemu_ds_shm_refresh;
-#endif
-#endif
-
-// register_displaychangelistener(ds, dcl);
+ dcl->ops = &maru_dcl_ops;
register_displaychangelistener(dcl);
maru_screenshot = g_malloc0(sizeof(MaruScreenshot));
#include <pthread.h>
#include <math.h>
-#include <pixman.h>
#include "ui/console.h"
#include "maru_sdl.h"
#include "maru_display.h"
#include "emul_state.h"
-/*
-#include "SDL_gfx/SDL_rotozoom.h"
-#include "maru_sdl_rotozoom.h"
-*/
#include "maru_finger.h"
#include "hw/maru_pm.h"
#include "hw/maru_brightness.h"
+#include "hw/maru_overlay.h"
#include "debug_ch.h"
/* #include "SDL_opengl.h" */
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
-
-DisplaySurface* qemu_display_surface = NULL;
+DisplaySurface *qemu_display_surface = NULL;
static SDL_Surface *surface_screen;
static SDL_Surface *surface_qemu;
#define SDL_BPP 32
/* Image processing functions using the pixman library */
+static void maru_do_pixman_sdl(pixman_image_t *dst_image)
+{
+ /* overlay0 */
+ if (overlay0_power) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ overlay0_image, NULL, dst_image,
+ 0, 0, 0, 0, overlay0_left, overlay0_top,
+ overlay0_width, overlay0_height);
+ }
+ /* overlay1 */
+ if (overlay1_power) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ overlay1_image, NULL, dst_image,
+ 0, 0, 0, 0, overlay1_left, overlay1_top,
+ overlay1_width, overlay1_height);
+ }
+ /* apply the brightness level */
+ if (brightness_level < BRIGHTNESS_MAX) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ brightness_image, NULL, dst_image,
+ 0, 0, 0, 0, 0, 0,
+ pixman_image_get_width(dst_image),
+ pixman_image_get_height(dst_image));
+ }
+}
+
static SDL_Surface *maru_do_pixman_scale(SDL_Surface *rz_src,
SDL_Surface *rz_dst,
int angle)
break;
case 90:
pixman_f_transform_rotate(&matrix_f, NULL, 0.0, 1.0);
- pixman_f_transform_translate(&matrix_f, NULL, (double)rz_dst->h, 0.0);
+ pixman_f_transform_translate(&matrix_f, NULL,
+ (double)rz_dst->h, 0.0);
break;
case 180:
pixman_f_transform_rotate(&matrix_f, NULL, -1.0, 0.0);
break;
case 270:
pixman_f_transform_rotate(&matrix_f, NULL, 0.0, -1.0);
- pixman_f_transform_translate(&matrix_f, NULL, 0.0, (double)rz_dst->w);
+ pixman_f_transform_translate(&matrix_f, NULL,
+ 0.0, (double)rz_dst->w);
break;
default:
fprintf(stdout, "not supported angle factor (angle=%d)\n", angle);
return rz_dst;
}
-void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h)
+static void qemu_ds_sdl_update(DisplayChangeListener *dcl,
+ int x, int y, int w, int h)
{
/* call sdl update */
#ifdef SDL_THREAD
maru_screenshot->isReady = 1;
if (maru_screenshot->request_screenshot == 1) {
-// FIXME: merge
-#if 0
- memcpy(maru_screenshot->pixel_data, ds->surface->data,
- ds->surface->linesize * ds->surface->height);
+ memcpy(maru_screenshot->pixel_data,
+ surface_data(qemu_display_surface),
+ surface_stride(qemu_display_surface) *
+ surface_height(qemu_display_surface));
maru_screenshot->request_screenshot = 0;
-#endif
pthread_cond_signal(&cond_screenshot);
}
pthread_mutex_unlock(&mutex_screenshot);
}
-void qemu_ds_sdl_resize(DisplayState *ds)
+static void qemu_ds_sdl_switch(DisplayChangeListener *dcl,
+ struct DisplaySurface *new_surface)
{
int w, h;
- w = ds_get_width(ds);
- h = ds_get_height(ds);
+ if (!new_surface) {
+ ERR("qemu_ds_sdl_switch: new_surface is NULL\n");
+ return;
+ }
+
+ qemu_display_surface = new_surface;
+ w = surface_width(new_surface);
+ h = surface_height(new_surface);
- INFO("qemu_ds_sdl_resize = (%d, %d)\n", w, h);
+ INFO("qemu_ds_sdl_switch = (%d, %d)\n", w, h);
#ifdef SDL_THREAD
pthread_mutex_lock(&sdl_mutex);
/* create surface_qemu */
if (w == get_emul_lcd_width() && h == get_emul_lcd_height()) {
-// FIXME: merge
-#if 0
- surface_qemu = SDL_CreateRGBSurfaceFrom(ds_get_data(ds), w, h,
- ds_get_bits_per_pixel(ds),
- ds_get_linesize(ds),
- ds->surface->pf.rmask,
- ds->surface->pf.gmask,
- ds->surface->pf.bmask,
- ds->surface->pf.amask);
-#endif
+ INFO("create SDL screen = (%d, %d)\n",
+ get_emul_lcd_width(), get_emul_lcd_height());
+ surface_qemu = SDL_CreateRGBSurfaceFrom(
+ surface_data(qemu_display_surface),
+ w, h,
+ surface_bits_per_pixel(qemu_display_surface),
+ surface_stride(qemu_display_surface),
+ qemu_display_surface->pf.rmask,
+ qemu_display_surface->pf.gmask,
+ qemu_display_surface->pf.bmask,
+ qemu_display_surface->pf.amask);
} else {
- INFO("create blank screen = (%d, %d)\n", get_emul_lcd_width(), get_emul_lcd_height());
+ INFO("create blank screen = (%d, %d)\n",
+ get_emul_lcd_width(), get_emul_lcd_height());
surface_qemu = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
- ds_get_bits_per_pixel(ds), 0, 0, 0, 0);
+ surface_bits_per_pixel(qemu_display_surface), 0, 0, 0, 0);
}
#ifdef SDL_THREAD
return ret;
}
-void qemu_ds_sdl_refresh(DisplayState *ds)
+static void qemu_ds_sdl_refresh(DisplayChangeListener *dcl)
{
SDL_Event ev1, *ev = &ev1;
static uint32_t sdl_skip_count = 0;
- // surface may be NULL in init func.
-// FIXME: merge
-// qemu_display_surface = ds->surface;
-
while (maru_sdl_poll_event(ev)) {
switch (ev->type) {
case SDL_VIDEORESIZE:
{
pthread_mutex_lock(&sdl_mutex);
- maruskin_sdl_init(0, get_emul_lcd_width(), get_emul_lcd_height(), true);
+ maruskin_sdl_init(0,
+ get_emul_lcd_width(), get_emul_lcd_height(),
+ true);
pthread_mutex_unlock(&sdl_mutex);
sdl_skip_update = 0;
/* Usually, continuously updated.
When the LCD is turned off,
ten more updates the screen for a black screen. */
- vga_hw_update();
if (brightness_off) {
+ dpy_gfx_update(dcl->con, 0, 0, 0, 0);
if (++sdl_skip_count > 10) {
sdl_skip_update = 1;
} else {
sdl_skip_update = 0;
}
} else {
+ graphic_hw_update(dcl->con);
sdl_skip_count = 0;
sdl_skip_update = 0;
}
#endif
}
+DisplayChangeListenerOps maru_dcl_ops = {
+ .dpy_name = "maru_sdl",
+ .dpy_gfx_update = qemu_ds_sdl_update,
+ .dpy_gfx_switch = qemu_ds_sdl_switch,
+ .dpy_refresh = qemu_ds_sdl_refresh,
+};
+
//extern int capability_check_gl;
static void _sdl_init(void)
{
int w, h, rwidth, rheight, temp;
- INFO("Set up a video mode with the specified width, height and bits-per-pixel\n");
+ INFO("Set up a video mode with the specified width, "
+ "height and bits-per-pixel\n");
//get current setting information and calculate screen size
rwidth = get_emul_lcd_width();
ERR("%s\n", SDL_GetError());
#endif
- surface_screen = SDL_SetVideoMode(w, h, get_emul_sdl_bpp(), SDL_FLAGS);
+ surface_screen = SDL_SetVideoMode(w, h,
+ get_emul_sdl_bpp(),
+ SDL_FLAGS);
if (surface_screen == NULL) {
- ERR("Could not open SDL display (%dx%dx%d): %s\n", w, h, get_emul_sdl_bpp(), SDL_GetError());
+ ERR("Could not open SDL display (%dx%dx%d): %s\n",
+ w, h, get_emul_sdl_bpp(), SDL_GetError());
return;
}
#if 0
else
{ //sdl surface
#endif
- if (current_scale_factor != 1.0)
- {
+ maru_do_pixman_sdl(qemu_display_surface->image);
+ if (current_scale_factor != 1.0) {
rotated_screen = maru_do_pixman_rotate(
surface_qemu, rotated_screen,
(int)current_screen_degree);
(int)current_screen_degree);
SDL_BlitSurface(scaled_screen, NULL, surface_screen, NULL);
}
- else /* current_scale_factor == 1.0 */
- {
+ else {/* current_scale_factor == 1.0 */
if (current_screen_degree != 0.0) {
rotated_screen = maru_do_pixman_rotate(
surface_qemu, rotated_screen,
rect.y = finger->origin_y - finger_point_size_half;
rect.w = rect.h = mts->finger_point_size;
- SDL_BlitSurface((SDL_Surface *)mts->finger_point_surface, NULL, surface_screen, &rect);
+ SDL_BlitSurface(
+ (SDL_Surface *)mts->finger_point_surface,
+ NULL, surface_screen, &rect);
}
}
} /* end of draw multi-touch */
#ifdef SDL_THREAD
-static void* run_qemu_update(void* arg)
+static void *run_qemu_update(void* arg)
{
- while(1) {
+ while(1) {
pthread_mutex_lock(&sdl_mutex);
- pthread_cond_wait(&sdl_cond, &sdl_mutex);
+ pthread_cond_wait(&sdl_cond, &sdl_mutex);
qemu_update();
pthread_mutex_unlock(&sdl_mutex);
- }
+ }
return NULL;
}
SDL_PushEvent(&ev);
}
-DisplaySurface* maruskin_sdl_get_display(void) {
+DisplaySurface *maruskin_sdl_get_display(void) {
return qemu_display_surface;
}
#ifndef MARU_SDL_H_
#define MARU_SDL_H_
-#include "ui/console.h"
#include <SDL.h>
#include <SDL_syswm.h>
+#include "ui/console.h"
#include "qemu-common.h"
-
-void qemu_ds_sdl_update(DisplayState *ds, int x, int y, int w, int h);
-void qemu_ds_sdl_resize(DisplayState *ds);
-void qemu_ds_sdl_refresh(DisplayState *ds);
+extern DisplayChangeListenerOps maru_dcl_ops;
void maruskin_sdl_init(uint64 swt_handle, int lcd_size_width, int lcd_size_height, bool is_resize);
void maruskin_sdl_resize(void);
*/
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
#include "maru_shm.h"
#include "emul_state.h"
#include "hw/maru_brightness.h"
+#include "hw/maru_overlay.h"
#include "skin/maruskin_server.h"
#include "debug_ch.h"
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
#include "maru_err_table.h"
MULTI_DEBUG_CHANNEL(tizen, maru_shm);
-
+static DisplaySurface *shm_surface;
static void *shared_memory = (void*) 0;
static int skin_shmid;
static unsigned int drop_frame;
#endif
-void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h)
+static void maru_do_pixman_shm(void)
+{
+ /* overlay0 */
+ if (overlay0_power) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ overlay0_image, NULL, shm_surface->image,
+ 0, 0, 0, 0, overlay0_left, overlay0_top,
+ overlay0_width, overlay0_height);
+ }
+ /* overlay1 */
+ if (overlay1_power) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ overlay1_image, NULL, shm_surface->image,
+ 0, 0, 0, 0, overlay1_left, overlay1_top,
+ overlay1_width, overlay1_height);
+ }
+ /* apply the brightness level */
+ if (brightness_level < BRIGHTNESS_MAX) {
+ pixman_image_composite(PIXMAN_OP_OVER,
+ brightness_image, NULL, shm_surface->image,
+ 0, 0, 0, 0, 0, 0,
+ surface_width(shm_surface),
+ surface_height(shm_surface));
+ }
+}
+
+static void qemu_ds_shm_update(DisplayChangeListener *dcl,
+ int x, int y, int w, int h)
{
if (shared_memory != NULL) {
pthread_mutex_lock(&mutex_draw_display);
if (draw_display_state == 0) {
draw_display_state = 1;
pthread_mutex_unlock(&mutex_draw_display);
-
- memcpy(shared_memory, ds->surface->data,
- ds->surface->linesize * ds->surface->height);
-
+ if (brightness_off) {
+ memset(shared_memory,
+ 0x00,
+ surface_stride(shm_surface) *
+ surface_height(shm_surface));
+ } else {
+ maru_do_pixman_shm();
+ memcpy(shared_memory,
+ surface_data(shm_surface),
+ surface_stride(shm_surface) *
+ surface_height(shm_surface));
+ }
#ifdef INFO_FRAME_DROP_RATE
draw_frame++;
#endif
-
notify_draw_frame();
} else {
#ifdef INFO_FRAME_DROP_RATE
drop_frame++;
#endif
-
pthread_mutex_unlock(&mutex_draw_display);
}
-
#ifdef INFO_FRAME_DROP_RATE
- INFO("! frame drop rate = (%d/%d)\n", drop_frame, draw_frame + drop_frame);
+ INFO("! frame drop rate = (%d/%d)\n",
+ drop_frame, draw_frame + drop_frame);
#endif
}
}
-void qemu_ds_shm_resize(DisplayState *ds)
+static void qemu_ds_shm_switch(DisplayChangeListener *dcl,
+ struct DisplaySurface *new_surface)
{
- TRACE("qemu_ds_shm_resize\n");
+ TRACE("qemu_ds_shm_switch\n");
+
+ if (new_surface) {
+ shm_surface = new_surface;
+ }
shm_skip_update = 0;
shm_skip_count = 0;
}
-void qemu_ds_shm_refresh(DisplayState *ds)
+static void qemu_ds_shm_refresh(DisplayChangeListener *dcl)
{
/* If the display is turned off,
the screen does not update until the it is turned on */
return;
}
- vga_hw_update();
-
/* Usually, continuously updated.
But when the display is turned off,
ten more updates the surface for a black screen. */
if (brightness_off) {
+ dpy_gfx_update(dcl->con, 0, 0, 0, 0);
if (++shm_skip_count > 10) {
shm_skip_update = 1;
} else {
shm_skip_update = 0;
}
} else {
+ graphic_hw_update(dcl->con);
shm_skip_count = 0;
shm_skip_update = 0;
}
}
+DisplayChangeListenerOps maru_dcl_ops = {
+ .dpy_name = "maru_shm",
+ .dpy_refresh = qemu_ds_shm_refresh,
+ .dpy_gfx_update = qemu_ds_shm_update,
+ .dpy_gfx_switch = qemu_ds_shm_switch,
+};
+
void maruskin_shm_init(uint64 swt_handle,
int lcd_size_width, int lcd_size_height, bool is_resize)
{
#ifndef MARU_SHM_H_
#define MARU_SHM_H_
-#include "console.h"
+#include "ui/console.h"
-
-void qemu_ds_shm_update(DisplayState *ds, int x, int y, int w, int h);
-void qemu_ds_shm_resize(DisplayState *ds);
-void qemu_ds_shm_refresh(DisplayState *ds);
+extern DisplayChangeListenerOps maru_dcl_ops;
void maruskin_shm_init(uint64 swt_handle,
int lcd_size_width, int lcd_size_height, bool is_resize);