From 2360ad01b787eb7556901b6be3ca27df7ae9f910 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Fri, 19 Sep 2014 10:43:12 +0100 Subject: [PATCH 1/4] init: Let a device's init.rc redefine service entries In case of duplicate service definitions, init.rc's version always wins. This is a less-than-ideal situation and the main reason for some devices to override the default init.rc, which leads to out-of-sync situations whenever we happen to insert something into the main copy. So let services be overridden. To prevent accidental override of system services, use a specific keyword for this, "service_redefine" Change-Id: Ib1cab6bd3008956e9a2f61355781861ef8bcf8ca --- init/init_parser.c | 20 ++++++++++++++------ init/keywords.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/init/init_parser.c b/init/init_parser.c index 1aebf983986..291cf9756a3 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -45,7 +45,7 @@ struct import { const char *filename; }; -static void *parse_service(struct parse_state *state, int nargs, char **args); +static void *parse_service(struct parse_state *state, int nargs, char **args, bool redefine); static void parse_line_service(struct parse_state *state, int nargs, char **args); static void *parse_action(struct parse_state *state, int nargs, char **args); @@ -145,6 +145,7 @@ int lookup_keyword(const char *s) case 's': if (!strcmp(s, "eclabel")) return K_seclabel; if (!strcmp(s, "ervice")) return K_service; + if (!strcmp(s, "ervice_redefine")) return K_service_redefine; if (!strcmp(s, "etcon")) return K_setcon; if (!strcmp(s, "etenforce")) return K_setenforce; if (!strcmp(s, "etenv")) return K_setenv; @@ -328,7 +329,8 @@ void parse_new_section(struct parse_state *state, int kw, nargs > 1 ? args[1] : ""); switch(kw) { case K_service: - state->context = parse_service(state, nargs, args); + case K_service_redefine: + state->context = parse_service(state, nargs, args, (kw == K_service_redefine)); if (state->context) { state->parse_line = parse_line_service; return; @@ -673,7 +675,7 @@ int action_queue_empty() return list_empty(&action_queue); } -static void *parse_service(struct parse_state *state, int nargs, char **args) +static void *parse_service(struct parse_state *state, int nargs, char **args, bool redefine) { struct service *svc; if (nargs < 3) { @@ -686,13 +688,18 @@ static void *parse_service(struct parse_state *state, int nargs, char **args) } svc = service_find_by_name(args[1]); - if (svc) { + if (svc && !redefine) { parse_error(state, "ignored duplicate definition of service '%s'\n", args[1]); return 0; } nargs -= 2; - svc = calloc(1, sizeof(*svc) + sizeof(char*) * nargs); + + if (!svc) { + svc = calloc(1, sizeof(*svc) + sizeof(char*) * nargs); + redefine = false; + } + if (!svc) { parse_error(state, "out of memory\n"); return 0; @@ -704,7 +711,8 @@ static void *parse_service(struct parse_state *state, int nargs, char **args) svc->nargs = nargs; svc->onrestart.name = "onrestart"; list_init(&svc->onrestart.commands); - list_add_tail(&service_list, &svc->slist); + if (!redefine) + list_add_tail(&service_list, &svc->slist); return svc; } diff --git a/init/keywords.h b/init/keywords.h index a62e9f177e5..8b3c089a765 100644 --- a/init/keywords.h +++ b/init/keywords.h @@ -79,6 +79,7 @@ enum { KEYWORD(rmdir, COMMAND, 1, do_rmdir) KEYWORD(seclabel, OPTION, 0, 0) KEYWORD(service, SECTION, 0, 0) + KEYWORD(service_redefine, SECTION, 0, 0) KEYWORD(setcon, COMMAND, 1, do_setcon) KEYWORD(setenforce, COMMAND, 1, do_setenforce) KEYWORD(setenv, OPTION, 2, 0) From 35c2ad035e65a2787f0f8d0876ee709cc679e953 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Tue, 2 Sep 2014 11:18:27 +0100 Subject: [PATCH 2/4] Mediatek platform support Add mtk UIDs and colorformats Change-Id: Icf1b023d39b47cfac96790a0c62a26fe5858b61f --- include/private/android_filesystem_config.h | 5 +++++ include/system/graphics.h | 11 +++++++++++ init/property_service.c | 4 ++++ liblog/logd_write.c | 7 +++++++ rootdir/init.rc | 2 +- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h index 91255a86d02..f89870ffd00 100644 --- a/include/private/android_filesystem_config.h +++ b/include/private/android_filesystem_config.h @@ -115,6 +115,9 @@ #define AID_MOT_DLNA 9011 /* DLNA native */ #endif // MOTOROLA_UIDS +#define AID_MTKCCCI 9996 +#define AID_NVRAM 9997 + #define AID_MISC 9998 /* access to misc storage */ #define AID_NOBODY 9999 @@ -207,6 +210,8 @@ static const struct android_id_info android_ids[] = { { "mot_dlna", AID_MOT_DLNA, }, #endif { "sensors", AID_SENSORS, }, + { "ccci", AID_MTKCCCI, }, + { "nvram", AID_NVRAM, }, { "misc", AID_MISC, }, { "nobody", AID_NOBODY, }, { "theme_man", AID_THEMEMAN }, diff --git a/include/system/graphics.h b/include/system/graphics.h index fd7b681b804..946073f5315 100644 --- a/include/system/graphics.h +++ b/include/system/graphics.h @@ -90,6 +90,17 @@ enum { * GL_OES_EGL_image_external OpenGL ES extension. */ +#ifdef MTK_HARDWARE + HAL_PIXEL_FORMAT_I420 = 0x00000100, // MTK I420 + HAL_PIXEL_FORMAT_NV12_BLK = 0x00000101, // MTK NV12 block progres + HAL_PIXEL_FORMAT_NV12_BLK_FCM = 0x00000102, // MTK NV12 block field m + + HAL_PIXEL_FORMAT_YUV_PRIVATE = 0x00000103, // I420 or NV12_BLK or NV + + HAL_PIXEL_FORMAT_I420_DI = 0x00000106, // MTK I420 for deinterla + HAL_PIXEL_FORMAT_YV12_DI = 0x00000107, // MTK YV12 for deinterla +#endif + /* * Android YUV format: * diff --git a/init/property_service.c b/init/property_service.c index e80d1544772..38c524813f5 100644 --- a/init/property_service.c +++ b/init/property_service.c @@ -102,6 +102,10 @@ struct { { "wc_transport.", AID_BLUETOOTH, AID_SYSTEM }, { "net.pdp", AID_RADIO, AID_RADIO }, { "service.bootanim.exit", AID_GRAPHICS, 0 }, +#ifdef MTK_HARDWARE + { "nvram_init", AID_NVRAM, 0 }, + { "gps.", AID_GPS, AID_SYSTEM }, +#endif #ifdef PROPERTY_PERMS_APPEND PROPERTY_PERMS_APPEND #endif diff --git a/liblog/logd_write.c b/liblog/logd_write.c index a2b94247fd0..65f3bba22fc 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -267,6 +267,7 @@ int __android_log_write(int prio, const char *tag, const char *msg) !strcmp(tag, "KINETO") || !strncmp(tag, "KIPC", 4) || !strncmp(tag, "Kineto", 6) || + !strncmp(tag, "MUXD", 4) || !strncmp(tag, "QCRIL", 5) || !strncmp(tag, "QC-RIL", 6) || !strncmp(tag, "QC-QMI", 6) || @@ -426,3 +427,9 @@ int __android_log_btwrite(int32_t tag, char type, const void *payload, return write_to_log(LOG_ID_EVENTS, vec, 3); } + +#ifdef MTK_HARDWARE +void __attribute__((weak)) __xlog_buf_printf(void *args) { + return; +} +#endif diff --git a/rootdir/init.rc b/rootdir/init.rc index b431bebc9e8..d3c9e081996 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -549,7 +549,7 @@ service drm /system/bin/drmserver service media /system/bin/mediaserver class main user media - group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc qcom_diag mediadrm + group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc qcom_diag mediadrm nvram ccci radio ioprio rt 4 service bootanim /system/bin/bootanimation From 25a8a126d5d114ac006c64c8e095a628db026917 Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Thu, 20 Nov 2014 15:20:48 +0000 Subject: [PATCH 3/4] mediatek: Add FM source/device ids. Change-Id: I293e77117be37226ccff5bd58bbb98a320eb6731 --- include/system/audio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/system/audio.h b/include/system/audio.h index 052954dec85..667fe4152cd 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -494,6 +494,9 @@ enum { AUDIO_DEVICE_IN_USB_DEVICE = AUDIO_DEVICE_BIT_IN | 0x1000, AUDIO_DEVICE_IN_ANC_HEADSET = AUDIO_DEVICE_BIT_IN | 0x2000, AUDIO_DEVICE_IN_PROXY = AUDIO_DEVICE_BIT_IN | 0x4000, +#ifdef MTK_HARDWARE + AUDIO_DEVICE_IN_FM = AUDIO_DEVICE_BIT_IN | 0x8000, +#endif #ifdef QCOM_HARDWARE AUDIO_DEVICE_IN_FM_RX = AUDIO_DEVICE_BIT_IN | 0x8000, AUDIO_DEVICE_IN_FM_RX_A2DP = AUDIO_DEVICE_BIT_IN | 0x10000, @@ -516,6 +519,9 @@ enum { AUDIO_DEVICE_IN_USB_DEVICE | AUDIO_DEVICE_IN_PROXY | AUDIO_DEVICE_IN_ANC_HEADSET | +#ifdef MTK_HARDWARE + AUDIO_DEVICE_IN_FM | +#endif #ifdef QCOM_HARDWARE AUDIO_DEVICE_IN_FM_RX | AUDIO_DEVICE_IN_FM_RX_A2DP | From dd6712d21ae78df349166f116a87b344b15d1f2d Mon Sep 17 00:00:00 2001 From: Diogo Ferreira Date: Thu, 27 Nov 2014 15:38:45 +0000 Subject: [PATCH 4/4] mediatek: Add MTK pmem symbols Change-Id: I179078a0c50350e9238786d09765cef1bc99841b --- libcutils/Android.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcutils/Android.mk b/libcutils/Android.mk index edb79d62826..60d57c54538 100644 --- a/libcutils/Android.mk +++ b/libcutils/Android.mk @@ -140,6 +140,10 @@ endif LOCAL_C_INCLUDES := $(libcutils_c_includes) $(KERNEL_HEADERS) LOCAL_STATIC_LIBRARIES := liblog LOCAL_CFLAGS += $(targetSmpFlag) + +ifeq ($(BOARD_HAS_MTK_HARDWARE), true) +LOCAL_WHOLE_STATIC_LIBRARIES += libpmem-dev +endif include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS)