1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Not a Contribution, Apache license notifications and license are retained 5 * for attribution purposes only. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 #include <stdint.h> 21 #include <malloc.h> 22 #include <arm_neon.h> 23 #include "hwc_delta_panel.h" 24 25 #define BYTE_PER_PIXEL 4 26 #define X_LAST 392 27 28 const static int X_START_TABLE[] = {0,176,168,160,152,152,144,144,136,136,136,128,128,128,120, 29 120,120,112,112,112,112,104,104,104,104,96,96,96,96,96,88, 30 88,88,88,88,80,80,80,80,80,80,72,72,72,72,72,72,64,64,64,64, 31 64,64,64,64,56,56,56,56,56,56,56,48,48,48,48,48,48,48,48,48, 32 40,40,40,40,40,40,40,40,40,40,32,32,32,32,32,32,32,32,32,32, 33 32,32,24,24,24,24,24,24,24,24,24,24,24,24,24,16,16,16,16,16, 34 16,16,16,16,16,16,16,16,16,16,16,16,8,8,8,8,8,8,8,8,8,8,8,8, 35 8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 36 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 37 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 38 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8, 39 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16, 40 16,16,16,16,16,16,16,16,16,16,16,16,24,24,24,24,24,24,24,24, 41 24,24,24,24,24,32,32,32,32,32,32,32,32,32,32,32,32,40,40,40, 42 40,40,40,40,40,40,40,48,48,48,48,48,48,48,48,48,56,56,56,56, 43 56,56,56,64,64,64,64,64,64,64,64,72,72,72,72,72,72,80,80,80, 44 80,80,80,88,88,88,88,88,96,96,96,96,96,104,104,104,104,112, 45 112,112,112,120,120,120,128,128,128,136,136,136,144,144,152, 46 152,160,168,176}; 47 48 const static int TABLE_SIZE = sizeof(X_START_TABLE) / sizeof(X_START_TABLE[0]); 49 const static uint8_t MASK[8] = {0xff, 0, 0xff, 0, 0xff, 0, 0xff, 0}; 50 51 /* 52 * Delta Real Panel Rending - Delta real pixel rending for Wearable device panel. 53 * pImage - Point to head of display image 54 * width - Input image width 55 * height - Input image height 56 */ deltaPanelRendering(uint8_t * pImage,int width,int height)57 void deltaPanelRendering(uint8_t *pImage, int width, int height) 58 { 59 int x, y; 60 uint8_t *pData; 61 int byteWidth; 62 uint32_t *pPixelAbove, *pPixelCenter, *pPixelBelow, *pPixelEnd; 63 int64_t diff; 64 int xStart, xEnd; 65 const uint8x8_t MASK_8X8 = vld1_u8(MASK); 66 const uint8x8_t THREE_8X8 = vdup_n_u8(3); 67 68 byteWidth = width * BYTE_PER_PIXEL; 69 pData = pImage + byteWidth; 70 71 // center 72 for(y = 1; y < (height - 1) && y < TABLE_SIZE; y++) 73 { 74 xStart = X_START_TABLE[y]; 75 xEnd = X_LAST - X_START_TABLE[y]; 76 pPixelCenter = ((uint32_t*)pData) + xStart; 77 pPixelEnd = ((uint32_t*)pData) + xEnd; 78 pPixelAbove = pPixelCenter - width; 79 pPixelBelow = pPixelCenter + width; 80 81 // process 8 pixels 82 while (pPixelCenter <= pPixelEnd) 83 { 84 __asm__ __volatile__ ( 85 "vld4.8 {d8-d11}, [%[above]]! \n" 86 "vld4.8 {d12-d15}, [%[below]]! \n" 87 "vld4.8 {d16-d19}, [%[center]] \n" 88 #ifdef DELTA_PANEL_R 89 "vbit d12, d8, %[mask] \n" 90 #endif 91 #ifdef DELTA_PANEL_G 92 "vbit d13, d9, %[mask] \n" 93 #endif 94 #ifdef DELTA_PANEL_B 95 "vbit d14, d10, %[mask] \n" 96 #endif 97 #ifdef DELTA_PANEL_R 98 "vmovl.u8 q0, d12 \n" 99 #endif 100 #ifdef DELTA_PANEL_G 101 "vmovl.u8 q1, d13 \n" 102 #endif 103 #ifdef DELTA_PANEL_B 104 "vmovl.u8 q2, d14 \n" 105 #endif 106 #ifdef DELTA_PANEL_R 107 "vmlal.u8 q0, d16, %[three] \n" 108 #endif 109 #ifdef DELTA_PANEL_G 110 "vmlal.u8 q1, d17, %[three] \n" 111 #endif 112 #ifdef DELTA_PANEL_B 113 "vmlal.u8 q2, d18, %[three] \n" 114 #endif 115 #ifdef DELTA_PANEL_R 116 "vshrn.i16 d16, q0, #2 \n" 117 #endif 118 #ifdef DELTA_PANEL_G 119 "vshrn.i16 d17, q1, #2 \n" 120 #endif 121 #ifdef DELTA_PANEL_B 122 "vshrn.i16 d18, q2, #2 \n" 123 #endif 124 "vst4.8 {d16-d19}, [%[center]]! \n" 125 : [above]"+&r"(pPixelAbove) 126 , [below]"+&r"(pPixelBelow) 127 , [center]"+&r"(pPixelCenter) 128 : [mask]"w"(MASK_8X8) 129 , [three]"w"(THREE_8X8) 130 : "d8", "d9", "d10", "d11" 131 , "d12", "d13", "d14", "d15" 132 , "d16", "d17", "d18", "d19" 133 , "q0", "q1", "q2", "memory"); 134 } 135 136 pData += byteWidth; 137 } 138 } 139