Commit 74155dc1 authored by Mark Stevens's avatar Mark Stevens
Browse files

update to duco/rk 3128-6003-6.0

parent edd2a148
......@@ -39,6 +39,7 @@
#include "selinux/selinux.h"
#include "qemu_tracing.h"
#include <cutils/klog.h>
#endif
static void adb_cleanup(void)
......@@ -357,6 +358,30 @@ void close_stdin() {
dup2(fd, 0);
adb_close(fd);
}
// usb adb will use ro.serialno write into /config/usb_gadget/g1/strings/0x409/serialnumber for adb connect.
// ro.serialno is generate by drmservie which is started later than adbd service, so adb usb driver can't get serialno in time.
// must wait for ro.serialno ready, then start adbd.
static int wait_for_serialno_ready(void) {
char value[PROPERTY_VALUE_MAX];
int count = 50;
//KLOG_ERROR("adb_main", "wait_for_serialno_ready\n");
while (1) {
property_get("ro.serialno", value, "none");
if (strcmp(value, "none") == 0) {
usleep(200000);
//KLOG_ERROR("adb_main", "ro.serialno not ready\n");
if (count-- <= 0)
break;
continue;
}
//KLOG_ERROR("adb_main", "ro.serialno ready\n");
break;
}
//KLOG_ERROR("adb_main", "wait_for_serialno_ready return count = %d\n", count);
return 0;
}
#endif
// TODO(danalbert): Split this file up into adb_main.cpp and adbd_main.cpp.
......@@ -405,6 +430,8 @@ int main(int argc, char **argv) {
* adb-debug qemud service in the emulator. */
adb_qemu_trace_init();
wait_for_serialno_ready();
D("Handling main()\n");
return adb_main(0, DEFAULT_ADB_PORT);
#endif
......
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_SRC_FILES:= \
drmservice.c
LOCAL_MULTILIB := 32
LOCAL_C_INCLUDES += bionic \
$(call include-path-for, libhardware_legacy)/hardware_legacy
LOCAL_MODULE:=drmservice
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES := libfs_mgr libcutils
#libc
LOCAL_SHARED_LIBRARIES := libhardware_legacy libnetutils liblog
include $(BUILD_EXECUTABLE)
This diff is collapsed.
#!/bin/sh
PID=`adb shell ps | grep drmservice | awk '{print $2}'`
adb shell kill -9 $PID
......@@ -53,9 +53,10 @@
#define KEY_LOC_PROP "ro.crypto.keyfile.userdata"
#define KEY_IN_FOOTER "footer"
#define E2FSCK_BIN "/system/bin/e2fsck"
#define E2FSCK_BIN "/sbin/e2fsck"
#define F2FS_FSCK_BIN "/system/bin/fsck.f2fs"
#define MKSWAP_BIN "/system/bin/mkswap"
#define RESIZE2FS_BIN "/sbin/resize2fs"
#define FSCK_LOG_FILE "/dev/fscklogs/log"
......@@ -93,6 +94,35 @@ static int wait_for_file(const char *filename, int timeout)
return ret;
}
static void resize_fs(char *blk_device, char *fs_type)
{
pid_t pid;
int status;
int err;
char *resize2fs_argv[3] = {
RESIZE2FS_BIN,
blk_device,
NULL
};
if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) {
if (access(RESIZE2FS_BIN, X_OK)) {
INFO("Not running %s on %s (executable not in system image)\n",
RESIZE2FS_BIN, blk_device);
} else {
INFO("Running %s on %s\n", RESIZE2FS_BIN, blk_device);
err = android_fork_execvp_ext(ARRAY_SIZE(resize2fs_argv), resize2fs_argv,
&status, true, LOG_KLOG, false, NULL);
if (err < 0) {
/* No need to check for error in fork, we can't really handle it now */
ERROR("Failed trying to run %s\n", RESIZE2FS_BIN);
}
}
}
return;
}
static void check_fs(char *blk_device, char *fs_type, char *target)
{
int status;
......@@ -161,11 +191,10 @@ static void check_fs(char *blk_device, char *fs_type, char *target)
} else if (!strcmp(fs_type, "f2fs")) {
char *f2fs_fsck_argv[] = {
F2FS_FSCK_BIN,
"-f",
"-a",
blk_device
};
INFO("Running %s -f %s\n", F2FS_FSCK_BIN, blk_device);
INFO("Running %s -a %s\n", F2FS_FSCK_BIN, blk_device);
ret = android_fork_execvp_ext(ARRAY_SIZE(f2fs_fsck_argv), f2fs_fsck_argv,
&status, true, LOG_KLOG | LOG_FILE,
true, FSCK_LOG_FILE);
......@@ -538,6 +567,10 @@ int fs_mgr_mount_all(struct fstab *fstab)
wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
}
if (fstab->recs[i].fs_mgr_flags & MF_RESIZE) {
resize_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type);
}
if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && device_is_secure()) {
int rc = fs_mgr_setup_verity(&fstab->recs[i]);
if (device_is_debuggable() && rc == FS_MGR_SETUP_VERITY_DISABLED) {
......@@ -680,6 +713,10 @@ int fs_mgr_do_mount(struct fstab *fstab, char *n_name, char *n_blk_device,
wait_for_file(n_blk_device, WAIT_TIMEOUT);
}
if (fstab->recs[i].fs_mgr_flags & MF_RESIZE) {
resize_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type);
}
if (fstab->recs[i].fs_mgr_flags & MF_CHECK) {
check_fs(n_blk_device, fstab->recs[i].fs_type,
fstab->recs[i].mount_point);
......
......@@ -61,6 +61,7 @@ static struct flag_list mount_flags[] = {
static struct flag_list fs_mgr_flags[] = {
{ "wait", MF_WAIT },
{ "check", MF_CHECK },
{ "resize", MF_RESIZE },
{ "encryptable=",MF_CRYPT },
{ "forceencrypt=",MF_FORCECRYPT },
{ "fileencryption",MF_FILEENCRYPTION },
......
......@@ -79,6 +79,7 @@
#define MF_NOTRIM 0x1000
#define MF_FILEENCRYPTION 0x2000
#define MF_FORMATTABLE 0x4000
#define MF_RESIZE 0x8000
#define DM_BUF_SIZE 4096
......
......@@ -870,9 +870,8 @@ int fs_mgr_load_verity_state(int *mode)
continue;
}
if (current != VERITY_MODE_DEFAULT) {
if (current == VERITY_MODE_LOGGING) {
*mode = current;
break;
}
}
......@@ -906,13 +905,12 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
property_get("ro.boot.veritymode", propbuf, "");
if (*propbuf != '\0') {
if (fs_mgr_load_verity_state(&mode) == -1) {
return -1;
}
use_state = false; /* state is kept by the bootloader */
}
if (fs_mgr_load_verity_state(&mode) == -1) {
return -1;
}
fd = TEMP_FAILURE_RETRY(open("/dev/device-mapper", O_RDWR | O_CLOEXEC));
if (fd == -1) {
......@@ -935,6 +933,13 @@ int fs_mgr_update_verity_state(fs_mgr_verity_state_callback callback)
continue;
}
if (use_state) {
if (get_verity_state_offset(&fstab->recs[i], &offset) < 0 ||
read_verity_state(fstab->recs[i].verity_loc, offset, &mode) < 0) {
continue;
}
}
mount_point = basename(fstab->recs[i].mount_point);
verity_ioctl_init(io, mount_point, 0);
......
......@@ -137,9 +137,6 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String
{ "USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_C", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_PD", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_PD_DRP", ANDROID_POWER_SUPPLY_TYPE_USB },
{ "Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS },
{ NULL, 0 },
};
......
......@@ -223,7 +223,7 @@ static void uevent_event(uint32_t /*epevents*/) {
cp = msg;
while (*cp) {
if (!strcmp(cp, "SUBSYSTEM=" POWER_SUPPLY_SUBSYSTEM)) {
if ((!strcmp(cp, "SUBSYSTEM=" POWER_SUPPLY_SUBSYSTEM)|| strstr(cp, POWER_SUPPLY_SUBSYSTEM))) {
healthd_battery_update();
break;
}
......
......@@ -159,7 +159,7 @@ static struct frame batt_anim_frames[] = {
};
static struct animation battery_animation = {
.run = false,
.run = true,
.frames = batt_anim_frames,
.cur_frame = 0,
.num_frames = ARRAY_SIZE(batt_anim_frames),
......@@ -580,7 +580,9 @@ static void handle_power_supply_state(struct charger *charger, int64_t now)
LOGW("[%" PRId64 "] shutting down\n", now);
android_reboot(ANDROID_RB_POWEROFF, 0, 0);
} else {
android_reboot(ANDROID_RB_POWEROFF, 0, 0);
/* otherwise we already have a shutdown timer scheduled */
LOGW("xiong:we already have a shutdown timer scheduled \n");
}
} else {
/* online supply present, reset shutdown timer if set */
......
This diff is collapsed.
/*
* Copyright (C) 2005 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_PIXELFLINGER_FORMAT_H
#define ANDROID_PIXELFLINGER_FORMAT_H
#include <stdint.h>
#include <sys/types.h>
enum GGLPixelFormat {
// these constants need to match those
// in graphics/PixelFormat.java, ui/PixelFormat.h, BlitHardware.h
GGL_PIXEL_FORMAT_UNKNOWN = 0,
GGL_PIXEL_FORMAT_NONE = 0,
GGL_PIXEL_FORMAT_RGBA_8888 = 1, // 4x8-bit ARGB
GGL_PIXEL_FORMAT_RGBX_8888 = 2, // 3x8-bit RGB stored in 32-bit chunks
GGL_PIXEL_FORMAT_RGB_888 = 3, // 3x8-bit RGB
GGL_PIXEL_FORMAT_RGB_565 = 4, // 16-bit RGB
GGL_PIXEL_FORMAT_BGRA_8888 = 5, // 4x8-bit BGRA
GGL_PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit RGBA
GGL_PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit RGBA
GGL_PIXEL_FORMAT_A_8 = 8, // 8-bit A
GGL_PIXEL_FORMAT_L_8 = 9, // 8-bit L (R=G=B = L)
GGL_PIXEL_FORMAT_LA_88 = 0xA, // 16-bit LA
GGL_PIXEL_FORMAT_RGB_332 = 0xB, // 8-bit RGB (non paletted)
// reserved range. don't use.
GGL_PIXEL_FORMAT_RESERVED_10 = 0x10,
GGL_PIXEL_FORMAT_RESERVED_11 = 0x11,
GGL_PIXEL_FORMAT_RESERVED_12 = 0x12,
GGL_PIXEL_FORMAT_RESERVED_13 = 0x13,
GGL_PIXEL_FORMAT_RESERVED_14 = 0x14,
GGL_PIXEL_FORMAT_RESERVED_15 = 0x15,
GGL_PIXEL_FORMAT_RESERVED_16 = 0x16,
GGL_PIXEL_FORMAT_RESERVED_17 = 0x17,
// reserved/special formats
GGL_PIXEL_FORMAT_Z_16 = 0x18,
GGL_PIXEL_FORMAT_S_8 = 0x19,
GGL_PIXEL_FORMAT_SZ_24 = 0x1A,
GGL_PIXEL_FORMAT_SZ_8 = 0x1B,
// reserved range. don't use.
GGL_PIXEL_FORMAT_RESERVED_20 = 0x20,
GGL_PIXEL_FORMAT_RESERVED_21 = 0x21,
};
enum GGLFormatComponents {
GGL_STENCIL_INDEX = 0x1901,
GGL_DEPTH_COMPONENT = 0x1902,
GGL_ALPHA = 0x1906,
GGL_RGB = 0x1907,
GGL_RGBA = 0x1908,
GGL_LUMINANCE = 0x1909,
GGL_LUMINANCE_ALPHA = 0x190A,
};
enum GGLFormatComponentIndex {
GGL_INDEX_ALPHA = 0,
GGL_INDEX_RED = 1,
GGL_INDEX_GREEN = 2,
GGL_INDEX_BLUE = 3,
GGL_INDEX_STENCIL = 0,
GGL_INDEX_DEPTH = 1,
GGL_INDEX_Y = 0,
GGL_INDEX_CB = 1,
GGL_INDEX_CR = 2,
};
typedef struct {
#ifdef __cplusplus
enum {
ALPHA = GGL_INDEX_ALPHA,
RED = GGL_INDEX_RED,
GREEN = GGL_INDEX_GREEN,
BLUE = GGL_INDEX_BLUE,
STENCIL = GGL_INDEX_STENCIL,
DEPTH = GGL_INDEX_DEPTH,
LUMA = GGL_INDEX_Y,
CHROMAB = GGL_INDEX_CB,
CHROMAR = GGL_INDEX_CR,
};
inline uint32_t mask(int i) const {
return ((1<<(c[i].h-c[i].l))-1)<<c[i].l;
}
inline uint32_t bits(int i) const {
return c[i].h - c[i].l;
}
#endif
uint8_t size; // bytes per pixel
uint8_t bitsPerPixel;
union {
struct {
uint8_t ah; // alpha high bit position + 1
uint8_t al; // alpha low bit position
uint8_t rh; // red high bit position + 1
uint8_t rl; // red low bit position
uint8_t gh; // green high bit position + 1
uint8_t gl; // green low bit position
uint8_t bh; // blue high bit position + 1
uint8_t bl; // blue low bit position
};
struct {
uint8_t h;
uint8_t l;
} __attribute__((__packed__)) c[4];
} __attribute__((__packed__));
uint16_t components; // GGLFormatComponents
} GGLFormat;
#ifdef __cplusplus
extern "C" const GGLFormat* gglGetPixelFormatTable(size_t* numEntries = 0);
#else
const GGLFormat* gglGetPixelFormatTable(size_t* numEntries);
#endif
// ----------------------------------------------------------------------------
#endif // ANDROID_PIXELFLINGER_FORMAT_H
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_PIXELFLINGER_H
#define ANDROID_PIXELFLINGER_H
#include <stdint.h>
#include <sys/types.h>
#include <pixelflinger/format.h>
// GGL types
typedef int8_t GGLbyte; // b
typedef int16_t GGLshort; // s
typedef int32_t GGLint; // i
typedef ssize_t GGLsizei; // i
typedef int32_t GGLfixed; // x
typedef int32_t GGLclampx; // x
typedef float GGLfloat; // f
typedef float GGLclampf; // f
typedef double GGLdouble; // d
typedef double GGLclampd; // d
typedef uint8_t GGLubyte; // ub
typedef uint8_t GGLboolean; // ub
typedef uint16_t GGLushort; // us
typedef uint32_t GGLuint; // ui
typedef unsigned int GGLenum; // ui
typedef unsigned int GGLbitfield; // ui
typedef void GGLvoid;
typedef int32_t GGLfixed32;
typedef int32_t GGLcolor;
typedef int32_t GGLcoord;
// ----------------------------------------------------------------------------
#define GGL_MAX_VIEWPORT_DIMS 4096
#define GGL_MAX_TEXTURE_SIZE 4096
#define GGL_MAX_ALIASED_POINT_SIZE 0x7FFFFFF
#define GGL_MAX_SMOOTH_POINT_SIZE 2048
#define GGL_MAX_SMOOTH_LINE_WIDTH 2048
// ----------------------------------------------------------------------------
// All these names are compatible with their OpenGL equivalents
// some of them are listed only for completeness
enum GGLNames {
GGL_FALSE = 0,
GGL_TRUE = 1,
// enable/disable
GGL_SCISSOR_TEST = 0x0C11,
GGL_TEXTURE_2D = 0x0DE1,
GGL_ALPHA_TEST = 0x0BC0,
GGL_BLEND = 0x0BE2,
GGL_COLOR_LOGIC_OP = 0x0BF2,
GGL_DITHER = 0x0BD0,
GGL_STENCIL_TEST = 0x0B90,
GGL_DEPTH_TEST = 0x0B71,
GGL_AA = 0x80000001,
GGL_W_LERP = 0x80000004,
GGL_POINT_SMOOTH_NICE = 0x80000005,
// buffers, pixel drawing/reading
GGL_COLOR = 0x1800,
// fog
GGL_FOG = 0x0B60,
// shade model
GGL_FLAT = 0x1D00,
GGL_SMOOTH = 0x1D01,
// Texture parameter name
GGL_TEXTURE_MIN_FILTER = 0x2801,
GGL_TEXTURE_MAG_FILTER = 0x2800,
GGL_TEXTURE_WRAP_S = 0x2802,
GGL_TEXTURE_WRAP_T = 0x2803,
GGL_TEXTURE_WRAP_R = 0x2804,
// Texture Filter
GGL_NEAREST = 0x2600,
GGL_LINEAR = 0x2601,
GGL_NEAREST_MIPMAP_NEAREST = 0x2700,
GGL_LINEAR_MIPMAP_NEAREST = 0x2701,
GGL_NEAREST_MIPMAP_LINEAR = 0x2702,
GGL_LINEAR_MIPMAP_LINEAR = 0x2703,
// Texture Wrap Mode
GGL_CLAMP = 0x2900,
GGL_REPEAT = 0x2901,
GGL_CLAMP_TO_EDGE = 0x812F,
// Texture Env Mode
GGL_REPLACE = 0x1E01,
GGL_MODULATE = 0x2100,
GGL_DECAL = 0x2101,
GGL_ADD = 0x0104,
// Texture Env Parameter
GGL_TEXTURE_ENV_MODE = 0x2200,
GGL_TEXTURE_ENV_COLOR = 0x2201,
// Texture Env Target
GGL_TEXTURE_ENV = 0x2300,
// Texture coord generation
GGL_TEXTURE_GEN_MODE = 0x2500,
GGL_S = 0x2000,
GGL_T = 0x2001,
GGL_R = 0x2002,
GGL_Q = 0x2003,
GGL_ONE_TO_ONE = 0x80000002,
GGL_AUTOMATIC = 0x80000003,
// AlphaFunction
GGL_NEVER = 0x0200,
GGL_LESS = 0x0201,
GGL_EQUAL = 0x0202,
GGL_LEQUAL = 0x0203,
GGL_GREATER = 0x0204,
GGL_NOTEQUAL = 0x0205,
GGL_GEQUAL = 0x0206,
GGL_ALWAYS = 0x0207,
// LogicOp
GGL_CLEAR = 0x1500, // 0
GGL_AND = 0x1501, // s & d
GGL_AND_REVERSE = 0x1502, // s & ~d
GGL_COPY = 0x1503, // s
GGL_AND_INVERTED = 0x1504, // ~s & d
GGL_NOOP = 0x1505, // d
GGL_XOR = 0x1506, // s ^ d
GGL_OR = 0x1507, // s | d
GGL_NOR = 0x1508, // ~(s | d)
GGL_EQUIV = 0x1509, // ~(s ^ d)
GGL_INVERT = 0x150A, // ~d
GGL_OR_REVERSE = 0x150B, // s | ~d
GGL_COPY_INVERTED = 0x150C, // ~s
GGL_OR_INVERTED = 0x150D, // ~s | d
GGL_NAND = 0x150E, // ~(s & d)
GGL_SET = 0x150F, // 1
// blending equation & function
GGL_ZERO = 0, // SD
GGL_ONE = 1, // SD
GGL_SRC_COLOR = 0x0300, // D
GGL_ONE_MINUS_SRC_COLOR = 0x0301, // D
GGL_SRC_ALPHA = 0x0302, // SD
GGL_ONE_MINUS_SRC_ALPHA = 0x0303, // SD
GGL_DST_ALPHA = 0x0304, // SD
GGL_ONE_MINUS_DST_ALPHA = 0x0305, // SD
GGL_DST_COLOR = 0x0306, // S
GGL_ONE_MINUS_DST_COLOR = 0x0307, // S
GGL_SRC_ALPHA_SATURATE = 0x0308, // S
// clear bits
GGL_DEPTH_BUFFER_BIT = 0x00000100,
GGL_STENCIL_BUFFER_BIT = 0x00000400,
GGL_COLOR_BUFFER_BIT = 0x00004000,
// errors
GGL_NO_ERROR = 0,
GGL_INVALID_ENUM = 0x0500,
GGL_INVALID_VALUE = 0x0501,
GGL_INVALID_OPERATION = 0x0502,
GGL_STACK_OVERFLOW = 0x0503,
GGL_STACK_UNDERFLOW = 0x0504,
GGL_OUT_OF_MEMORY = 0x0505
};
// ----------------------------------------------------------------------------
typedef struct {
GGLsizei version; // always set to sizeof(GGLSurface)
GGLuint width; // width in pixels
GGLuint height; // height in pixels
GGLint stride; // stride in pixels
GGLubyte* data; // pointer to the bits
GGLubyte format; // pixel format
GGLubyte rfu[3]; // must be zero
// these values are dependent on the used format
union {
GGLint compressedFormat;
GGLint vstride;
};
void* reserved;
} GGLSurface;
typedef struct {
// immediate rendering
void (*pointx)(void *con, const GGLcoord* v, GGLcoord r);
void (*linex)(void *con,
const GGLcoord* v0, const GGLcoord* v1, GGLcoord width);
void (*recti)(void* c, GGLint l, GGLint t, GGLint r, GGLint b);
void (*trianglex)(void* c,
GGLcoord const* v0, GGLcoord const* v1, GGLcoord const* v2);
// scissor
void (*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizei height);
// Set the textures and color buffers
void (*activeTexture)(void* c, GGLuint tmu);
void (*bindTexture)(void* c, const GGLSurface* surface);
void (*colorBuffer)(void* c, const GGLSurface* surface);
void (*readBuffer)(void* c, const GGLSurface* surface);
void (*depthBuffer)(void* c, const GGLSurface* surface);
void (*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);
// enable/disable features
void (*enable)(void* c, GGLenum name);
void (*disable)(void* c, GGLenum name);
void (*enableDisable)(void* c, GGLenum name, GGLboolean en);
// specify the fragment's color
void (*shadeModel)(void* c, GGLenum mode);
void (*color4xv)(void* c, const GGLclampx* color);
// specify color iterators (16.16)
void (*colorGrad12xv)(void* c, const GGLcolor* grad);
// specify Z coordinate iterators (0.32)
void (*zGrad3xv)(void* c, const GGLfixed32* grad);
// specify W coordinate iterators (16.16)
void (*wGrad3xv)(void* c, const GGLfixed* grad);
// specify fog iterator & color (16.16)
void (*fogGrad3xv)(void* c, const GGLfixed* grad);
void (*fogColor3xv)(void* c, const GGLclampx* color);
// specify blending parameters
void (*blendFunc)(void* c, GGLenum src, GGLenum dst);
void (*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,
GGLenum srcAlpha, GGLenum dstAplha);
// texture environnement (REPLACE / MODULATE / DECAL / BLEND)
void (*texEnvi)(void* c, GGLenum target,
GGLenum pname,
GGLint param);
void (*texEnvxv)(void* c, GGLenum target,
GGLenum pname, const GGLfixed* params);
// texture parameters (Wrapping, filter)
void (*texParameteri)(void* c, GGLenum target,
GGLenum pname,
GGLint param);
// texture iterators (16.16)
void (*texCoord2i)(void* c, GGLint s, GGLint t);
void (*texCoord2x)(void* c, GGLfixed s, GGLfixed t);
// s, dsdx, dsdy, scale, t, dtdx, dtdy, tscale
// This api uses block floating-point for S and T texture coordinates.
// All values are given in 16.16, scaled by 'scale'. In other words,
// set scale to 0, for 16.16 values.
void (*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);
void (*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);
// masking
void (*colorMask)(void* c, GGLboolean red,
GGLboolean green,
GGLboolean blue,
GGLboolean alpha);
void (*depthMask)(void* c, GGLboolean flag);
void (*stencilMask)(void* c, GGLuint mask);
// alpha func
void (*alphaFuncx)(void* c, GGLenum func, GGLclampx ref);
// depth func
void (*depthFunc)(void* c, GGLenum func);
// logic op
void (*logicOp)(void* c, GGLenum opcode);
// clear
void (*clear)(void* c, GGLbitfield mask);
void (*clearColorx)(void* c,
GGLclampx r, GGLclampx g, GGLclampx b, GGLclampx a);
void (*clearDepthx)(void* c, GGLclampx depth);
void (*clearStencil)(void* c, GGLint s);
// framebuffer operations
void (*copyPixels)(void* c, GGLint x, GGLint y,
GGLsizei width, GGLsizei height, GGLenum type);
void (*rasterPos2x)(void* c, GGLfixed x, GGLfixed y);
void (*rasterPos2i)(void* c, GGLint x, GGLint y);
} GGLContext;
// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
// construct / destroy the context
ssize_t gglInit(GGLContext** context);
ssize_t gglUninit(GGLContext* context);
GGLint gglBitBlit(
GGLContext* c,
int tmu,
GGLint crop[4],
GGLint where[4]);
#ifdef __cplusplus
};
#endif
// ----------------------------------------------------------------------------
#endif // ANDROID_PIXELFLINGER_H
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_GGL_CONTEXT_H
#define ANDROID_GGL_CONTEXT_H
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <endian.h>
#include <pixelflinger/pixelflinger.h>
#include <private/pixelflinger/ggl_fixed.h>
namespace android {
// ----------------------------------------------------------------------------
#if BYTE_ORDER == LITTLE_ENDIAN
inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
return v;
}
inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
return v;
}
#else
inline uint32_t GGL_RGBA_TO_HOST(uint32_t v) {
#if defined(__mips__) && __mips==32 && __mips_isa_rev>=2
uint32_t r;
__asm__("wsbh %0, %1;"
"rotr %0, %0, 16"
: "=r" (r)
: "r" (v)
);
return r;
#else
return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
#endif
}
inline uint32_t GGL_HOST_TO_RGBA(uint32_t v) {
#if defined(__mips__) && __mips==32 && __mips_isa_rev>=2
uint32_t r;
__asm__("wsbh %0, %1;"
"rotr %0, %0, 16"
: "=r" (r)
: "r" (v)
);
return r;
#else
return (v<<24) | (v>>24) | ((v<<8)&0xff0000) | ((v>>8)&0xff00);
#endif
}
#endif
// ----------------------------------------------------------------------------
const int GGL_DITHER_BITS = 6; // dither weights stored on 6 bits
const int GGL_DITHER_ORDER_SHIFT= 3;
const int GGL_DITHER_ORDER = (1<<GGL_DITHER_ORDER_SHIFT);
const int GGL_DITHER_SIZE = GGL_DITHER_ORDER * GGL_DITHER_ORDER;
const int GGL_DITHER_MASK = GGL_DITHER_ORDER-1;
// ----------------------------------------------------------------------------
const int GGL_SUBPIXEL_BITS = 4;
// TRI_FRACTION_BITS defines the number of bits we want to use
// for the sub-pixel coordinates during the edge stepping, the
// value shouldn't be more than 7, or bad things are going to
// happen when drawing large triangles (8 doesn't work because
// 32 bit muls will loose the sign bit)
#define TRI_FRACTION_BITS (GGL_SUBPIXEL_BITS)
#define TRI_ONE (1 << TRI_FRACTION_BITS)
#define TRI_HALF (1 << (TRI_FRACTION_BITS-1))
#define TRI_FROM_INT(x) ((x) << TRI_FRACTION_BITS)
#define TRI_FRAC(x) ((x) & (TRI_ONE-1))
#define TRI_FLOOR(x) ((x) & ~(TRI_ONE-1))
#define TRI_CEIL(x) (((x) + (TRI_ONE-1)) & ~(TRI_ONE-1))
#define TRI_ROUND(x) (((x) + TRI_HALF ) & ~(TRI_ONE-1))
#define TRI_ROUDNING (1 << (16 - TRI_FRACTION_BITS - 1))
#define TRI_FROM_FIXED(x) (((x)+TRI_ROUDNING) >> (16-TRI_FRACTION_BITS))
#define TRI_SNAP_NEXT_HALF(x) (TRI_CEIL((x)+TRI_HALF) - TRI_HALF)
#define TRI_SNAP_PREV_HALF(x) (TRI_CEIL((x)-TRI_HALF) - TRI_HALF)
// ----------------------------------------------------------------------------
const int GGL_COLOR_BITS = 24;
// To maintain 8-bits color chanels, with a maximum GGLSurface
// size of 4096 and GGL_SUBPIXEL_BITS=4, we need 8 + 12 + 4 = 24 bits
// for encoding the color iterators
inline GGLcolor gglFixedToIteratedColor(GGLfixed c) {
return (c << 8) - c;
}
// ----------------------------------------------------------------------------
template<bool> struct CTA;
template<> struct CTA<true> { };
#define GGL_CONTEXT(con, c) context_t *con = static_cast<context_t *>(c)
#define GGL_OFFSETOF(field) uintptr_t(&(((context_t*)0)->field))
#define GGL_INIT_PROC(p, f) p.f = ggl_ ## f;
#define GGL_BETWEEN(x, L, H) (uint32_t((x)-(L)) <= ((H)-(L)))
#define ggl_likely(x) __builtin_expect(!!(x), 1)
#define ggl_unlikely(x) __builtin_expect(!!(x), 0)
const int GGL_TEXTURE_UNIT_COUNT = 2;
const int GGL_TMU_STATE = 0x00000001;
const int GGL_CB_STATE = 0x00000002;
const int GGL_PIXEL_PIPELINE_STATE = 0x00000004;
// ----------------------------------------------------------------------------
#define GGL_RESERVE_NEEDS(name, l, s) \
const uint32_t GGL_NEEDS_##name##_MASK = (((1LU<<(s))-1)<<l); \
const uint32_t GGL_NEEDS_##name##_SHIFT = (l);
#define GGL_BUILD_NEEDS(val, name) \
(((val)<<(GGL_NEEDS_##name##_SHIFT)) & GGL_NEEDS_##name##_MASK)
#define GGL_READ_NEEDS(name, n) \
(uint32_t(n & GGL_NEEDS_##name##_MASK) >> GGL_NEEDS_##name##_SHIFT)
#define GGL_NEED_MASK(name) (uint32_t(GGL_NEEDS_##name##_MASK))
#define GGL_NEED(name, val) GGL_BUILD_NEEDS(val, name)
GGL_RESERVE_NEEDS( CB_FORMAT, 0, 6 )
GGL_RESERVE_NEEDS( SHADE, 6, 1 )
GGL_RESERVE_NEEDS( W, 7, 1 )
GGL_RESERVE_NEEDS( BLEND_SRC, 8, 4 )
GGL_RESERVE_NEEDS( BLEND_DST, 12, 4 )
GGL_RESERVE_NEEDS( BLEND_SRCA, 16, 4 )
GGL_RESERVE_NEEDS( BLEND_DSTA, 20, 4 )
GGL_RESERVE_NEEDS( LOGIC_OP, 24, 4 )
GGL_RESERVE_NEEDS( MASK_ARGB, 28, 4 )
GGL_RESERVE_NEEDS( P_ALPHA_TEST, 0, 3 )
GGL_RESERVE_NEEDS( P_AA, 3, 1 )
GGL_RESERVE_NEEDS( P_DEPTH_TEST, 4, 3 )
GGL_RESERVE_NEEDS( P_MASK_Z, 7, 1 )
GGL_RESERVE_NEEDS( P_DITHER, 8, 1 )
GGL_RESERVE_NEEDS( P_FOG, 9, 1 )
GGL_RESERVE_NEEDS( P_RESERVED1, 10,22 )
GGL_RESERVE_NEEDS( T_FORMAT, 0, 6 )
GGL_RESERVE_NEEDS( T_RESERVED0, 6, 1 )
GGL_RESERVE_NEEDS( T_POT, 7, 1 )
GGL_RESERVE_NEEDS( T_S_WRAP, 8, 2 )
GGL_RESERVE_NEEDS( T_T_WRAP, 10, 2 )
GGL_RESERVE_NEEDS( T_ENV, 12, 3 )
GGL_RESERVE_NEEDS( T_LINEAR, 15, 1 )
const int GGL_NEEDS_WRAP_CLAMP_TO_EDGE = 0;
const int GGL_NEEDS_WRAP_REPEAT = 1;
const int GGL_NEEDS_WRAP_11 = 2;
inline uint32_t ggl_wrap_to_needs(uint32_t e) {
switch (e) {
case GGL_CLAMP: return GGL_NEEDS_WRAP_CLAMP_TO_EDGE;
case GGL_REPEAT: return GGL_NEEDS_WRAP_REPEAT;
}
return 0;
}
inline uint32_t ggl_blendfactor_to_needs(uint32_t b) {
if (b <= 1) return b;
return (b & 0xF)+2;
}
inline uint32_t ggl_needs_to_blendfactor(uint32_t n) {
if (n <= 1) return n;
return (n - 2) + 0x300;
}
inline uint32_t ggl_env_to_needs(uint32_t e) {
switch (e) {
case GGL_REPLACE: return 0;
case GGL_MODULATE: return 1;
case GGL_DECAL: return 2;
case GGL_BLEND: return 3;
case GGL_ADD: return 4;
}
return 0;
}
inline uint32_t ggl_needs_to_env(uint32_t n) {
const uint32_t envs[] = { GGL_REPLACE, GGL_MODULATE,
GGL_DECAL, GGL_BLEND, GGL_ADD };
return envs[n];
}
// ----------------------------------------------------------------------------
enum {
GGL_ENABLE_BLENDING = 0x00000001,
GGL_ENABLE_SMOOTH = 0x00000002,
GGL_ENABLE_AA = 0x00000004,
GGL_ENABLE_LOGIC_OP = 0x00000008,
GGL_ENABLE_ALPHA_TEST = 0x00000010,
GGL_ENABLE_SCISSOR_TEST = 0x00000020,
GGL_ENABLE_TMUS = 0x00000040,
GGL_ENABLE_DEPTH_TEST = 0x00000080,
GGL_ENABLE_STENCIL_TEST = 0x00000100,
GGL_ENABLE_W = 0x00000200,
GGL_ENABLE_DITHER = 0x00000400,
GGL_ENABLE_FOG = 0x00000800,
GGL_ENABLE_POINT_AA_NICE= 0x00001000
};
// ----------------------------------------------------------------------------
class needs_filter_t;
struct needs_t {
inline int match(const needs_filter_t& filter);
inline bool operator == (const needs_t& rhs) const {
return (n==rhs.n) &&
(p==rhs.p) &&
(t[0]==rhs.t[0]) &&
(t[1]==rhs.t[1]);
}
inline bool operator != (const needs_t& rhs) const {
return !operator == (rhs);
}
uint32_t n;
uint32_t p;
uint32_t t[GGL_TEXTURE_UNIT_COUNT];
};
inline int compare_type(const needs_t& lhs, const needs_t& rhs) {
return memcmp(&lhs, &rhs, sizeof(needs_t));
}
struct needs_filter_t {
needs_t value;
needs_t mask;
};
int needs_t::match(const needs_filter_t& filter) {
uint32_t result =
((filter.value.n ^ n) & filter.mask.n) |
((filter.value.p ^ p) & filter.mask.p) |
((filter.value.t[0] ^ t[0]) & filter.mask.t[0]) |
((filter.value.t[1] ^ t[1]) & filter.mask.t[1]);
return (result == 0);
}
// ----------------------------------------------------------------------------
struct context_t;
class Assembly;
struct blend_state_t {
uint32_t src;
uint32_t dst;
uint32_t src_alpha;
uint32_t dst_alpha;
uint8_t reserved;
uint8_t alpha_separate;
uint8_t operation;
uint8_t equation;
};
struct mask_state_t {
uint8_t color;
uint8_t depth;
uint32_t stencil;
};
struct clear_state_t {
GGLclampx r;
GGLclampx g;
GGLclampx b;
GGLclampx a;
GGLclampx depth;
GGLint stencil;
uint32_t colorPacked;
uint32_t depthPacked;
uint32_t stencilPacked;
uint32_t dirty;
};
struct fog_state_t {
uint8_t color[4];
};
struct logic_op_state_t {
uint16_t opcode;
};
struct alpha_test_state_t {
uint16_t func;
GGLcolor ref;
};
struct depth_test_state_t {
uint16_t func;
GGLclampx clearValue;
};
struct scissor_t {
uint32_t user_left;
uint32_t user_right;
uint32_t user_top;
uint32_t user_bottom;
uint32_t left;
uint32_t right;
uint32_t top;
uint32_t bottom;
};
struct pixel_t {
uint32_t c[4];
uint8_t s[4];
};
struct surface_t {
union {
GGLSurface s;
// Keep the following struct field types in line with the corresponding
// GGLSurface fields to avoid mismatches leading to errors.
struct {
GGLsizei reserved;
GGLuint width;
GGLuint height;
GGLint stride;
GGLubyte* data;
GGLubyte format;
GGLubyte dirty;
GGLubyte pad[2];
};
};
void (*read) (const surface_t* s, context_t* c,
uint32_t x, uint32_t y, pixel_t* pixel);
void (*write)(const surface_t* s, context_t* c,
uint32_t x, uint32_t y, const pixel_t* pixel);
};
// ----------------------------------------------------------------------------
struct texture_shade_t {
union {
struct {
int32_t is0;
int32_t idsdx;
int32_t idsdy;
int sscale;
int32_t it0;
int32_t idtdx;
int32_t idtdy;
int tscale;
};
struct {
int32_t v;
int32_t dx;
int32_t dy;
int scale;
} st[2];
};
};
struct texture_iterators_t {
// these are not encoded in the same way than in the
// texture_shade_t structure
union {
struct {
GGLfixed ydsdy;
GGLfixed dsdx;
GGLfixed dsdy;
int sscale;
GGLfixed ydtdy;
GGLfixed dtdx;
GGLfixed dtdy;
int tscale;
};
struct {
GGLfixed ydvdy;
GGLfixed dvdx;
GGLfixed dvdy;
int scale;
} st[2];
};
};
struct texture_t {
surface_t surface;
texture_iterators_t iterators;
texture_shade_t shade;
uint32_t s_coord;
uint32_t t_coord;
uint16_t s_wrap;
uint16_t t_wrap;
uint16_t min_filter;
uint16_t mag_filter;
uint16_t env;
uint8_t env_color[4];
uint8_t enable;
uint8_t dirty;
};
struct raster_t {
GGLfixed x;
GGLfixed y;
};
struct framebuffer_t {
surface_t color;
surface_t read;
surface_t depth;
surface_t stencil;
int16_t *coverage;
size_t coverageBufferSize;
};
// ----------------------------------------------------------------------------
struct iterators_t {
int32_t xl;
int32_t xr;
int32_t y;
GGLcolor ydady;
GGLcolor ydrdy;
GGLcolor ydgdy;
GGLcolor ydbdy;
GGLfixed ydzdy;
GGLfixed ydwdy;
GGLfixed ydfdy;
};
struct shade_t {
GGLcolor a0;
GGLcolor dadx;
GGLcolor dady;
GGLcolor r0;
GGLcolor drdx;
GGLcolor drdy;
GGLcolor g0;
GGLcolor dgdx;
GGLcolor dgdy;
GGLcolor b0;
GGLcolor dbdx;
GGLcolor dbdy;
uint32_t z0;
GGLfixed32 dzdx;
GGLfixed32 dzdy;
GGLfixed w0;
GGLfixed dwdx;
GGLfixed dwdy;
uint32_t f0;
GGLfixed dfdx;
GGLfixed dfdy;
};
// these are used in the generated code
// we use this mirror structure to improve
// data locality in the pixel pipeline
struct generated_tex_vars_t {
uint32_t width;
uint32_t height;
uint32_t stride;
uintptr_t data;
int32_t dsdx;
int32_t dtdx;
int32_t spill[2];
};
struct generated_vars_t {
struct {
int32_t c;
int32_t dx;
} argb[4];
int32_t aref;
int32_t dzdx;
int32_t zbase;
int32_t f;
int32_t dfdx;
int32_t spill[3];
generated_tex_vars_t texture[GGL_TEXTURE_UNIT_COUNT];
int32_t rt;
int32_t lb;
};
// ----------------------------------------------------------------------------
struct state_t {
framebuffer_t buffers;
texture_t texture[GGL_TEXTURE_UNIT_COUNT];
scissor_t scissor;
raster_t raster;
blend_state_t blend;
alpha_test_state_t alpha_test;
depth_test_state_t depth_test;
mask_state_t mask;
clear_state_t clear;
fog_state_t fog;
logic_op_state_t logic_op;
uint32_t enables;
uint32_t enabled_tmu;
needs_t needs;
};
// ----------------------------------------------------------------------------
struct context_t {
GGLContext procs;
state_t state;
shade_t shade;
iterators_t iterators;
generated_vars_t generated_vars __attribute__((aligned(32)));
uint8_t ditherMatrix[GGL_DITHER_SIZE] __attribute__((aligned(32)));
uint32_t packed;
uint32_t packed8888;
const GGLFormat* formats;
uint32_t dirty;
texture_t* activeTMU;
uint32_t activeTMUIndex;
void (*init_y)(context_t* c, int32_t y);
void (*step_y)(context_t* c);
void (*scanline)(context_t* c);
void (*span)(context_t* c);
void (*rect)(context_t* c, size_t yc);
void* base;
Assembly* scanline_as;
GGLenum error;
};
// ----------------------------------------------------------------------------
void ggl_init_context(context_t* context);
void ggl_uninit_context(context_t* context);
void ggl_error(context_t* c, GGLenum error);
int64_t ggl_system_time();
// ----------------------------------------------------------------------------
};
#endif // ANDROID_GGL_CONTEXT_H
This diff is collapsed.
......@@ -58,6 +58,28 @@ enum {
HAL_PIXEL_FORMAT_RGB_565 = 4,
HAL_PIXEL_FORMAT_BGRA_8888 = 5,
/*
* sRGB color pixel formats:
*
* The red, green and blue components are stored in sRGB space, and converted
* to linear space when read, using the standard sRGB to linear equation:
*
* Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
* = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
*
* When written the inverse transformation is performed:
*
* Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
* = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
*
*
* The alpha component, if present, is always stored in linear space and
* is left unmodified when read or written.
*
*/
HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC,
HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD,
/*
* 0x100 - 0x1FF
*
......@@ -189,6 +211,7 @@ enum {
* extra metadata to define.
*/
HAL_PIXEL_FORMAT_RAW16 = 0x20,
HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, // TODO(rubenbrunk): Remove RAW_SENSOR.
/*
* Android RAW10 format:
......@@ -440,6 +463,11 @@ enum {
HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16
HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21
HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2
HAL_PIXEL_FORMAT_YCrCb_NV12 = 0x15, // YUY2
HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO = 0x16,
HAL_PIXEL_FORMAT_YCrCb_NV12_10 = 0x17, // YUY2_1obit
HAL_PIXEL_FORMAT_YCbCr_422_SP_10 = 0x18, //
HAL_PIXEL_FORMAT_YCrCb_420_SP_10 = 0x19, //
};
/*
......
......@@ -4,7 +4,7 @@ LOCAL_PATH:= $(call my-dir)
# --
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
ifneq (,$(filter userdebug eng user,$(TARGET_BUILD_VARIANT)))
init_options += -DALLOW_LOCAL_PROP_OVERRIDE=1 -DALLOW_DISABLE_SELINUX=1
else
init_options += -DALLOW_LOCAL_PROP_OVERRIDE=0 -DALLOW_DISABLE_SELINUX=0
......@@ -12,6 +12,26 @@ endif
init_options += -DLOG_UEVENTS=0
ifeq ($(strip $(TARGET_BOARD_PLATFORM)), rk3288)
init_options += -DTARGET_BOARD_PLATFORM_RK3288
endif
ifeq ($(strip $(TARGET_BOARD_PLATFORM)), sofia3gr)
init_options += -DTARGET_BOARD_PLATFORM_SOFIA3GR
endif
ifeq ($(strip $(TARGET_BOARD_PLATFORM)), rk3368)
init_options += -DTARGET_BOARD_PLATFORM_RK3368
endif
ifeq ($(strip $(TARGET_BOARD_PLATFORM)), rk312x)
init_options += -DTARGET_BOARD_PLATFORM_RK312x
endif
ifeq ($(strip $(TARGET_BOARD_PLATFORM_PRODUCT)), box)
LOCAL_CFLAGS += -DTARGET_BOARD_PLATFORM_PRODUCT_BOX
endif
ifeq ($(strip $(TARGET_DISASTER_RECOVERY)), true)
LOCAL_CFLAGS += -DTARGET_DISASTER_RECOVERY
endif
init_cflags += \
$(init_options) \
-Wall -Wextra \
......@@ -74,7 +94,8 @@ LOCAL_STATIC_LIBRARIES := \
libc++_static \
libdl \
libsparse_static \
libz
libz \
libunwind_llvm
# Create symlinks
LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \
......
......@@ -69,6 +69,8 @@ struct selabel_handle *sehandle_prop;
static int property_triggers_enabled = 0;
static char bootmode[32];
static char hardware[32];
static char qemu[32];
static struct action *cur_action = NULL;
......@@ -84,6 +86,25 @@ bool waiting_for_exec = false;
static int epoll_fd = -1;
static int
unix_read(int fd, void* buff, int len) {
int ret;
do { ret = read(fd, buff, len); } while (ret < 0 && errno == EINTR);
return ret;
}
static int
proc_read(const char* filename, char* buff, size_t buffsize) {
int len = 0;
int fd = open(filename, O_RDONLY);
if (fd >= 0) {
len = unix_read(fd, buff, buffsize-1);
close(fd);
}
buff[len > 0 ? len : 0] = 0;
return len;
}
void register_epoll_handler(int fd, void (*fn)()) {
epoll_event ev;
ev.events = EPOLLIN;
......@@ -793,24 +814,85 @@ static void import_kernel_nv(char *name, bool for_emulator)
}
}
static void symlink_fstab() {
char fstab_path[255] = "/fstab.";
char fstab_default_path[50] = "/fstab.";
int ret = -1;
//such as: fstab.rk30board.bootmode.unknown
strcat(fstab_path, hardware);
strcat(fstab_path, ".bootmode.");
strcat(fstab_path, bootmode);
strcat(fstab_default_path, hardware);
ret = symlink(fstab_path, fstab_default_path);
if (ret < 0) {
ERROR("%s : failed", __func__);
}
}
static void export_kernel_boot_props() {
char tmp[PROP_VALUE_MAX];
int ret;
char cmdline[1024];
char* s1;
char* s2;
struct {
const char *src_prop;
const char *dst_prop;
const char *default_value;
} prop_map[] = {
{ "ro.boot.serialno", "ro.serialno", "", },
#ifdef TARGET_BOARD_PLATFORM_SOFIA3GR
{ "ro.boot.serialno", "ro.serialno", "", },
#endif
{ "ro.boot.mode", "ro.bootmode", "unknown", },
{ "ro.boot.baseband", "ro.baseband", "unknown", },
{ "ro.boot.bootloader", "ro.bootloader", "unknown", },
{ "ro.boot.hardware", "ro.hardware", "unknown", },
{ "ro.boot.revision", "ro.revision", "0", },
};
//if storagemedia is emmc, so we will wait emmc init finish
for (int i = 0; i < EMMC_RETRY_COUNT; i++) {
proc_read( "/proc/cmdline", cmdline, sizeof(cmdline) );
s1 = strstr(cmdline, STORAGE_MEDIA);
s2 = strstr(cmdline, "androidboot.mode=emmc");
if(s1 == NULL){
//storagemedia is unknow
break;
}
if ((s1 > 0) && (s2 > 0)) {
ERROR("OK,EMMC DRIVERS INIT OK\n");
property_set("ro.boot.mode", "emmc");
break;
} else {
ERROR("OK,EMMC DRIVERS NOT READY, RERRY=%d\n", i);
sleep(1);
}
}
for (size_t i = 0; i < ARRAY_SIZE(prop_map); i++) {
char value[PROP_VALUE_MAX];
int rc = property_get(prop_map[i].src_prop, value);
property_set(prop_map[i].dst_prop, (rc > 0) ? value : prop_map[i].default_value);
}
/* save a copy for init's usage during boot */
property_get("ro.bootmode", tmp);
strlcpy(bootmode, tmp, sizeof(bootmode));
/* if this was given on kernel command line, override what we read
* before (e.g. from /proc/cpuinfo), if anything */
ret = property_get("ro.boot.hardware", tmp);
if (ret)
strlcpy(hardware, tmp, sizeof(hardware));
property_set("ro.hardware", hardware);
symlink_fstab();
}
static void process_kernel_dt(void)
......@@ -986,6 +1068,162 @@ static void selinux_initialize(bool in_kernel_domain) {
}
}
#ifdef TARGET_BOARD_PLATFORM_RK312x
static void rk_312x_set_cpu(void)
{
int fd;
char buf[128];
char value[16]={"1200000"};
bool can_set_cpu = false;
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies",O_RDONLY);
if (fd >= 0) {
int n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
buf[n-1] = '\0';
//check whether 1.2G in the freqs table
if(strstr(buf,value)){
can_set_cpu = true;
}
// ERROR("available_frequencies %s \n",buf);
}
close(fd);
}else{
ERROR("error to open scaling_available_frequencies");
}
//first set write permission to root
chmod("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", 0644);
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",O_RDWR);
if (fd >= 0) {
if(can_set_cpu){
write(fd, value, strlen(value));
}//if(can_set_cpu)
close(fd);
}//if (fd >= 0)
}
#endif
#ifdef TARGET_BOARD_PLATFORM_RK3288
static void rk_3288_set_cpu(void)
{
int fd;
char buf[128];
char value[16]={"1512000"};//1416000 1512000 1608000
bool can_set_cpu = false;
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies",O_RDONLY);
if (fd >= 0) {
int n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
buf[n-1] = '\0';
//check whether 1.4G in the freqs table
if(strstr(buf,value)){
can_set_cpu = true;
}
// ERROR("available_frequencies %s \n",buf);
}
close(fd);
}else{
ERROR("error to open scaling_available_frequencies");
}
//first set write permission to root
chmod("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", 0644);
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",O_RDWR);
if (fd >= 0) {
if(can_set_cpu){
write(fd, value, strlen(value));
}//if(can_set_cpu)
close(fd);
}//if (fd >= 0)
}
#endif
#ifdef TARGET_BOARD_PLATFORM_RK3368
static void rk_3368_set_cpu(void)
{
int fd;
char buf[128];
char value[16]={"1200000"};
char value_large[16] = {"1512000"};
bool can_set_cpu = false;
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies",O_RDONLY);
if (fd >= 0) {
int n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
buf[n-1] = '\0';
//check whether 1.2G in the freqs table
if(strstr(buf,value)){
can_set_cpu = true;
}
// ERROR("available_frequencies %s \n",buf);
}
close(fd);
}else{
ERROR("error to open scaling_available_frequencies");
}
//first set write permission to root
chmod("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", 0644);
fd = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq",O_RDWR);
if (fd >= 0) {
if(can_set_cpu){
write(fd, value, strlen(value));
}//if(can_set_cpu)
close(fd);
}//if (fd >= 0)
//set big core
chmod("/sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq", 0644);
fd = open("/sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq",O_RDWR);
if (fd >= 0) {
if(can_set_cpu){
write(fd, value_large, strlen(value_large));
}//if(can_set_cpu)
close(fd);
}//if (fd >= 0)
}
#endif
static void rk_parse_cpu(void)
{
int fd;
char buf[64];
fd = open("/sys/devices/system/cpu/type", O_RDONLY);
if (fd >= 0) {
int n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
if (buf[n-1] == '\n')
n--;
buf[n] = 0;
property_set("ro.rk.cpu", buf);
}
close(fd);
}
fd = open("/sys/devices/system/cpu/soc", O_RDONLY);
if (fd >= 0) {
int n = read(fd, buf, sizeof(buf) - 1);
if (n > 0) {
if (buf[n-1] == '\n')
n--;
buf[n] = 0;
property_set("ro.rk.soc", buf);
}
close(fd);
}
}
int main(int argc, char** argv) {
if (!strcmp(basename(argv[0]), "ueventd")) {
return ueventd_main(argc, argv);
......@@ -999,6 +1237,16 @@ int main(int argc, char** argv) {
umask(0);
add_environment("PATH", _PATH_DEFPATH);
#ifdef TARGET_BOARD_PLATFORM_RK3288
rk_3288_set_cpu();
#else
#ifdef TARGET_BOARD_PLATFORM_RK3368
rk_3368_set_cpu();
#endif
#ifdef TARGET_BOARD_PLATFORM_RK312x
rk_312x_set_cpu();
#endif
#endif
bool is_first_stage = (argc == 1) || (strcmp(argv[1], "--second-stage") != 0);
......@@ -1019,7 +1267,7 @@ int main(int argc, char** argv) {
// to the outside world.
open_devnull_stdio();
klog_init();
klog_set_level(KLOG_NOTICE_LEVEL);
//klog_set_level(KLOG_NOTICE_LEVEL);
NOTICE("init%s started!\n", is_first_stage ? "" : " second stage");
......@@ -1076,6 +1324,7 @@ int main(int argc, char** argv) {
property_load_boot_defaults();
start_property_service();
rk_parse_cpu();
init_parse_config_file("/init.rc");
......
......@@ -92,6 +92,10 @@ struct svcenvinfo {
#define COMMAND_RETRY_TIMEOUT 5
/* IMPORTANT: THE VALUE OF STORAGE_MEDIA MUST BE CONSISTANT WITH UBOOT */
#define EMMC_RETRY_COUNT 20
#define STORAGE_MEDIA "storagemedia=emmc"
struct service {
void NotifyStateChange(const char* new_state);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment