ARM: add MARU brightness
authorOleg Ogurtsov <o.ogurtsov@samsung.com>
Wed, 11 Jul 2012 06:33:57 +0000 (10:33 +0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Fri, 13 Jul 2012 05:27:59 +0000 (09:27 +0400)
hw/exynos4210_fimd.c
tizen/src/hw/maru_arm_board.c
tizen/src/hw/maru_brightness.c

index 3313f00a71ce17188da1a9aa9b7a04a07521122b..84288a436e0e7c12a33684a998aab1ba2616b9b8 100644 (file)
@@ -28,6 +28,7 @@
 #include "console.h"
 #include "pixel_ops.h"
 #include "bswap.h"
+#include "../tizen/src/hw/maru_brightness.h"
 
 /* Debug messages configuration */
 #define EXYNOS4210_FIMD_DEBUG              0
@@ -860,28 +861,64 @@ static void draw_line_mapcolor(Exynos4210fimdWindow *w, uint8_t *src,
 
 static int put_to_qemufb_pixel8(const rgba p, uint8_t *d)
 {
-    uint32_t pixel = rgb_to_pixel8(p.r, p.g, p.b);
+    uint32_t pixel;
+    uint8_t alpha;
+
+    if ( brightness_level < BRIGHTNESS_MAX ) {
+        alpha = brightness_tbl[brightness_level];
+        pixel = rgb_to_pixel8(alpha * p.r >> 8, alpha * p.g >> 8,
+                              alpha * p.b >> 8);
+    } else {
+        pixel = rgb_to_pixel8(p.r, p.g, p.b);
+    }
     *(uint8_t *)d = pixel;
     return 1;
 }
 
 static int put_to_qemufb_pixel15(const rgba p, uint8_t *d)
 {
-    uint32_t pixel = rgb_to_pixel15(p.r, p.g, p.b);
+    uint32_t pixel;
+    uint8_t alpha;
+
+    if ( brightness_level < BRIGHTNESS_MAX ) {
+        alpha = brightness_tbl[brightness_level];
+        pixel = rgb_to_pixel15(alpha * p.r >> 8, alpha * p.g >> 8,
+                               alpha * p.b >> 8);
+    } else {
+        pixel = rgb_to_pixel15(p.r, p.g, p.b);
+    }
     *(uint16_t *)d = pixel;
     return 2;
 }
 
 static int put_to_qemufb_pixel16(const rgba p, uint8_t *d)
 {
-    uint32_t pixel = rgb_to_pixel16(p.r, p.g, p.b);
+    uint32_t pixel;
+    uint8_t alpha;
+
+    if ( brightness_level < BRIGHTNESS_MAX ) {
+        alpha = brightness_tbl[brightness_level];
+        pixel = rgb_to_pixel16(alpha * p.r >> 8, alpha * p.g >> 8,
+                               alpha * p.b >> 8);
+    } else {
+        pixel = rgb_to_pixel16(p.r, p.g, p.b);
+    }
     *(uint16_t *)d = pixel;
     return 2;
 }
 
 static int put_to_qemufb_pixel24(const rgba p, uint8_t *d)
 {
-    uint32_t pixel = rgb_to_pixel24(p.r, p.g, p.b);
+    uint32_t pixel;
+    uint8_t alpha;
+
+    if ( brightness_level < BRIGHTNESS_MAX ) {
+        alpha = brightness_tbl[brightness_level];
+        pixel = rgb_to_pixel24(alpha * p.r >> 8, alpha * p.g >> 8,
+                               alpha * p.b >> 8);
+    } else {
+        pixel = rgb_to_pixel24(p.r, p.g, p.b);
+    }
     *(uint8_t *)d++ = (pixel >>  0) & 0xFF;
     *(uint8_t *)d++ = (pixel >>  8) & 0xFF;
     *(uint8_t *)d++ = (pixel >> 16) & 0xFF;
@@ -890,7 +927,16 @@ static int put_to_qemufb_pixel24(const rgba p, uint8_t *d)
 
 static int put_to_qemufb_pixel32(const rgba p, uint8_t *d)
 {
-    uint32_t pixel = rgb_to_pixel24(p.r, p.g, p.b);
+    uint32_t pixel;
+    uint8_t alpha;
+
+    if ( brightness_level < BRIGHTNESS_MAX ) {
+        alpha = brightness_tbl[brightness_level];
+        pixel = rgb_to_pixel24(alpha * p.r >> 8, alpha * p.g >> 8,
+                               alpha * p.b >> 8);
+    } else {
+        pixel = rgb_to_pixel24(p.r, p.g, p.b);
+    }
     *(uint32_t *)d = pixel;
     return 4;
 }
@@ -1283,6 +1329,7 @@ static void exynos4210_fimd_update(void *opaque)
                         w->lefttop_x * RGBA_SIZE + (w->lefttop_y + line) *
                         global_width * RGBA_SIZE, blend);
                 }
+
                 host_fb_addr += inc_size;
                 fb_line_addr += inc_size;
                 is_dirty = false;
index 698611986f3afa50370d89198ada8a31cc2ffbe6..2cc93cb07b92eaeeb1382afebe2038fd1a46642e 100644 (file)
@@ -30,6 +30,7 @@
 #include "maru_arm.h"
 #include "i2c.h"
 #include "exec-memory.h"
+#include "../tizen/src/hw/maru_brightness.h"
 
 #undef DEBUG
 //#define DEBUG
@@ -118,6 +119,7 @@ static void maru_arm_machine_init(ram_addr_t ram_size,
 
     pci_create_simple(pci_bus, -1, "pci-ohci");
     maru_camera_pci_init(pci_bus);
+    pci_maru_brightness_init(pci_bus);
     codec_init(pci_bus);
 
     arm_load_kernel(first_cpu, &maru_arm_board_binfo);
index 601e739db9abd58d321a523721bec0be54038690..103cafd1cee801ef8be2daf0b49c3752f52f2c22 100644 (file)
@@ -38,6 +38,9 @@
 
 
 #include "pc.h"
+#ifdef TARGET_ARM
+#include "console.h"
+#endif
 #include "pci.h"
 #include "maru_pci_ids.h"
 #include "maru_brightness.h"
@@ -97,10 +100,16 @@ static void brightness_reg_write( void *opaque, target_phys_addr_t addr, uint64_
     case BRIGHTNESS_LEVEL:
         brightness_level = val;
         INFO("brightness_level : %lld\n", val);
+#ifdef TARGET_ARM
+        vga_hw_invalidate();
+#endif
         return;
     case BRIGHTNESS_OFF:
         INFO("brightness_off : %lld\n", val);
         brightness_off = val;
+#ifdef TARGET_ARM
+        vga_hw_invalidate();
+#endif
         return;
     default:
         ERR("wrong brightness register write - addr : %d\n", (int)addr);