typedef struct BrightnessState {
PCIDevice dev;
ram_addr_t vram_offset;
- uint8_t* vram_ptr;
- MemoryRegion mem_addr;
MemoryRegion mmio_addr;
} BrightnessState;
enum {
- BRIGHTNESS_LEVEL = 0x00,
- BRIGHTNESS_OFF = 0x04,
+ BRIGHTNESS_LEVEL = 0x00,
+ BRIGHTNESS_OFF = 0x04,
};
uint32_t brightness_level = 24;
uint32_t brightness_off = 0;
+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) {
case 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 brightness_off;
default:
ERR("wrong brightness register read - addr : %d\n", (int)addr);
break;
static void brightness_reg_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size)
{
- INFO("brightness_reg_write: addr = %d, val = %d\n", (int)addr, val);
-
#if BRIGHTNESS_MIN > 0
if (val < BRIGHTNESS_MIN || val > BRIGHTNESS_MAX) {
#else
switch (addr & 0xFF) {
case BRIGHTNESS_LEVEL:
brightness_level = val;
+ INFO("brightness_level : %lld\n", val);
return;
case BRIGHTNESS_OFF:
- INFO("Brightness off : %d\n", val);
+ INFO("brightness_off : %lld\n", val);
brightness_off = val;
return;
default:
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_ram(&s->mem_addr, NULL, "brightness.ram", BRIGHTNESS_MEM_SIZE);
memory_region_init_io (&s->mmio_addr, &brightness_mmio_ops, s, "brightness-mmio", BRIGHTNESS_REG_SIZE);
- s->vram_ptr = memory_region_get_ram_ptr(&s->mem_addr);
-
- /* setup memory space */
- /* memory #0 device memory (overlay surface) */
- /* memory #1 memory-mapped I/O */
- pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mem_addr);
pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_addr);
return 0;
/*
- *
+ * Maru brightness device for VGA
*
* Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
*
#include "qemu-common.h"
+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);
#include "pci.h"
#include "maru_pci_ids.h"
#include "maru_overlay.h"
+#include "debug_ch.h"
+
+MULTI_DEBUG_CHANNEL(qemu, maru_overlay);
#define OVERLAY_MEM_SIZE (8192 * 1024) // 4MB(overlay0) + 4MB(overlay1)
#define OVERLAY_REG_SIZE 256
OVERLAY_SIZE = 0x08, // width and height
};
+uint8_t* overlay_ptr;
+
uint8_t overlay0_power;
uint16_t overlay0_left;
uint16_t overlay0_top;
typedef struct OverlayState {
PCIDevice dev;
-
- ram_addr_t vram_offset;
MemoryRegion mem_addr;
MemoryRegion mmio_addr;
} OverlayState;
-uint8_t* overlay_ptr;
static uint64_t overlay_reg_read(void *opaque, target_phys_addr_t addr, unsigned size)
{
return overlay1_width | overlay1_height << 16;
break;
default:
- fprintf(stderr, "wrong overlay register read - addr : %d\n", (int)addr);
+ ERR("wrong overlay register read - addr : %d\n", (int)addr);
break;
}
overlay1_height = val >> 16;
break;
default:
- fprintf(stderr, "wrong overlay register write - addr : %d\n", (int)addr);
+ ERR("wrong overlay register write - addr : %d\n", (int)addr);
break;
}
}
/* setup memory space */
/* memory #0 device memory (overlay surface) */
/* memory #1 memory-mapped I/O */
- pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem_addr);
- pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mmio_addr);
+ pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mem_addr);
+ pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_addr);
return 0;
}
#include "qemu-common.h"
+extern uint8_t* overlay_ptr;
+extern uint8_t overlay0_power;
+extern uint16_t overlay0_left;
+extern uint16_t overlay0_top;
+extern uint16_t overlay0_width;
+extern uint16_t overlay0_height;
+
+extern uint8_t overlay1_power;
+extern uint16_t overlay1_left;
+extern uint16_t overlay1_top;
+extern uint16_t overlay1_width;
+extern uint16_t overlay1_height;
+
int pci_maru_overlay_init( PCIBus *bus );
#endif /* MARU_OVERLAY_H_ */
#include "pixel_ops.h"
#include "qemu-timer.h"
#include "maru_vga_int.h"
+#include "maru_brightness.h"
+#include "maru_overlay.h"
//#define DEBUG_VGA
//#define DEBUG_VGA_MEM
/*
* graphic modes
*/
-#if defined (TARGET_I386)
-extern uint8_t overlay0_power;
-extern uint16_t overlay0_left;
-extern uint16_t overlay0_top;
-extern uint16_t overlay0_width;
-extern uint16_t overlay0_height;
-
-extern uint8_t overlay1_power;
-extern uint16_t overlay1_left;
-extern uint16_t overlay1_top;
-extern uint16_t overlay1_width;
-extern uint16_t overlay1_height;
-
-extern uint8_t* overlay_ptr; // pointer in qemu space
-
-/* brightness level : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 */
-//static const uint8_t brightness_tbl[] = {20, 100, 120, 140, 160, 180, 200, 220, 230, 240};
-static const 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};
-extern uint32_t brightness_level;
-extern uint32_t brightness_off;
-#endif
static void vga_draw_graphic(VGACommonState *s, int full_update)
{
int y1, y, update, linesize, y_start, double_scan, mask, depth;
int i;
uint8_t *fb_sub;
uint8_t *over_sub;
- uint8_t *dst_sub;
+// uint8_t *dst_sub;
uint8_t alpha, c_alpha;
uint32_t *dst;
uint16_t overlay_bottom;
}
}
- if( brightness_off ) {
- alpha = 0x00;
- }else if (brightness_level < 24) {
- alpha = brightness_tbl[brightness_level];
- }
-
- if ( brightness_off || brightness_level < 24 ) {
- 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);
- }
- }
+ //FIXME
+// if( brightness_off ) {
+// alpha = 0x00;
+// }else if (brightness_level < 24) {
+// alpha = brightness_tbl[brightness_level];
+// }
+//
+// if ( brightness_level < 24 ) {
+// 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);
+// }
+// }
#endif /* TARGET_I386 */
} else {