enum {
HARD_KEY_HOME = 101,
HARD_KEY_POWER = 103,
+ HARD_KEY_VOL_UP = 115,
+ HARD_KEY_VOL_DOWN = 114,
};
enum {
#include "maru_brightness.h"
#include "debug_ch.h"
-MULTI_DEBUG_CHANNEL(qemu, maru_brightness);
+MULTI_DEBUG_CHANNEL( qemu, maru_brightness );
#define QEMU_DEV_NAME "MARU_BRIGHTNESS"
#define BRIGHTNESS_MEM_SIZE (4 * 1024) /* 4KB */
#define BRIGHTNESS_REG_SIZE 256
-#define BRIGHTNESS_MIN (0)
-#define BRIGHTNESS_MAX (24)
-
typedef struct BrightnessState {
PCIDevice dev;
ram_addr_t vram_offset;
} BrightnessState;
enum {
- BRIGHTNESS_LEVEL = 0x00,
- BRIGHTNESS_OFF = 0x04,
+ BRIGHTNESS_LEVEL = 0x00,
+ BRIGHTNESS_OFF = 0x04,
};
uint32_t brightness_level = 24;
uint8_t brightness_tbl[] = {20, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120,
130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240};
-static uint64_t brightness_reg_read(void *opaque, target_phys_addr_t addr, unsigned size)
-{
- switch (addr & 0xFF) {
+static uint64_t brightness_reg_read( void *opaque, target_phys_addr_t addr, unsigned size ) {
+ switch ( addr & 0xFF ) {
case BRIGHTNESS_LEVEL:
- INFO("brightness_reg_read: brightness_level = %d\n", brightness_level);
+ INFO("brightness_reg_read: brightness_level = %d\n", brightness_level);
return brightness_level;
case BRIGHTNESS_OFF:
INFO("brightness_reg_read: brightness_off = %d\n", brightness_off);
return 0;
}
-static void brightness_reg_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size)
-{
+static void brightness_reg_write( void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size ) {
#if BRIGHTNESS_MIN > 0
- if (val < BRIGHTNESS_MIN || val > BRIGHTNESS_MAX) {
+ if (val < BRIGHTNESS_MIN || val > BRIGHTNESS_MAX) {
#else
- if (val > BRIGHTNESS_MAX) {
+ if ( val > BRIGHTNESS_MAX ) {
#endif
- ERR("brightness_reg_write: Invalide brightness level.\n");
- }
-
- switch (addr & 0xFF) {
- case BRIGHTNESS_LEVEL:
- brightness_level = val;
- INFO("brightness_level : %lld\n", val);
- return;
- case BRIGHTNESS_OFF:
- INFO("brightness_off : %lld\n", val);
- brightness_off = val;
- return;
- default:
- ERR("wrong brightness register write - addr : %d\n", (int)addr);
- break;
- }
+ ERR("brightness_reg_write: Invalide brightness level.\n");
+ }
+
+ switch ( addr & 0xFF ) {
+ case BRIGHTNESS_LEVEL:
+ brightness_level = val;
+ INFO("brightness_level : %lld\n", val);
+ return;
+ case BRIGHTNESS_OFF:
+ INFO("brightness_off : %lld\n", val);
+ brightness_off = val;
+ return;
+ default:
+ ERR("wrong brightness register write - addr : %d\n", (int)addr);
+ break;
+ }
}
static const MemoryRegionOps brightness_mmio_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
-static int brightness_initfn(PCIDevice *dev)
-{
- BrightnessState *s = DO_UPCAST(BrightnessState, dev, dev);
+static int brightness_initfn( PCIDevice *dev ) {
+ BrightnessState *s = DO_UPCAST(BrightnessState, dev, dev);
uint8_t *pci_conf = s->dev.config;
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_TIZEN);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIRTUAL_BRIGHTNESS);
- pci_config_set_class(pci_conf, PCI_CLASS_DISPLAY_OTHER);
+ pci_config_set_vendor_id( pci_conf, PCI_VENDOR_ID_TIZEN );
+ pci_config_set_device_id( pci_conf, PCI_DEVICE_ID_VIRTUAL_BRIGHTNESS );
+ pci_config_set_class( pci_conf, PCI_CLASS_DISPLAY_OTHER );
- memory_region_init_io (&s->mmio_addr, &brightness_mmio_ops, s, "maru_brightness_mmio", BRIGHTNESS_REG_SIZE);
- pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_addr);
+ memory_region_init_io( &s->mmio_addr, &brightness_mmio_ops, s, "maru_brightness_mmio", BRIGHTNESS_REG_SIZE );
+ pci_register_bar( &s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_addr );
return 0;
}
/* external interface */
-int pci_get_brightness(void)
-{
- return brightness_level;
+int pci_get_brightness( void ) {
+ return brightness_level;
}
-int pci_maru_brightness_init(PCIBus *bus)
-{
- pci_create_simple(bus, -1, QEMU_DEV_NAME);
+int pci_maru_brightness_init( PCIBus *bus ) {
+ pci_create_simple( bus, -1, QEMU_DEV_NAME );
return 0;
}
static PCIDeviceInfo brightness_info = {
- .qdev.name = QEMU_DEV_NAME,
- .qdev.size = sizeof(BrightnessState),
- .no_hotplug = 1,
- .init = brightness_initfn,
+ .qdev.name = QEMU_DEV_NAME,
+ .qdev.size = sizeof(BrightnessState),
+ .no_hotplug = 1,
+ .init = brightness_initfn,
};
-static void brightness_register(void)
-{
- pci_qdev_register(&brightness_info);
+static void brightness_register( void ) {
+ pci_qdev_register( &brightness_info );
}
device_init(brightness_register);
*
*/
-
#ifndef MARU_BRIGHTNESS_H_
#define MARU_BRIGHTNESS_H_
#include "qemu-common.h"
+#define BRIGHTNESS_MIN (0)
+#define BRIGHTNESS_MAX (24)
+
extern uint32_t brightness_level;
extern uint32_t brightness_off;
extern uint8_t brightness_tbl[];
-int pci_get_brightness(void);
-int pci_maru_brightness_init(PCIBus *bus);
+int pci_get_brightness( void );
+int pci_maru_brightness_init( PCIBus *bus );
#endif /* MARU_BRIGHTNESS_H_ */
{
int sci_level, pmsts;
+ acpi_state = s;
+
pmsts = acpi_pm1_evt_get_sts(&s->pm1a, s->tmr.overflow_time);
sci_level = (((pmsts & s->pm1a.en) &
(ACPI_BITMASK_RT_CLOCK_ENABLE |
if ( acpi_state ) {
if ( acpi_state->pm1_cnt.cmos_s3 ) {
- acpi_state->pm1_cnt.cnt |= ( ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS );
- INFO( "raise irq for ACPI wake." );
+ acpi_state->pm1a.sts |= ( ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS );
+ INFO( "raise irq for ACPI wake.\n" );
qemu_irq_raise( acpi_state->pm1_cnt.cmos_s3 );
}else {
- ERR( "acpi cmos_s3 is NULL." );
+ ERR( "acpi cmos_s3 is NULL.\n" );
}
}else {
- ERR( "acpi state is NULL." );
+ ERR( "acpi state is NULL.\n" );
}
}
#define GET_PLANE(data, p) (((data) >> ((p) * 8)) & 0xff)
#endif
+#define MARU_VGA
+
static const uint32_t mask16[16] = {
PAT(0x00000000),
PAT(0x000000ff),
static const char *screen_dump_filename;
static DisplayChangeListener *screen_dump_dcl;
-#ifdef TARGET_I386
-static int is_off_screen = 0;
-#endif
-
static void vga_dumb_update_retrace_info(VGACommonState *s)
{
(void) s;
uint32_t v, addr1, addr;
maru_vga_draw_line_func *maru_vga_draw_line;
-#ifdef TARGET_I386
- if( brightness_off ) {
- if( is_off_screen ) {
- return;
- }
- }
-#endif
-
full_update |= update_basic_params(s);
if (!full_update)
if (depth == 32) {
#endif
qemu_free_displaysurface(s->ds);
+
+#ifdef MARU_VGA // create new sufrace by malloc in MARU VGA
+ s->ds->surface = qemu_create_displaysurface( s->ds, disp_width, height );
+#else
s->ds->surface = qemu_create_displaysurface_from(disp_width, height, depth,
s->line_offset,
s->vram_ptr + (s->start_addr * 4));
+#endif
+
#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
s->ds->surface->pf = qemu_different_endianness_pixelformat(depth);
#endif
}
/* explicit invalidation for the hardware cursor */
update |= (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1;
-#ifdef TARGET_I386
+
+#ifdef MARU_VGA // needs full update
update |= 1;
#endif
+
if (update) {
if (y_start < 0)
y_start = y;
s->cursor_draw_line(s, d, y);
}
-#ifdef TARGET_I386
+#ifdef MARU_VGA
+
int i;
uint8_t *fb_sub;
uint8_t *over_sub;
uint32_t *dst;
uint16_t overlay_bottom;
- if (overlay0_power) {
+ if ( overlay0_power ) {
+
overlay_bottom = overlay0_top + overlay0_height;
- if (overlay0_top <= y && y < overlay_bottom) {
+ if ( overlay0_top <= y && y < overlay_bottom ) {
+
fb_sub = s->vram_ptr + addr + overlay0_left * 4;
- over_sub = overlay_ptr + (y - overlay0_top) * overlay0_width * 4;
- dst = (uint32_t*)(s->ds->surface->data + addr + overlay0_left * 4);
+ over_sub = overlay_ptr + ( y - overlay0_top ) * overlay0_width * 4;
+ dst = (uint32_t*) ( s->ds->surface->data + addr + overlay0_left * 4 );
+
+ for ( i = 0; i < overlay0_width; i++, fb_sub += 4, over_sub += 4, dst++ ) {
- for (i = 0; i < overlay0_width; i++, fb_sub += 4, over_sub += 4, dst++) {
- //alpha = 0x80;
alpha = fb_sub[3];
c_alpha = 0xff - alpha;
- //fprintf(stderr, "alpha = %d\n", alpha);
- *dst = ((c_alpha * over_sub[0] + alpha * fb_sub[0]) >> 8) |
- ((c_alpha * over_sub[1] + alpha * fb_sub[1]) & 0xFF00) |
- (((c_alpha * over_sub[2] + alpha * fb_sub[2]) & 0xFF00) << 8);
+ *dst = ( ( c_alpha * over_sub[0] + alpha * fb_sub[0] ) >> 8 )
+ | ( ( c_alpha * over_sub[1] + alpha * fb_sub[1] ) & 0xFF00 )
+ | ( ( ( c_alpha * over_sub[2] + alpha * fb_sub[2] ) & 0xFF00 ) << 8 );
}
+
}
+
}
- if (overlay1_power) {
+ if ( overlay1_power ) {
+
overlay_bottom = overlay1_top + overlay1_height;
- if (overlay1_top <= y && y < overlay_bottom) {
+ if ( overlay1_top <= y && y < overlay_bottom ) {
+
fb_sub = s->vram_ptr + addr + overlay1_left * 4;
- over_sub = overlay_ptr + (y - overlay1_top) * overlay1_width * 4 + 0x00400000;
- dst = (uint32_t*)(s->ds->surface->data + addr + overlay1_left * 4);
+ over_sub = overlay_ptr + ( y - overlay1_top ) * overlay1_width * 4 + 0x00400000;
+ dst = (uint32_t*) ( s->ds->surface->data + addr + overlay1_left * 4 );
+
+ for ( i = 0; i < overlay1_width; i++, fb_sub += 4, over_sub += 4, dst++ ) {
- for (i = 0; i < overlay1_width; i++, fb_sub += 4, over_sub += 4, dst++) {
- //alpha = 0x80;
alpha = fb_sub[3];
c_alpha = 0xff - alpha;
- //fprintf(stderr, "alpha = %d\n", alpha);
- *dst = ((c_alpha * over_sub[0] + alpha * fb_sub[0]) >> 8) |
- ((c_alpha * over_sub[1] + alpha * fb_sub[1]) & 0xFF00) |
- (((c_alpha * over_sub[2] + alpha * fb_sub[2]) & 0xFF00) << 8);
+ *dst = ( ( c_alpha * over_sub[0] + alpha * fb_sub[0] ) >> 8 )
+ | ( ( c_alpha * over_sub[1] + alpha * fb_sub[1] ) & 0xFF00 )
+ | ( ( ( c_alpha * over_sub[2] + alpha * fb_sub[2] ) & 0xFF00 ) << 8 );
}
+
}
+
}
- //FIXME
- if( brightness_off ) {
+ if ( brightness_off ) {
dst_sub = s->ds->surface->data + addr;
- dst = (uint32_t*)(s->ds->surface->data + addr);
- for (i=0; i < disp_width; i++, dst_sub += 4, dst++) {
- *dst = 0xFF000000;
+ dst = (uint32_t*) ( s->ds->surface->data + addr );
+
+ for ( i = 0; i < disp_width; i++, dst_sub += 4, dst++ ) {
+ *dst = 0xFF000000; // black
}
- }else if (brightness_level < 24) {
+ } else {
- alpha = brightness_tbl[brightness_level];
+ if ( brightness_level < BRIGHTNESS_MAX ) {
- dst_sub = s->ds->surface->data + addr;
- dst = (uint32_t*)(s->ds->surface->data + addr);
+ alpha = brightness_tbl[brightness_level];
+
+ dst_sub = s->ds->surface->data + addr;
+ dst = (uint32_t*) ( s->ds->surface->data + addr );
- for (i=0; i < disp_width; i++, dst_sub += 4, dst++) {
- *dst = ((alpha * dst_sub[0]) >> 8) |
- ((alpha * dst_sub[1]) & 0xFF00) |
- (((alpha * dst_sub[2]) & 0xFF00) << 8);
+ for ( i = 0; i < disp_width; i++, dst_sub += 4, dst++ ) {
+ *dst = ( ( alpha * dst_sub[0] ) >> 8 )
+ | ( ( alpha * dst_sub[1] ) & 0xFF00 )
+ | ( ( ( alpha * dst_sub[2] ) & 0xFF00 ) << 8 );
+ }
}
}
-#endif /* TARGET_I386 */
+#endif /* MARU_VGA */
} else {
if (y_start >= 0) {
disp_width, y - y_start);
}
- if( brightness_off ) {
- is_off_screen = 1;
- }else {
- if( is_off_screen ) {
- is_off_screen = 0;
- }
- }
-
/* reset modified pages */
if (page_max >= page_min) {
memory_region_reset_dirty(&s->vram,
#include <pthread.h>
+#include "console.h"
#include "maru_sdl.h"
#include "emul_state.h"
#include "sdl_rotate.h"
#include "maru_finger.h"
+#include "hw/maru_pm.h"
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(tizen, maru_sdl);
SDL_Surface *processing_screen = NULL;
if (scale_factor != 1.0 || screen_degree != 0.0) {
+
+ // workaround
+ if ( surface_qemu ) {
+ // set color key 'magenta'
+ surface_qemu->format->colorkey = 0xFF00FF;
+ }
+
//image processing
processing_screen = rotozoomSurface(surface_qemu, screen_degree, scale_factor, 1);
SDL_BlitSurface(processing_screen, NULL, surface_screen, NULL);
return ret;
}
+static void put_hardkey_code( SDL_UserEvent event ) {
+
+ // use pointer as integer
+ int event_type = (int) event.data1;
+ int keycode = (int) event.data2;
+
+ if ( KEY_PRESSED == event_type ) {
+
+ if ( kbd_mouse_is_absolute() ) {
+
+ // home key or power key is used for resume.
+ if ( ( HARD_KEY_HOME == keycode ) || ( HARD_KEY_POWER == keycode ) ) {
+ if ( is_suspended_state() ) {
+ INFO( "user requests system resume.\n" );
+ resume();
+ }
+ }
+
+ ps2kbd_put_keycode( keycode & 0x7f );
+
+ }
+
+ } else if ( KEY_RELEASED == event_type ) {
+
+ if ( kbd_mouse_is_absolute() ) {
+ ps2kbd_put_keycode( keycode | 0x80 );
+ }
+
+ } else {
+ ERR( "Unknown hardkey event type.[event_type:%d]", event_type );
+ }
+
+}
+
+static void handle_sdl_user_event ( SDL_UserEvent event ) {
+
+ int code = event.code;
+
+ switch ( code ) {
+ case SDL_USER_EVENT_CODE_HARDKEY: {
+ put_hardkey_code( event );
+ break;
+ }
+ default: {
+ ERR( "Unknown sdl user event.[event code:%d]\n", code );
+ break;
+ }
+ }
+
+}
+
static void qemu_ds_refresh(DisplayState *ds)
{
SDL_Event ev1, *ev = &ev1;
break;
}
+ case SDL_USEREVENT: {
+ handle_sdl_user_event( ev->user );
+ break;
+ }
default:
break;
#include <SDL.h>
#include <SDL_syswm.h>
+#define SDL_USER_EVENT_CODE_HARDKEY 1
+
void maruskin_display_init(DisplayState *ds);
void maruskin_sdl_init(int swt_handle, int lcd_size_width, int lcd_size_height);
void maruskin_sdl_resize(void);
#include "maruskin_operation.h"
#include "maru_sdl.h"
#include "debug_ch.h"
-#include "../hw/maru_pm.h"
-#include "console.h"
#include "sdb.h"
#include "nbd.h"
#include "../mloop_event.h"
#include "emul_state.h"
#include "maruskin_keymap.h"
+#include "emul_state.h"
MULTI_DEBUG_CHANNEL(qemu, skin_operation);
+#define CLOSE_POWER_KEY_INTERVAL 1.2 // seconds
void start_display( int handle_id, int lcd_size_width, int lcd_size_height, double scale_factor, short rotation_type )
{
{
TRACE( "do_hardkey_event event_type:%d, keycode:%d\n", event_type, keycode );
- // press
- if ( KEY_PRESSED == event_type ) {
+ SDL_Event event;
+ memset( &event, 0, sizeof(SDL_Event) );
- if ( kbd_mouse_is_absolute() ) {
+ event.type = SDL_USEREVENT;
+ event.user.code = SDL_USER_EVENT_CODE_HARDKEY;
- // home key or power key is used for resume.
- if ( ( HARD_KEY_HOME == keycode ) || ( HARD_KEY_POWER == keycode ) ) {
- if ( is_suspended_state() ) {
- INFO( "user requests system resume.\n" );
- resume();
-#ifdef _WIN32
- Sleep( 500 );
-#else
- usleep( 500 * 1000 );
-#endif
- }
- }
-
- ps2kbd_put_keycode( keycode & 0x7f );
-
- }
+ // use pointer as integer
+ event.user.data1 = (void*) event_type;
+ event.user.data2 = (void*) keycode;
- } else if ( KEY_RELEASED == event_type ) {
-
- if ( kbd_mouse_is_absolute() ) {
- ps2kbd_put_keycode( keycode | 0x80 );
- }
-
- }
+ // see qemu_ds_refresh in maru_sdl.c
+ SDL_PushEvent( &event );
}
{
INFO( "request_close\n" );
- ps2kbd_put_keycode( 103 & 0x7f );
+ do_hardkey_event( KEY_PRESSED, HARD_KEY_POWER );
+
#ifdef _WIN32
- Sleep( 1.6 * 1000 ); // 1.6 seconds
+ Sleep( CLOSE_POWER_KEY_INTERVAL * 1000 ); // 1.6 seconds
#else
- usleep( 1.6 * 1000 * 1000 ); // 1.6 seconds
+ usleep( CLOSE_POWER_KEY_INTERVAL * 1000 * 1000 ); // 1.6 seconds
#endif
- kbd_put_keycode( 103 | 0x80 );
+
+ do_hardkey_event( KEY_RELEASED, HARD_KEY_POWER );
}