From de3e063645fa9e64a8f7fb9ea81fae1249a3737e Mon Sep 17 00:00:00 2001 From: Tellen Yu Date: Wed, 03 Feb 2016 03:04:00 +0000 Subject: rename CTv class to TvPlay class and optimize the code Change-Id: I5ec3facbf0f7f89cbd6d7f7d3d1ac13b804e2a3f --- diff --git a/tv_callback.h b/tv_callback.h index ef97442..f753c6f 100644 --- a/tv_callback.h +++ b/tv_callback.h @@ -1,18 +1,14 @@ #ifndef TV_CALLBACK #define TV_CALLBACK -#include "tvapi/android/tv/CTv.h" -class TvCallback : public CTv::TvIObserver -{ - public: - TvCallback(void* data) - { - mPri = data; - } - ~TvCallback() - { - } - void onTvEvent (int32_t msgType, const Parcel &p); - private: - void* mPri; +#include "tvapi/android/tv/TvPlay.h" +class TvCallback : public TvPlayObserver { +public: + TvCallback(void* data){ mPri = data; } + ~TvCallback() {} + void onTvEvent (int32_t msgType, const Parcel &p); + +private: + void* mPri; }; #endif + diff --git a/tv_input.cpp b/tv_input.cpp index 9eb4781..277349b 100644 --- a/tv_input.cpp +++ b/tv_input.cpp @@ -22,7 +22,7 @@ #include #include -#include "tvapi/android/tv/CTv.h" +#include "tvapi/android/tv/TvPlay.h" #include "tv_callback.h" #include "tvapi/android/include/tvcmd.h" #include @@ -35,190 +35,181 @@ __android_log_print(ANDROID_LOG_DEBUG, "tv_input", __VA_ARGS__); } #ifndef container_of #define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); }) + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - (char *)(&((type *)0)->member)); }) #endif struct sideband_handle_t { - native_handle_t nativeHandle; - int identflag; - int usage; + native_handle_t nativeHandle; + int identflag; + int usage; }; typedef struct tv_input_private { - tv_input_device_t device; - const tv_input_callback_ops_t *callback; - void *callback_data; - CTv *mpTv; - TvCallback *tvcallback; + tv_input_device_t device; + const tv_input_callback_ops_t *callback; + void *callback_data; + TvPlay *mpTv; + TvCallback *tvcallback; } tv_input_private_t; static int notify_ATV_device_available(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id = SOURCE_TV; - event.device_info.type = TV_INPUT_TYPE_TUNER; - event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = SOURCE_TV; + event.device_info.type = TV_INPUT_TYPE_TUNER; + event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_ATV_stream_configurations_change(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id = SOURCE_TV; - event.device_info.type = TV_INPUT_TYPE_TUNER; - event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = SOURCE_TV; + event.device_info.type = TV_INPUT_TYPE_TUNER; + event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_DTV_device_available(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id = SOURCE_DTV; - event.device_info.type = TV_INPUT_TYPE_TUNER; - event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = SOURCE_DTV; + event.device_info.type = TV_INPUT_TYPE_TUNER; + event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_DTV_stream_configurations_change(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id = SOURCE_DTV; - event.device_info.type = TV_INPUT_TYPE_TUNER; - event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = SOURCE_DTV; + event.device_info.type = TV_INPUT_TYPE_TUNER; + event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } void TvIputHal_ChannelConl(tv_input_private_t *priv, int ops_type, int device_id) { - if (priv->mpTv) { - if (ops_type) { - LOGD ( "%s\, OpenSourceSwitchInput id = %d\n", __FUNCTION__, device_id ); - priv->mpTv->StartTv(); - priv->mpTv->SwitchSourceInput((tv_source_input_t) device_id); - } else { - if (priv->mpTv->GetCurrentSourceInput() == device_id) { - LOGD ( "%s\, StopSourceSwitchInput id = %d\n", __FUNCTION__, device_id ); - priv->mpTv->StopTv(); - } - } - } + if (priv->mpTv) { + if (ops_type) { + LOGD ( "%s\, OpenSourceSwitchInput id = %d\n", __FUNCTION__, device_id ); + priv->mpTv->StartTv(); + priv->mpTv->SwitchSourceInput((tv_source_input_t) device_id); + } else if (priv->mpTv->GetCurrentSourceInput() == device_id) { + LOGD ( "%s\, StopSourceSwitchInput id = %d\n", __FUNCTION__, device_id ); + priv->mpTv->StopTv(); + } + } } static int notify_AV_device_available(tv_input_private_t *priv, tv_source_input_t source_input, int type) { - tv_input_event_t event; - event.device_info.device_id = source_input; - event.device_info.type = TV_INPUT_TYPE_COMPONENT; - event.type = type; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = source_input; + event.device_info.type = TV_INPUT_TYPE_COMPONENT; + event.type = type; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_AV_stream_configurations_change(tv_input_private_t *priv, tv_source_input_t source_input) { - tv_input_event_t event; - event.device_info.device_id = source_input; - event.device_info.type = TV_INPUT_TYPE_COMPONENT; - event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = source_input; + event.device_info.type = TV_INPUT_TYPE_COMPONENT; + event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_HDMI_device_available(tv_input_private_t *priv, tv_source_input_t source_input, uint32_t port_id, int type) { - tv_input_event_t event; - event.device_info.device_id = source_input; - event.device_info.type = TV_INPUT_TYPE_HDMI; - event.type = type; - event.device_info.hdmi.port_id = port_id; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = source_input; + event.device_info.type = TV_INPUT_TYPE_HDMI; + event.type = type; + event.device_info.hdmi.port_id = port_id; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } static int notify_HDMI_stream_configurations_change(tv_input_private_t *priv, tv_source_input_t source_input, uint32_t port_id) { - tv_input_event_t event; - event.device_info.device_id = source_input; - event.device_info.type = TV_INPUT_TYPE_HDMI; - event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; - event.device_info.hdmi.port_id = port_id; - event.device_info.audio_type = AUDIO_DEVICE_NONE; - event.device_info.audio_address = NULL; - priv->callback->notify(&priv->device, &event, priv->callback_data); - return 0; + tv_input_event_t event; + event.device_info.device_id = source_input; + event.device_info.type = TV_INPUT_TYPE_HDMI; + event.type = TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED; + event.device_info.hdmi.port_id = port_id; + event.device_info.audio_type = AUDIO_DEVICE_NONE; + event.device_info.audio_address = NULL; + priv->callback->notify(&priv->device, &event, priv->callback_data); + return 0; } - void TvCallback::onTvEvent (int32_t msgType, const Parcel &p) { - tv_input_private_t *priv = (tv_input_private_t *)(mPri); - switch (msgType) { - case SOURCE_CONNECT_CALLBACK: { - int source = p.readInt32(); - int connectState = p.readInt32(); - LOGD("TvCallback::onTvEvent source = %d, status = %d", source, connectState) - if ( connectState == 1) { - switch (source) { - case SOURCE_HDMI1: - case SOURCE_HDMI2: - case SOURCE_HDMI3: { - notify_HDMI_device_available(priv, (tv_source_input_t)source, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, (tv_source_input_t)source, 1); - break; - } - case SOURCE_AV1: - case SOURCE_AV2: { - notify_AV_device_available(priv, (tv_source_input_t)source, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_AV_stream_configurations_change(priv, (tv_source_input_t)source); - break; - } - default: - break; - } - } else {//out - switch (source) { - case SOURCE_HDMI1: - case SOURCE_HDMI2: - case SOURCE_HDMI3: { - notify_HDMI_device_available(priv, (tv_source_input_t)source, 1, TV_INPUT_EVENT_DEVICE_UNAVAILABLE); - break; - } - case SOURCE_AV1: - case SOURCE_AV2: { - notify_AV_device_available(priv, (tv_source_input_t)source, TV_INPUT_EVENT_DEVICE_UNAVAILABLE); - break; - } - default: - break; - } - } - //tv_input_event_t event; - - break; - } - default: - break; - } + tv_input_private_t *priv = (tv_input_private_t *)(mPri); + switch (msgType) { + case SOURCE_CONNECT_CALLBACK: { + int source = p.readInt32(); + int connectState = p.readInt32(); + LOGD("TvCallback::onTvEvent source = %d, status = %d", source, connectState) + + switch (source) { + case SOURCE_HDMI1: + case SOURCE_HDMI2: + case SOURCE_HDMI3: { + if (connectState == 1) { + notify_HDMI_device_available(priv, (tv_source_input_t)source, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, (tv_source_input_t)source, 1); + } + else { + notify_HDMI_device_available(priv, (tv_source_input_t)source, 1, TV_INPUT_EVENT_DEVICE_UNAVAILABLE); + } + } + break; + + case SOURCE_AV1: + case SOURCE_AV2: { + if (connectState == 1) { + notify_AV_device_available(priv, (tv_source_input_t)source, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_AV_stream_configurations_change(priv, (tv_source_input_t)source); + } + else { + notify_AV_device_available(priv, (tv_source_input_t)source, TV_INPUT_EVENT_DEVICE_UNAVAILABLE); + } + } + break; + + default: + break; + } + } + break; + + default: + break; + } } #define NORMAL_STREAM_ID 1 @@ -226,305 +217,298 @@ void TvCallback::onTvEvent (int32_t msgType, const Parcel &p) static tv_stream_config_t mconfig[2]; static int get_stream_configs(int dev_id, int *num_configurations, const tv_stream_config_t **configs) { - switch (dev_id) { - case SOURCE_TV: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - case SOURCE_DTV: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - case SOURCE_AV1: - case SOURCE_AV2: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - case SOURCE_HDMI1: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - case SOURCE_HDMI2: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - case SOURCE_HDMI3: - mconfig[0].stream_id = NORMAL_STREAM_ID; - mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig[0].max_video_width = 1920; - mconfig[0].max_video_height = 1080; - mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; - mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; - mconfig[1].max_video_width = 1920; - mconfig[1].max_video_height = 1080; - *num_configurations = 2; - *configs = mconfig; - break; - default: - break; - } - return 0; + switch (dev_id) { + case SOURCE_TV: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + case SOURCE_DTV: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + case SOURCE_AV1: + case SOURCE_AV2: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + case SOURCE_HDMI1: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + case SOURCE_HDMI2: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + case SOURCE_HDMI3: + mconfig[0].stream_id = NORMAL_STREAM_ID; + mconfig[0].type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig[0].max_video_width = 1920; + mconfig[0].max_video_height = 1080; + mconfig[1].stream_id = FRAME_CAPTURE_STREAM_ID; + mconfig[1].type = TV_STREAM_TYPE_BUFFER_PRODUCER ; + mconfig[1].max_video_width = 1920; + mconfig[1].max_video_height = 1080; + *num_configurations = 2; + *configs = mconfig; + break; + default: + break; + } + return 0; } static int get_tv_stream(tv_stream_t *stream) { - static struct sideband_handle_t *tvstream = NULL; - if (stream->stream_id == NORMAL_STREAM_ID) { - if ( !tvstream ) { - tvstream = (struct sideband_handle_t *)native_handle_create(0, 2); - if ( !tvstream ) { - return -EINVAL; - } - } - tvstream->identflag = 0xabcdcdef; //magic word - tvstream->usage = GRALLOC_USAGE_AML_VIDEO_OVERLAY; - stream->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE; - stream->sideband_stream_source_handle = (native_handle_t *)tvstream; - } else if (stream->stream_id == NORMAL_STREAM_ID) { - stream->type = TV_STREAM_TYPE_BUFFER_PRODUCER; - } - return 0; + static struct sideband_handle_t *tvstream = NULL; + if (stream->stream_id == NORMAL_STREAM_ID) { + if ( !tvstream ) { + tvstream = (struct sideband_handle_t *)native_handle_create(0, 2); + if ( !tvstream ) { + return -EINVAL; + } + } + tvstream->identflag = 0xabcdcdef; //magic word + tvstream->usage = GRALLOC_USAGE_AML_VIDEO_OVERLAY; + stream->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE; + stream->sideband_stream_source_handle = (native_handle_t *)tvstream; + } else if (stream->stream_id == NORMAL_STREAM_ID) { + stream->type = TV_STREAM_TYPE_BUFFER_PRODUCER; + } + return 0; } static int tv_input_device_open(const struct hw_module_t *module, - const char *name, struct hw_device_t **device); + const char *name, struct hw_device_t **device); static struct hw_module_methods_t tv_input_module_methods = { open: - tv_input_device_open + tv_input_device_open }; tv_input_module_t HAL_MODULE_INFO_SYM = { -common: - { -tag: - HARDWARE_MODULE_TAG, - version_major: 0, - version_minor: 1, -id: - TV_INPUT_HARDWARE_MODULE_ID, -name: "TVInput module" - , -author: "Amlogic" - , -methods: - &tv_input_module_methods, - } + common: { + tag: HARDWARE_MODULE_TAG, + version_major: 0, + version_minor: 1, + id: TV_INPUT_HARDWARE_MODULE_ID, + name: "TVInput module", + author: "Amlogic", + methods: &tv_input_module_methods, + } }; /*****************************************************************************/ - static int tv_input_initialize(struct tv_input_device *dev, - const tv_input_callback_ops_t *callback, void *data) + const tv_input_callback_ops_t *callback, void *data) { - if (dev == NULL || callback == NULL) { - return -EINVAL; - } - tv_input_private_t *priv = (tv_input_private_t *)dev; - if (priv->callback != NULL) { - return -EEXIST; - } - priv->callback = callback; - priv->callback_data = data; - /* ATV_DEVICE_AVAILABLE */ - notify_ATV_device_available(priv); - notify_ATV_stream_configurations_change(priv); - /* DTV_DEVICE_AVAILABLE */ - notify_DTV_device_available(priv); - notify_DTV_stream_configurations_change(priv); - - if (priv->mpTv->GetHdmiAvHotplugDetectOnoff()) { - /* AV1_DEVICE_AVAILABLE */ - int status = priv->mpTv->GetSourceConnectStatus(SOURCE_AV1); - if (status == 1) { //IN - notify_AV_device_available(priv, SOURCE_AV1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_AV_stream_configurations_change(priv, SOURCE_AV1); - } - - /* AV2_DEVICE_AVAILABLE */ - status = priv->mpTv->GetSourceConnectStatus(SOURCE_AV2); - if (status == 1) { //IN - notify_AV_device_available(priv, SOURCE_AV2, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_AV_stream_configurations_change(priv, SOURCE_AV2); - } - - /* HDMI1_DEVICE_AVAILABLE */ - status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI1); - if (status == 1) { //IN - notify_HDMI_device_available(priv, SOURCE_HDMI1, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI1, 0); - } - - /* HDMI2_DEVICE_AVAILABLE */ - status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI2); - if (status == 1) { //IN - notify_HDMI_device_available(priv, SOURCE_HDMI2, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI2, 1); - } - - /* HDMI3_DEVICE_AVAILABLE */ - status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI3); - if (status == 1) { //IN - notify_HDMI_device_available(priv, SOURCE_HDMI3, 2, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI3, 2); - } - - priv->mpTv->setTvObserver(priv->tvcallback); - } else { - /* AV1_DEVICE_AVAILABLE */ - notify_AV_device_available(priv, SOURCE_AV1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_AV_stream_configurations_change(priv, SOURCE_AV1); - /* AV2_DEVICE_AVAILABLE */ - notify_AV_device_available(priv, SOURCE_AV2, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_AV_stream_configurations_change(priv, SOURCE_AV2); - /* HDMI1_DEVICE_AVAILABLE */ - notify_HDMI_device_available(priv, SOURCE_HDMI1, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI1, 0); - /* HDMI2_DEVICE_AVAILABLE */ - notify_HDMI_device_available(priv, SOURCE_HDMI2, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI2, 1); - /* HDMI3_DEVICE_AVAILABLE */ - notify_HDMI_device_available(priv, SOURCE_HDMI3, 2, TV_INPUT_EVENT_DEVICE_AVAILABLE); - notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI3, 2); - } - return 0; + if (dev == NULL || callback == NULL) { + return -EINVAL; + } + tv_input_private_t *priv = (tv_input_private_t *)dev; + if (priv->callback != NULL) { + return -EEXIST; + } + priv->callback = callback; + priv->callback_data = data; + /* ATV_DEVICE_AVAILABLE */ + notify_ATV_device_available(priv); + notify_ATV_stream_configurations_change(priv); + /* DTV_DEVICE_AVAILABLE */ + notify_DTV_device_available(priv); + notify_DTV_stream_configurations_change(priv); + + if (priv->mpTv->GetHdmiAvHotplugDetectOnoff()) { + /* AV1_DEVICE_AVAILABLE */ + int status = priv->mpTv->GetSourceConnectStatus(SOURCE_AV1); + if (status == 1) { //IN + notify_AV_device_available(priv, SOURCE_AV1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_AV_stream_configurations_change(priv, SOURCE_AV1); + } + + /* AV2_DEVICE_AVAILABLE */ + status = priv->mpTv->GetSourceConnectStatus(SOURCE_AV2); + if (status == 1) { //IN + notify_AV_device_available(priv, SOURCE_AV2, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_AV_stream_configurations_change(priv, SOURCE_AV2); + } + + /* HDMI1_DEVICE_AVAILABLE */ + status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI1); + if (status == 1) { //IN + notify_HDMI_device_available(priv, SOURCE_HDMI1, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI1, 0); + } + + /* HDMI2_DEVICE_AVAILABLE */ + status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI2); + if (status == 1) { //IN + notify_HDMI_device_available(priv, SOURCE_HDMI2, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI2, 1); + } + + /* HDMI3_DEVICE_AVAILABLE */ + status = priv->mpTv->GetSourceConnectStatus(SOURCE_HDMI3); + if (status == 1) { //IN + notify_HDMI_device_available(priv, SOURCE_HDMI3, 2, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI3, 2); + } + + priv->mpTv->setTvObserver(priv->tvcallback); + } else { + /* AV1_DEVICE_AVAILABLE */ + notify_AV_device_available(priv, SOURCE_AV1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_AV_stream_configurations_change(priv, SOURCE_AV1); + /* AV2_DEVICE_AVAILABLE */ + notify_AV_device_available(priv, SOURCE_AV2, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_AV_stream_configurations_change(priv, SOURCE_AV2); + /* HDMI1_DEVICE_AVAILABLE */ + notify_HDMI_device_available(priv, SOURCE_HDMI1, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI1, 0); + /* HDMI2_DEVICE_AVAILABLE */ + notify_HDMI_device_available(priv, SOURCE_HDMI2, 1, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI2, 1); + /* HDMI3_DEVICE_AVAILABLE */ + notify_HDMI_device_available(priv, SOURCE_HDMI3, 2, TV_INPUT_EVENT_DEVICE_AVAILABLE); + notify_HDMI_stream_configurations_change(priv, SOURCE_HDMI3, 2); + } + return 0; } static int tv_input_get_stream_configurations(const struct tv_input_device *dev, - int device_id, int *num_configurations, - const tv_stream_config_t **configs) + int device_id, int *num_configurations, + const tv_stream_config_t **configs) { - if (get_stream_configs(device_id, num_configurations, configs) == 0) { - return 0; - } - return -EINVAL; + if (get_stream_configs(device_id, num_configurations, configs) == 0) { + return 0; + } + return -EINVAL; } static int tv_input_open_stream(struct tv_input_device *dev, int device_id, - tv_stream_t *stream) + tv_stream_t *stream) { - tv_input_private_t *priv = (tv_input_private_t *)dev; - if (priv) { - if (get_tv_stream(stream) != 0) { - return -EINVAL; - } - if (stream->stream_id == NORMAL_STREAM_ID) { - TvIputHal_ChannelConl(priv, 1, device_id); - return 0; - } else if (stream->stream_id == FRAME_CAPTURE_STREAM_ID) { - return 0; - } - } - return -EINVAL; + tv_input_private_t *priv = (tv_input_private_t *)dev; + if (priv) { + if (get_tv_stream(stream) != 0) { + return -EINVAL; + } + if (stream->stream_id == NORMAL_STREAM_ID) { + TvIputHal_ChannelConl(priv, 1, device_id); + return 0; + } else if (stream->stream_id == FRAME_CAPTURE_STREAM_ID) { + return 0; + } + } + return -EINVAL; } static int tv_input_close_stream(struct tv_input_device *dev, int device_id, - int stream_id) + int stream_id) { - tv_input_private_t *priv = (tv_input_private_t *)dev; - if (stream_id == NORMAL_STREAM_ID) { - TvIputHal_ChannelConl(priv, 0, device_id); - return 0; - } else if (stream_id == FRAME_CAPTURE_STREAM_ID) { - return 0; - } - return -EINVAL; + tv_input_private_t *priv = (tv_input_private_t *)dev; + if (stream_id == NORMAL_STREAM_ID) { + TvIputHal_ChannelConl(priv, 0, device_id); + return 0; + } else if (stream_id == FRAME_CAPTURE_STREAM_ID) { + return 0; + } + return -EINVAL; } static int tv_input_request_capture( - struct tv_input_device *dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq) + struct tv_input_device *dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq) { - return -EINVAL; + return -EINVAL; } static int tv_input_cancel_capture(struct tv_input_device *, int, int, uint32_t) { - return -EINVAL; + return -EINVAL; } /*****************************************************************************/ static int tv_input_device_close(struct hw_device_t *dev) { - tv_input_private_t *priv = (tv_input_private_t *)dev; - if (priv) { - if (priv->mpTv) { - delete priv->mpTv; - } - free(priv); - } - return 0; + tv_input_private_t *priv = (tv_input_private_t *)dev; + if (priv) { + if (priv->mpTv) { + delete priv->mpTv; + } + free(priv); + } + return 0; } /*****************************************************************************/ static int tv_input_device_open(const struct hw_module_t *module, - const char *name, struct hw_device_t **device) + const char *name, struct hw_device_t **device) { - int status = -EINVAL; - if (!strcmp(name, TV_INPUT_DEFAULT_DEVICE)) { - tv_input_private_t *dev = (tv_input_private_t *)malloc(sizeof(*dev)); - - /* initialize our state here */ - memset(dev, 0, sizeof(*dev)); - dev->mpTv = new CTv(); - dev->tvcallback = new TvCallback(dev); - /* initialize the procs */ - dev->device.common.tag = HARDWARE_DEVICE_TAG; - dev->device.common.version = TV_INPUT_DEVICE_API_VERSION_0_1; - dev->device.common.module = const_cast(module); - dev->device.common.close = tv_input_device_close; - - dev->device.initialize = tv_input_initialize; - dev->device.get_stream_configurations = - tv_input_get_stream_configurations; - dev->device.open_stream = tv_input_open_stream; - dev->device.close_stream = tv_input_close_stream; - dev->device.request_capture = tv_input_request_capture; - dev->device.cancel_capture = tv_input_cancel_capture; - - *device = &dev->device.common; - status = 0; - } - return status; + int status = -EINVAL; + if (!strcmp(name, TV_INPUT_DEFAULT_DEVICE)) { + tv_input_private_t *dev = (tv_input_private_t *)malloc(sizeof(*dev)); + + /* initialize our state here */ + memset(dev, 0, sizeof(*dev)); + dev->mpTv = new TvPlay(); + dev->tvcallback = new TvCallback(dev); + /* initialize the procs */ + dev->device.common.tag = HARDWARE_DEVICE_TAG; + dev->device.common.version = TV_INPUT_DEVICE_API_VERSION_0_1; + dev->device.common.module = const_cast(module); + dev->device.common.close = tv_input_device_close; + + dev->device.initialize = tv_input_initialize; + dev->device.get_stream_configurations = + tv_input_get_stream_configurations; + dev->device.open_stream = tv_input_open_stream; + dev->device.close_stream = tv_input_close_stream; + dev->device.request_capture = tv_input_request_capture; + dev->device.cancel_capture = tv_input_cancel_capture; + + *device = &dev->device.common; + status = 0; + } + return status; } diff --git a/tvapi/android/include/ITv.h b/tvapi/android/include/ITv.h index 9b80586..1130511 100644 --- a/tvapi/android/include/ITv.h +++ b/tvapi/android/include/ITv.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include using namespace android; diff --git a/tvapi/android/include/Tv.h b/tvapi/android/include/Tv.h deleted file mode 100644 index e39b5a1..0000000 --- a/tvapi/android/include/Tv.h +++ b/dev/null @@ -1,79 +0,0 @@ -#ifndef ANDROID_AMLOGIC_TV_H -#define ANDROID_AMLOGIC_TV_H - -#include -#include -#include -#include -#include - -using namespace android; - -class ITvService; -class ITv; - -// ref-counted object for callbacks -class TvListener: virtual public RefBase { -public: - virtual void notify(int32_t msgType, const Parcel &ext) = 0; -}; - -class Tv : public BnTvClient, public IBinder::DeathRecipient { -public: - // construct a tv client from an existing remote - static sp create(const sp &tv); - static sp connect(); - ~Tv(); - void init(); - status_t reconnect(); - void disconnect(); - status_t lock(); - status_t unlock(); - - status_t getStatus() - { - return mStatus; - } - status_t processCmd(const Parcel &p, Parcel *r); - status_t createSubtitle(const sp &share_mem); - status_t createVideoFrame(const sp &share_mem, int iSourceMode, int iCapVideoLayerOnly); - void setListener(const sp &listener); - - // ITvClient interface - virtual void notifyCallback(int32_t msgType, const Parcel &p); - - sp remote(); - -private: - Tv(); - Tv(const Tv &); - Tv &operator = (const Tv); - virtual void binderDied(const wp &who); - - class DeathNotifier: public IBinder::DeathRecipient { - public: - DeathNotifier() {} - virtual void binderDied(const wp &who); - }; - - static sp mDeathNotifier; - - // helper function to obtain tv service handle - static const sp &getTvService(); - - sp mTv; - status_t mStatus; - - sp mListener; - - friend class DeathNotifier; - - static Mutex mLock; - static sp mTvService; - - sp mBmpMemHeap; - sp mBmpMemBase; -}; - - -#endif diff --git a/tvapi/android/include/TvClient.h b/tvapi/android/include/TvClient.h new file mode 100644 index 0000000..a3f2a3f --- a/dev/null +++ b/tvapi/android/include/TvClient.h @@ -0,0 +1,75 @@ +#ifndef _ANDROID_TV_CLIENT_H_ +#define _ANDROID_TV_CLIENT_H_ + +#include +#include +#include +#include +#include + +using namespace android; + +class ITvService; +class ITv; + +// ref-counted object for callbacks +class TvListener: virtual public RefBase { +public: + virtual void notify(int32_t msgType, const Parcel &ext) = 0; +}; + +class TvClient : public BnTvClient, public IBinder::DeathRecipient { +public: + // construct a tv client from an existing remote + static sp create(const sp &tv); + static sp connect(); + ~TvClient(); + void init(); + status_t reconnect(); + void disconnect(); + status_t lock(); + status_t unlock(); + + status_t getStatus() { return mStatus; } + status_t processCmd(const Parcel &p, Parcel *r); + status_t createSubtitle(const sp &share_mem); + status_t createVideoFrame(const sp &share_mem, int iSourceMode, int iCapVideoLayerOnly); + void setListener(const sp &listener); + + // ITvClient interface + virtual void notifyCallback(int32_t msgType, const Parcel &p); + + sp remote(); + +private: + TvClient(); + TvClient(const TvClient &); + TvClient &operator = (const TvClient); + virtual void binderDied(const wp &who); + + class DeathNotifier: public IBinder::DeathRecipient { + public: + DeathNotifier() {} + virtual void binderDied(const wp &who); + }; + + static sp mDeathNotifier; + + // helper function to obtain tv service handle + static const sp &getTvService(); + + sp mTv; + status_t mStatus; + + sp mListener; + + friend class DeathNotifier; + + static Mutex mLock; + static sp mTvService; + + sp mBmpMemHeap; + sp mBmpMemBase; +}; +#endif/*_ANDROID_TV_CLIENT_H_*/ + diff --git a/tvapi/android/jni/com_droidlogic_app_tv_TvControlManager.cpp b/tvapi/android/jni/com_droidlogic_app_tv_TvControlManager.cpp index 56ad946..0f815f2 100644 --- a/tvapi/android/jni/com_droidlogic_app_tv_TvControlManager.cpp +++ b/tvapi/android/jni/com_droidlogic_app_tv_TvControlManager.cpp @@ -7,7 +7,7 @@ #include "GraphicsJNI.h" #include "android_runtime/AndroidRuntime.h" #include -#include +#include #include #include #include @@ -31,14 +31,14 @@ static fields_t fields; static Mutex sLock; class JNITvContext: public TvListener { public: - JNITvContext(JNIEnv *env, jobject weak_this, jclass clazz, const sp &tv); + JNITvContext(JNIEnv *env, jobject weak_this, jclass clazz, const sp &tv); ~JNITvContext() { release(); } virtual void notify(int32_t msgType, const Parcel &p); void addCallbackBuffer(JNIEnv *env, jbyteArray cbb); - sp getTv() + sp getTv() { Mutex::Autolock _l(mLock); return mTv; @@ -50,7 +50,7 @@ public: private: jobject mTvJObjectWeak; // weak reference to java object jclass mTvJClass; // strong reference to java class - sp mTv; // strong reference to native object + sp mTv; // strong reference to native object Mutex mLock; Vector mCallbackBuffers; // Global reference application managed byte[] @@ -58,9 +58,9 @@ private: bool mManualTvCallbackSet; // Whether the callback has been set, used to reduce unnecessary calls to set the callback. }; -sp get_native_tv(JNIEnv *env, jobject thiz, JNITvContext **pContext) +sp get_native_tv(JNIEnv *env, jobject thiz, JNITvContext **pContext) { - sp tv; + sp tv; Mutex::Autolock _l(sLock); JNITvContext *context = reinterpret_cast(env->GetIntField(thiz, fields.context)); if (context != NULL) { @@ -74,7 +74,7 @@ sp get_native_tv(JNIEnv *env, jobject thiz, JNITvContext **pContext) return tv; } -JNITvContext::JNITvContext(JNIEnv *env, jobject weak_this, jclass clazz, const sp &tv) +JNITvContext::JNITvContext(JNIEnv *env, jobject weak_this, jclass clazz, const sp &tv) { mTvJObjectWeak = env->NewGlobalRef(weak_this); mTvJClass = (jclass)env->NewGlobalRef(clazz); @@ -110,7 +110,7 @@ void JNITvContext::release() // connect to tv service static void com_droidlogic_app_tv_TvControlManager_native_setup(JNIEnv *env, jobject thiz, jobject weak_this) { - sp tv = Tv::connect(); + sp tv = TvClient::connect(); ALOGD("com_droidlogic_app_tv_TvControlManager_native_setup."); @@ -143,7 +143,7 @@ static void com_droidlogic_app_tv_TvControlManager_release(JNIEnv *env, jobject { // TODO: Change to LOGE JNITvContext *context = NULL; - sp tv; + sp tv; { Mutex::Autolock _l(sLock); context = reinterpret_cast(env->GetIntField(thiz, fields.context)); @@ -217,7 +217,7 @@ void JNITvContext::addCallbackBuffer(JNIEnv *env, jbyteArray cbb) static jint com_droidlogic_app_tv_TvControlManager_processCmd(JNIEnv *env, jobject thiz, jobject pObj, jobject rObj) { - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return -1; Parcel *p = parcelForJavaObject(env, pObj); @@ -251,7 +251,7 @@ static void com_droidlogic_app_tv_TvControlManager_addCallbackBuffer(JNIEnv *env static void com_droidlogic_app_tv_TvControlManager_reconnect(JNIEnv *env, jobject thiz) { - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return; if (tv->reconnect() != NO_ERROR) { @@ -262,7 +262,7 @@ static void com_droidlogic_app_tv_TvControlManager_reconnect(JNIEnv *env, jobjec static void com_droidlogic_app_tv_TvControlManager_lock(JNIEnv *env, jobject thiz) { - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return; ALOGD("lock"); @@ -274,7 +274,7 @@ static void com_droidlogic_app_tv_TvControlManager_lock(JNIEnv *env, jobject thi static void com_droidlogic_app_tv_TvControlManager_unlock(JNIEnv *env, jobject thiz) { - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return; ALOGD("unlock"); @@ -288,7 +288,7 @@ static void com_droidlogic_app_tv_TvControlManager_create_subtitle_bitmap(JNIEnv { ALOGD("create subtitle bmp"); JNITvContext *context = reinterpret_cast(env->GetIntField(thiz, fields.context)); - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return; //get skbitmap @@ -319,7 +319,7 @@ static void com_droidlogic_app_tv_TvControlManager_create_subtitle_bitmap(JNIEnv static void com_droidlogic_app_tv_TvControlManager_create_video_frame_bitmap(JNIEnv *env, jobject thiz, jobject bmpobj, jint inputSourceMode, jint iCapVideoLayer ) { ALOGD("create video frame bmp"); - sp tv = get_native_tv(env, thiz, NULL); + sp tv = get_native_tv(env, thiz, NULL); if (tv == 0) return; //get skbitmap diff --git a/tvapi/android/libtvbinder/Android.mk b/tvapi/android/libtvbinder/Android.mk index e7820a3..b1b7517 100644 --- a/tvapi/android/libtvbinder/Android.mk +++ b/tvapi/android/libtvbinder/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES:= \ - Tv.cpp \ + TvClient.cpp \ ITv.cpp \ ITvClient.cpp \ ITvService.cpp diff --git a/tvapi/android/libtvbinder/Tv.cpp b/tvapi/android/libtvbinder/Tv.cpp deleted file mode 100644 index 0882edb..0000000 --- a/tvapi/android/libtvbinder/Tv.cpp +++ b/dev/null @@ -1,189 +0,0 @@ -#define LOG_TAG "Tv" -#include -#include -#include -#include -#include - -#include -#include - -// client singleton for tv service binder interface -Mutex Tv::mLock; -sp Tv::mTvService; -sp Tv::mDeathNotifier; - -// establish binder interface to tv service -const sp &Tv::getTvService() -{ - Mutex::Autolock _l(mLock); - if (mTvService.get() == 0) { - sp sm = defaultServiceManager(); - sp binder; - do { - binder = sm->getService(String16("aml.tvserver")); - if (binder != 0) - break; - ALOGW("TvService not published, waiting..."); - usleep(500000); // 0.5 s - } while (true); - if (mDeathNotifier == NULL) { - mDeathNotifier = new DeathNotifier(); - } - binder->linkToDeath(mDeathNotifier); - mTvService = interface_cast(binder); - } - ALOGE_IF(mTvService == 0, "no TvService!?"); - return mTvService; -} - -Tv::Tv() -{ - init(); -} - -// construct a tv client from an existing tv remote -sp Tv::create(const sp &tv) -{ - ALOGD("create"); - if (tv == 0) { - ALOGE("tv remote is a NULL pointer"); - return 0; - } - - sp c = new Tv(); - if (tv->connect(c) == NO_ERROR) { - c->mStatus = NO_ERROR; - c->mTv = tv; - IInterface::asBinder(tv)->linkToDeath(c); - } - return c; -} - -void Tv::init() -{ - mStatus = UNKNOWN_ERROR; -} - -Tv::~Tv() -{ - disconnect(); -} - -sp Tv::connect() -{ - ALOGD("Tv::connect------------------------------------------"); - sp c = new Tv(); - const sp &cs = getTvService(); - if (cs != 0) { - c->mTv = cs->connect(c); - } - if (c->mTv != 0) { - IInterface::asBinder(c->mTv)->linkToDeath(c); - c->mStatus = NO_ERROR; - } else { - c.clear(); - } - return c; -} - -void Tv::disconnect() -{ - ALOGD("disconnect"); - if (mTv != 0) { - mTv->disconnect(); - IInterface::asBinder(mTv)->unlinkToDeath(this); - mTv = 0; - } -} - -status_t Tv::reconnect() -{ - ALOGD("reconnect"); - sp c = mTv; - if (c == 0) return NO_INIT; - return c->connect(this); -} - -sp Tv::remote() -{ - return mTv; -} - -status_t Tv::lock() -{ - sp c = mTv; - if (c == 0) return NO_INIT; - return c->lock(); -} - -status_t Tv::unlock() -{ - sp c = mTv; - if (c == 0) return NO_INIT; - return c->unlock(); -} - -status_t Tv::processCmd(const Parcel &p, Parcel *r) -{ - sp c = mTv; - if (c == 0) return NO_INIT; - return c->processCmd(p, r); -} - -// -status_t Tv::createSubtitle(const sp &share_mem) -{ - sp c = mTv; - if (c == 0) return NO_INIT; - return c->createSubtitle(share_mem); -} - -status_t Tv::createVideoFrame(const sp &share_mem, int iSourceMode, int iCapVideoLayerOnly) -{ - sp c = mTv; - if (c == 0) return NO_INIT; - return c->createVideoFrame(share_mem, iSourceMode, iCapVideoLayerOnly); -} - - -void Tv::setListener(const sp &listener) -{ - ALOGD("tv------------Tv::setListener"); - Mutex::Autolock _l(mLock); - mListener = listener; -} - - -// callback from tv service -void Tv::notifyCallback(int32_t msgType, const Parcel &p) -{ - int size = p.dataSize(); - int pos = p.dataPosition(); - p.setDataPosition(0); - sp listener; - { - Mutex::Autolock _l(mLock); - listener = mListener; - } - if (listener != NULL) { - listener->notify(msgType, p); - } -} - -void Tv::binderDied(const wp &who) -{ - ALOGW("ITv died"); - //notifyCallback(1, 2, 0); -} - -void Tv::DeathNotifier::binderDied(const wp &who) -{ - ALOGW("-----------------binderDied"); - Mutex::Autolock _l(Tv::mLock); - Tv::mTvService.clear(); - ALOGW("kill myself"); - kill(getpid(), SIGKILL); - ALOGW("----------------Tv server died!"); -} - diff --git a/tvapi/android/libtvbinder/TvClient.cpp b/tvapi/android/libtvbinder/TvClient.cpp new file mode 100644 index 0000000..188a964 --- a/dev/null +++ b/tvapi/android/libtvbinder/TvClient.cpp @@ -0,0 +1,168 @@ +#define LOG_TAG "TvClient" +#include +#include +#include +#include +#include + +#include +#include + +// client singleton for tv service binder interface +Mutex TvClient::mLock; +sp TvClient::mTvService; +sp TvClient::mDeathNotifier; + +// establish binder interface to tv service +const sp &TvClient::getTvService() { + Mutex::Autolock _l(mLock); + if (mTvService.get() == 0) { + sp sm = defaultServiceManager(); + sp binder; + do { + binder = sm->getService(String16("aml.tvserver")); + if (binder != 0) + break; + ALOGW("TvService not published, waiting..."); + usleep(500000); // 0.5 s + } while (true); + if (mDeathNotifier == NULL) { + mDeathNotifier = new DeathNotifier(); + } + binder->linkToDeath(mDeathNotifier); + mTvService = interface_cast(binder); + } + ALOGE_IF(mTvService == 0, "no TvService!?"); + return mTvService; +} + +TvClient::TvClient() { + init(); +} + +// construct a tv client from an existing tv remote +sp TvClient::create(const sp &tv) { + ALOGD("create"); + if (tv == 0) { + ALOGE("tv remote is a NULL pointer"); + return 0; + } + + sp c = new TvClient(); + if (tv->connect(c) == NO_ERROR) { + c->mStatus = NO_ERROR; + c->mTv = tv; + IInterface::asBinder(tv)->linkToDeath(c); + } + return c; +} + +void TvClient::init() { + mStatus = UNKNOWN_ERROR; +} + +TvClient::~TvClient() { + disconnect(); +} + +sp TvClient::connect() { + ALOGD("Tv::connect------------------------------------------"); + sp c = new TvClient(); + const sp &cs = getTvService(); + if (cs != 0) { + c->mTv = cs->connect(c); + } + if (c->mTv != 0) { + IInterface::asBinder(c->mTv)->linkToDeath(c); + c->mStatus = NO_ERROR; + } else { + c.clear(); + } + return c; +} + +void TvClient::disconnect() { + ALOGD("disconnect"); + if (mTv != 0) { + mTv->disconnect(); + IInterface::asBinder(mTv)->unlinkToDeath(this); + mTv = 0; + } +} + +status_t TvClient::reconnect() { + ALOGD("reconnect"); + sp c = mTv; + if (c == 0) return NO_INIT; + return c->connect(this); +} + +sp TvClient::remote() { + return mTv; +} + +status_t TvClient::lock() { + sp c = mTv; + if (c == 0) return NO_INIT; + return c->lock(); +} + +status_t TvClient::unlock() { + sp c = mTv; + if (c == 0) return NO_INIT; + return c->unlock(); +} + +status_t TvClient::processCmd(const Parcel &p, Parcel *r) { + sp c = mTv; + if (c == 0) return NO_INIT; + return c->processCmd(p, r); +} + +status_t TvClient::createSubtitle(const sp &share_mem) { + sp c = mTv; + if (c == 0) return NO_INIT; + return c->createSubtitle(share_mem); +} + +status_t TvClient::createVideoFrame(const sp &share_mem, int iSourceMode, int iCapVideoLayerOnly) { + sp c = mTv; + if (c == 0) return NO_INIT; + return c->createVideoFrame(share_mem, iSourceMode, iCapVideoLayerOnly); +} + +void TvClient::setListener(const sp &listener) { + ALOGD("tv------------Tv::setListener"); + Mutex::Autolock _l(mLock); + mListener = listener; +} + +// callback from tv service +void TvClient::notifyCallback(int32_t msgType, const Parcel &p) { + int size = p.dataSize(); + int pos = p.dataPosition(); + p.setDataPosition(0); + sp listener; + { + Mutex::Autolock _l(mLock); + listener = mListener; + } + if (listener != NULL) { + listener->notify(msgType, p); + } +} + +void TvClient::binderDied(const wp &who) { + ALOGW("ITv died"); + //notifyCallback(1, 2, 0); +} + +void TvClient::DeathNotifier::binderDied(const wp &who) { + ALOGW("-----------------binderDied"); + Mutex::Autolock _l(TvClient::mLock); + TvClient::mTvService.clear(); + ALOGW("kill myself"); + kill(getpid(), SIGKILL); + ALOGW("----------------Tv server died!"); +} + diff --git a/tvapi/android/tv/Android.mk b/tvapi/android/tv/Android.mk index 8aa9f68..dcadd57 100644 --- a/tvapi/android/tv/Android.mk +++ b/tvapi/android/tv/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES:= \ - CTv.cpp \ + TvPlay.cpp \ LOCAL_SHARED_LIBRARIES := \ libcutils \ diff --git a/tvapi/android/tv/CTv.cpp b/tvapi/android/tv/CTv.cpp deleted file mode 100644 index cdfc52b..0000000 --- a/tvapi/android/tv/CTv.cpp +++ b/dev/null @@ -1,104 +0,0 @@ -#include -#include "CTv.h" -#include "../include/tvcmd.h" - -CTv::CTv() { - mpObserver = NULL; - tv = Tv::connect(); - tv->setListener(this); -} - -CTv::~CTv() { - tv.clear(); -} - -int CTv::setTvObserver ( TvIObserver *ob ) -{ - mpObserver = ob; - return 0; -} - -void CTv::notify(int32_t msgType, const Parcel &p) -{ - ALOGD("CTv-------notify-------"); - //if(mpObserver) - //mpObserver->onTvEvent(msgType, p); - if (mpObserver != NULL) - mpObserver->onTvEvent(msgType, p); -} - -int CTv::StartTv() -{ - Parcel p, r; - p.writeInt32(START_TV); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::StopTv() -{ - Parcel p, r; - p.writeInt32(STOP_TV); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::SwitchSourceInput(tv_source_input_t source_input) -{ - Parcel p, r; - p.writeInt32(SET_SOURCE_INPUT); - p.writeInt32(source_input); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::DoSuspend(int type) -{ - Parcel p, r; - p.writeInt32(DO_SUSPEND); - p.writeInt32(type); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::DoResume(int type) -{ - Parcel p, r; - p.writeInt32(DO_RESUME); - p.writeInt32(type); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::GetSourceConnectStatus(tv_source_input_t source_input) -{ - Parcel p, r; - p.writeInt32(GET_SOURCE_CONNECT_STATUS); - p.writeInt32(source_input); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::GetCurrentSourceInput() -{ - Parcel p, r; - p.writeInt32(SSM_READ_SOURCE_INPUT); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} - -int CTv::GetHdmiAvHotplugDetectOnoff() -{ - Parcel p, r; - p.writeInt32(HDMIAV_HOTPLUGDETECT_ONOFF); - tv->processCmd(p, &r); - int ret = r.readInt32(); - return ret; -} diff --git a/tvapi/android/tv/CTv.h b/tvapi/android/tv/CTv.h deleted file mode 100644 index 00caabb..0000000 --- a/tvapi/android/tv/CTv.h +++ b/dev/null @@ -1,54 +0,0 @@ -#ifndef ANDROID_AMLOGIC_CTV_H -#define ANDROID_AMLOGIC_CTV_H - -#include - -typedef enum tv_source_input_e { - SOURCE_INVALID = -1, - SOURCE_TV = 0, - SOURCE_AV1, - SOURCE_AV2, - SOURCE_YPBPR1, - SOURCE_YPBPR2, - SOURCE_HDMI1, - SOURCE_HDMI2, - SOURCE_HDMI3, - SOURCE_VGA, - SOURCE_MPEG, - SOURCE_DTV, - SOURCE_SVIDEO, - SOURCE_IPTV, - SOURCE_DUMMY, - SOURCE_MAX, -} tv_source_input_t; - -class CTv : public TvListener{ -public: - class TvIObserver - { - public: - TvIObserver() {}; - virtual ~TvIObserver() {}; - virtual void onTvEvent (int32_t msgType, const Parcel &p) = 0; - }; - CTv(); - ~CTv(); - int StartTv(); - int StopTv(); - int SwitchSourceInput(tv_source_input_t source_input); - //type , 1 is instaboot suspend - int DoSuspend(int type); - int DoResume(int type); - int GetSourceConnectStatus(tv_source_input_t source_input); - int GetCurrentSourceInput(); - int GetHdmiAvHotplugDetectOnoff(); - int setTvObserver (TvIObserver *ob); - virtual void notify(int32_t msgType, const Parcel &p); - - sp tv; - -private: - TvIObserver *mpObserver; -}; - -#endif diff --git a/tvapi/android/tv/TvPlay.cpp b/tvapi/android/tv/TvPlay.cpp new file mode 100644 index 0000000..b5994d4 --- a/dev/null +++ b/tvapi/android/tv/TvPlay.cpp @@ -0,0 +1,85 @@ +#include +#include "TvPlay.h" +#include "../include/tvcmd.h" + +TvPlay::TvPlay() { + mpObserver = NULL; + tvSession = TvClient::connect(); + tvSession->setListener(this); +} + +TvPlay::~TvPlay() { + tvSession.clear(); +} + +int TvPlay::setTvObserver ( TvPlayObserver *ob ) { + mpObserver = ob; + return 0; +} + +void TvPlay::notify(int32_t msgType, const Parcel &p) { + ALOGD("TvPlay-------notify-------"); + if (mpObserver != NULL) + mpObserver->onTvEvent(msgType, p); +} + +int TvPlay::StartTv() { + Parcel p, r; + p.writeInt32(START_TV); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::StopTv() { + Parcel p, r; + p.writeInt32(STOP_TV); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::SwitchSourceInput(tv_source_input_t source_input) { + Parcel p, r; + p.writeInt32(SET_SOURCE_INPUT); + p.writeInt32(source_input); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::DoSuspend(int type) { + Parcel p, r; + p.writeInt32(DO_SUSPEND); + p.writeInt32(type); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::DoResume(int type) { + Parcel p, r; + p.writeInt32(DO_RESUME); + p.writeInt32(type); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::GetSourceConnectStatus(tv_source_input_t source_input) { + Parcel p, r; + p.writeInt32(GET_SOURCE_CONNECT_STATUS); + p.writeInt32(source_input); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::GetCurrentSourceInput() { + Parcel p, r; + p.writeInt32(SSM_READ_SOURCE_INPUT); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + +int TvPlay::GetHdmiAvHotplugDetectOnoff() { + Parcel p, r; + p.writeInt32(HDMIAV_HOTPLUGDETECT_ONOFF); + tvSession->processCmd(p, &r); + return r.readInt32(); +} + diff --git a/tvapi/android/tv/TvPlay.h b/tvapi/android/tv/TvPlay.h new file mode 100644 index 0000000..cbab849 --- a/dev/null +++ b/tvapi/android/tv/TvPlay.h @@ -0,0 +1,62 @@ +#ifndef _ANDROID_TV_PLAY_H_ +#define _ANDROID_TV_PLAY_H_ + +#ifdef __cplusplus +//extern "C" { +#endif + +#include + +typedef enum tv_source_input_e { + SOURCE_INVALID = -1, + SOURCE_TV = 0, + SOURCE_AV1, + SOURCE_AV2, + SOURCE_YPBPR1, + SOURCE_YPBPR2, + SOURCE_HDMI1, + SOURCE_HDMI2, + SOURCE_HDMI3, + SOURCE_VGA, + SOURCE_MPEG, + SOURCE_DTV, + SOURCE_SVIDEO, + SOURCE_IPTV, + SOURCE_DUMMY, + SOURCE_MAX, +} tv_source_input_t; + +class TvPlayObserver { +public: + TvPlayObserver() {}; + virtual ~TvPlayObserver() {}; + virtual void onTvEvent (int32_t msgType, const Parcel &p) = 0; +}; + +class TvPlay : public TvListener{ +public: + TvPlay(); + ~TvPlay(); + int StartTv(); + int StopTv(); + int SwitchSourceInput(tv_source_input_t source_input); + //type , 1 is instaboot suspend + int DoSuspend(int type); + int DoResume(int type); + int GetSourceConnectStatus(tv_source_input_t source_input); + int GetCurrentSourceInput(); + int GetHdmiAvHotplugDetectOnoff(); + int setTvObserver (TvPlayObserver *ob); + virtual void notify(int32_t msgType, const Parcel &p); + + sp tvSession; + +private: + TvPlayObserver *mpObserver; +}; + +#ifdef __cplusplus +//} +#endif + +#endif/*_ANDROID_TV_PLAY_H_*/ diff --git a/tvapi/android/tvserver/TvService.cpp b/tvapi/android/tvserver/TvService.cpp index 9de4fb8..56dbe48 100644 --- a/tvapi/android/tvserver/TvService.cpp +++ b/tvapi/android/tvserver/TvService.cpp @@ -2842,7 +2842,7 @@ status_t TvService::Client::processCmd(const Parcel &p, Parcel *r) tmp_str16 = p.readString16(); value_str = String8(tmp_str16); - tmpRet = config_set_str("TV", key_str.string(), value_str.string()); + tmpRet = config_set_str(CFG_SECTION_TV, key_str.string(), value_str.string()); r->writeInt32(tmpRet); break; } @@ -2856,7 +2856,7 @@ status_t TvService::Client::processCmd(const Parcel &p, Parcel *r) tmp_str16 = p.readString16(); def_str = String8(tmp_str16); - prop_value = config_get_str("TV", key_str.string(), def_str.string()); + prop_value = config_get_str(CFG_SECTION_TV, key_str.string(), def_str.string()); tmp_str16 = String16(prop_value); r->writeString16(tmp_str16); @@ -3117,7 +3117,7 @@ status_t TvService::Client::processCmd(const Parcel &p, Parcel *r) Vector > out; int tmpRet = CTvRegion::getChannelListByName("CHINA,Default DTMB ALL", out); r->writeInt32(out.size()); - for (int i = 0; i < out.size(); i++) { + for (int i = 0; i < (int)out.size(); i++) { r->writeInt32(out[i]->getID()); r->writeInt32(out[i]->getFrequency()); } @@ -3353,8 +3353,7 @@ status_t TvService::Client::processCmd(const Parcel &p, Parcel *r) } case HDMI_OUT_TOWHAT: { - int tmpRet = mpTv->hdmi_out_towhat(); - r->writeInt32(tmpRet); + r->writeInt32(mpTv->hdmiOutWithFbc()?1:0); break; } case FACTORY_FBC_UPGRADE: { @@ -4281,7 +4280,7 @@ status_t TvService::Client::processCmd(const Parcel &p, Parcel *r) int skip = p.readInt32(); CTvProgram::selectByType(type, skip, out); r->writeInt32(out.size()); - for (int i = 0; i < out.size(); i++) { + for (int i = 0; i < (int)out.size(); i++) { r->writeInt32(out[i]->getID()); r->writeInt32(out[i]->getChanOrderNum()); r->writeInt32(out[i]->getMajor()); diff --git a/tvapi/android/tvserver/TvService.h b/tvapi/android/tvserver/TvService.h index 5356d49..7507f6a 100644 --- a/tvapi/android/tvserver/TvService.h +++ b/tvapi/android/tvserver/TvService.h @@ -2,7 +2,7 @@ #define ANDROID_SERVERS_TV_TVSERVICE_H #include -#include +//#include #include #include #include diff --git a/tvapi/libtv/tv/CAv.cpp b/tvapi/libtv/tv/CAv.cpp index 655b281..904ee3b 100644 --- a/tvapi/libtv/tv/CAv.cpp +++ b/tvapi/libtv/tv/CAv.cpp @@ -172,7 +172,7 @@ int CAv::EnableVideoNow() return 0; } mCurVideoLayerMuteState = 0; - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); if ( strcmp ( config_value, "black" ) == 0 ) { } else { SetVideoScreenColor ( 0, 16, 128, 128 ); // Show blue with vdin0, postblending disabled diff --git a/tvapi/libtv/tv/CFbcCommunication.cpp b/tvapi/libtv/tv/CFbcCommunication.cpp index cf63278..0318d77 100644 --- a/tvapi/libtv/tv/CFbcCommunication.cpp +++ b/tvapi/libtv/tv/CFbcCommunication.cpp @@ -464,7 +464,7 @@ int CFbcCommunication::processData(COMM_DEV_TYPE_E fromDev, unsigned char *pData //just test const char *value; if (!mbSendKeyCode) { - value = config_get_str("FBCUART", "fbc_key_event_handle", "null"); + value = config_get_str(CFG_SECTION_FBCUART, "fbc_key_event_handle", "null"); if ( strcmp ( value, "true" ) == 0 ) mbSendKeyCode = true; else mbSendKeyCode = false; diff --git a/tvapi/libtv/tv/CTv.cpp b/tvapi/libtv/tv/CTv.cpp index c167ea0..8a6aa0f 100644 --- a/tvapi/libtv/tv/CTv.cpp +++ b/tvapi/libtv/tv/CTv.cpp @@ -65,7553 +65,6901 @@ extern "C" { using namespace android; // Called each time a message is logged. -static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg) -{ - LOGD( "showbo sqlite (%d) %s\n", iErrCode, zMsg); -} - - - -CTv::CTv() : mSigDetectThread ( &mTvin ), mSourceConnectDetectThread(&mTvin), mHDMIRxCEC ( &mTvin ), mTvScanner ( &mTvin ), mTvMsgQueue(this), mAutoBackLight( &mVpp, &mTvin ), mTvScannerDetectObserver(this), mAutoPQparam( &mVpp, &mTvin, &mAv ) -{ - mAudioMuteStatusForTv = CC_AUDIO_UNMUTE; - mAudioMuteStatusForSystem = CC_AUDIO_UNMUTE; - //mpClient = pClient; - //copy file to param - if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_SYSTEM_PATH ) == 0 ) { - if ( Tv_Utils_IsFileExist ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) { - CFile file ( TV_CONFIG_FILE_SYSTEM_PATH ); - - if ( file.copyTo ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) { - LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CONFIG_FILE_PARAM_PATH ); - } - } - } - - if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_SYSTEM_PATH ) == 0 ) { - if ( Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) { - CFile file ( TV_CHANNEL_LIST_SYSTEM_PATH ); - - if ( file.copyTo ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) { - LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CHANNEL_LIST_PARAM_PATH ); - } - } - } - - //ssm - if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_SYSTEM_PATH ) == 0 ) { - if ( Tv_Utils_IsFileExist ( TV_SSM_DATA_PARAM_PATH ) != 0 ) { - CFile file ( TV_SSM_DATA_SYSTEM_PATH ); - - if ( file.copyTo ( TV_SSM_DATA_PARAM_PATH ) != 0 ) { - LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_SSM_DATA_PARAM_PATH ); - } - } - } - - AM_EVT_Init(); - mTvEpg.setObserver ( &mTvMsgQueue ); - mpObserver = NULL; - mB_hdmiout_fbc = false; - fbcIns = NULL; - dtv_auto_3d_flag = 0; - m_autoset_displayfreq = false; - - tv_config_load ( TV_CONFIG_FILE_PATH ); - sqlite3_config (SQLITE_CONFIG_SERIALIZED); - //sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void*)1); - sqlite3_soft_heap_limit(8 * 1024 * 1024); - // Initialize SQLite. - sqlite3_initialize(); - CTvDatabase::GetTvDb()->InitTvDb ( TV_DB_PATH ); - - if ( CTvDimension::isDimensionTblExist() == false ) { - CTvDimension::builtinAtscDimensions(); - } - - CTvSettingLoad(); - - mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; - if (hdmi_out_towhat() == 1) { - mB_hdmiout_fbc = true; - } else { - mB_hdmiout_fbc = false; - } - - m_sig_stable_nums = 0; - m_is_set_hdmi_edid = false; - m_cur_playing_prog_id = -1; - - m_hdmi_audio_data = 0; - mSigDetectThread.setObserver ( this ); - mSourceConnectDetectThread.setObserver ( this ); - mHDMIRxCEC.setObserver(this); - mFrontDev.setObserver ( &mTvMsgQueue ); - mpUpgradeFBC = NULL; - if (mB_hdmiout_fbc) { - fbcIns = GetSingletonFBC(); - - mpUpgradeFBC = new CUpgradeFBC(); - mpUpgradeFBC->setObserver(this); - } - mSerialA.setObserver(this); - mSerialB.setObserver(this); - mSerialC.setObserver(this); - mSubtitle.setObserver(this); - mHeadSet.setObserver(this); - mTvScanner.setGlobalScanerObject(&mTvScanner); - mAv.setObserver(&mTvMsgQueue); - mMainVolLutTableExtraName[0] = '\0'; - //----------------------------------------------------------- - mCurAudioMasterVolume = CC_DEF_SOUND_VOL; - mCurAudioBalance = CC_DEF_SOUND_BALANCE_VAL; - mCurAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; - mCurAudioSupperBassSwitch = CC_SWITCH_OFF; - mCurAudioSRSSurround = CC_SWITCH_OFF; - mCurAudioSrsDialogClarity = CC_SWITCH_OFF; - mCurAudioSrsTruBass = CC_SWITCH_OFF; - mCurAudioSPDIFSwitch = CC_SWITCH_ON; - mCurAudioSPDIFMode = CC_SPDIF_MODE_PCM; - mCurAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; - mCurAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; - mCurAudioSoundMode = CC_SOUND_MODE_END; - mCurAudioWallEffect = CC_SWITCH_OFF; - mCurAudioEQMode = CC_EQ_MODE_START; - mCustomAudioMasterVolume = CC_DEF_SOUND_VOL; - mCustomAudioBalance = CC_DEF_SOUND_BALANCE_VAL; - mCustomAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; - mCustomAudioSupperBassSwitch = CC_SWITCH_OFF; - mCustomAudioSRSSurround = CC_SWITCH_OFF; - mCustomAudioSrsDialogClarity = CC_SWITCH_OFF; - mCustomAudioSrsTruBass = CC_SWITCH_OFF; - mCustomAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; - mCustomAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; - mCustomAudioSoundMode = CC_SOUND_MODE_END; - mCustomAudioWallEffect = CC_SWITCH_OFF; - mCustomAudioEQMode = CC_EQ_MODE_START; - mCustomAudioSoundEnhancementSwitch = CC_SWITCH_OFF; - mVolumeCompensationVal = 0; - - mMainVolumeBalanceVal = 0; - for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { - mCustomEQGainBuf[i] = 0; - mCurEQGainBuf[i] = 0; - mCurEQGainChBuf[i] = 0; - } - static const int WALL_EFFECT_VALUE[CC_BAND_ITEM_CNT] = { 0, 0, 1, 2, 2, 0 }; - for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { - mWallEffectValueBuf[i] = WALL_EFFECT_VALUE[i]; - } - mTvAction = mTvAction & TV_ACTION_NULL; - mTvStatus = TV_INIT_ED; - print_version_info(); +static void sqliteLogCallback(void *data, int iErrCode, const char *zMsg) { + data = data; + LOGD( "showbo sqlite (%d) %s\n", iErrCode, zMsg); +} + +CTv::CTv() : + mSigDetectThread ( &mTvin ), + mSourceConnectDetectThread(&mTvin), + mHDMIRxCEC ( &mTvin ), + mTvScanner ( &mTvin ), + mTvMsgQueue(this), + mAutoBackLight( &mVpp, &mTvin ), + mTvScannerDetectObserver(this), + mAutoPQparam( &mVpp, &mTvin, &mAv ) { + mAudioMuteStatusForTv = CC_AUDIO_UNMUTE; + mAudioMuteStatusForSystem = CC_AUDIO_UNMUTE; + //mpClient = pClient; + //copy file to param + if (Tv_Utils_IsFileExist ( TV_CONFIG_FILE_SYSTEM_PATH )) { + if (!Tv_Utils_IsFileExist ( TV_CONFIG_FILE_PARAM_PATH )) { + CFile file ( TV_CONFIG_FILE_SYSTEM_PATH ); + + if ( file.copyTo ( TV_CONFIG_FILE_PARAM_PATH ) != 0 ) { + LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CONFIG_FILE_PARAM_PATH ); + } + } + } + + if (Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_SYSTEM_PATH )) { + if (!Tv_Utils_IsFileExist ( TV_CHANNEL_LIST_PARAM_PATH )) { + CFile file ( TV_CHANNEL_LIST_SYSTEM_PATH ); + + if ( file.copyTo ( TV_CHANNEL_LIST_PARAM_PATH ) != 0 ) { + LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_CHANNEL_LIST_PARAM_PATH ); + } + } + } + + //ssm + if (Tv_Utils_IsFileExist ( TV_SSM_DATA_SYSTEM_PATH )) { + if (!Tv_Utils_IsFileExist ( TV_SSM_DATA_PARAM_PATH )) { + CFile file ( TV_SSM_DATA_SYSTEM_PATH ); + + if ( file.copyTo ( TV_SSM_DATA_PARAM_PATH ) != 0 ) { + LOGE ( "%s, copy file = %s , error", __FUNCTION__, TV_SSM_DATA_PARAM_PATH ); + } + } + } + + AM_EVT_Init(); + mTvEpg.setObserver ( &mTvMsgQueue ); + mpObserver = NULL; + fbcIns = NULL; + dtv_auto_3d_flag = 0; + m_autoset_displayfreq = false; + + tv_config_load ( TV_CONFIG_FILE_PATH ); + sqlite3_config (SQLITE_CONFIG_SERIALIZED); + //sqlite3_config(SQLITE_CONFIG_LOG, &sqliteLogCallback, (void*)1); + sqlite3_soft_heap_limit(8 * 1024 * 1024); + // Initialize SQLite. + sqlite3_initialize(); + CTvDatabase::GetTvDb()->InitTvDb ( TV_DB_PATH ); + + if ( CTvDimension::isDimensionTblExist() == false ) { + CTvDimension::builtinAtscDimensions(); + } + + CTvSettingLoad(); + + mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; + if (hdmiOutWithFbc()) { + mHdmiOutFbc = true; + } else { + mHdmiOutFbc = false; + } + + m_sig_stable_nums = 0; + m_is_set_hdmi_edid = false; + m_cur_playing_prog_id = -1; + + m_hdmi_audio_data = 0; + mSigDetectThread.setObserver ( this ); + mSourceConnectDetectThread.setObserver ( this ); + mHDMIRxCEC.setObserver(this); + mFrontDev.setObserver ( &mTvMsgQueue ); + mpUpgradeFBC = NULL; + if (mHdmiOutFbc) { + fbcIns = GetSingletonFBC(); + + mpUpgradeFBC = new CUpgradeFBC(); + mpUpgradeFBC->setObserver(this); + } + mSerialA.setObserver(this); + mSerialB.setObserver(this); + mSerialC.setObserver(this); + mSubtitle.setObserver(this); + mHeadSet.setObserver(this); + mTvScanner.setGlobalScanerObject(&mTvScanner); + mAv.setObserver(&mTvMsgQueue); + mMainVolLutTableExtraName[0] = '\0'; + //----------------------------------------------------------- + mCurAudioMasterVolume = CC_DEF_SOUND_VOL; + mCurAudioBalance = CC_DEF_SOUND_BALANCE_VAL; + mCurAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; + mCurAudioSupperBassSwitch = CC_SWITCH_OFF; + mCurAudioSRSSurround = CC_SWITCH_OFF; + mCurAudioSrsDialogClarity = CC_SWITCH_OFF; + mCurAudioSrsTruBass = CC_SWITCH_OFF; + mCurAudioSPDIFSwitch = CC_SWITCH_ON; + mCurAudioSPDIFMode = CC_SPDIF_MODE_PCM; + mCurAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; + mCurAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; + mCurAudioSoundMode = CC_SOUND_MODE_END; + mCurAudioWallEffect = CC_SWITCH_OFF; + mCurAudioEQMode = CC_EQ_MODE_START; + mCustomAudioMasterVolume = CC_DEF_SOUND_VOL; + mCustomAudioBalance = CC_DEF_SOUND_BALANCE_VAL; + mCustomAudioSupperBassVolume = CC_DEF_SUPPERBASS_VOL; + mCustomAudioSupperBassSwitch = CC_SWITCH_OFF; + mCustomAudioSRSSurround = CC_SWITCH_OFF; + mCustomAudioSrsDialogClarity = CC_SWITCH_OFF; + mCustomAudioSrsTruBass = CC_SWITCH_OFF; + mCustomAudioBassVolume = CC_DEF_BASS_TREBLE_VOL; + mCustomAudioTrebleVolume = CC_DEF_BASS_TREBLE_VOL; + mCustomAudioSoundMode = CC_SOUND_MODE_END; + mCustomAudioWallEffect = CC_SWITCH_OFF; + mCustomAudioEQMode = CC_EQ_MODE_START; + mCustomAudioSoundEnhancementSwitch = CC_SWITCH_OFF; + mVolumeCompensationVal = 0; + + mMainVolumeBalanceVal = 0; + for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { + mCustomEQGainBuf[i] = 0; + mCurEQGainBuf[i] = 0; + mCurEQGainChBuf[i] = 0; + } + static const int WALL_EFFECT_VALUE[CC_BAND_ITEM_CNT] = { 0, 0, 1, 2, 2, 0 }; + for (int i = 0; i < CC_BAND_ITEM_CNT; i++) { + mWallEffectValueBuf[i] = WALL_EFFECT_VALUE[i]; + } + mTvAction &= TV_ACTION_NULL; + mTvStatus = TV_INIT_ED; + print_version_info(); }; -CTv::~CTv() -{ - int iRet; - mpObserver = NULL; - CTvSettingunLoad(); - CTvDatabase::deleteTvDb(); - tv_config_unload(); - mAv.Close(); - mTvStatus = TV_INIT_ED; - mFrontDev.Close(); - - if (mpUpgradeFBC != NULL) { - delete mpUpgradeFBC; - mpUpgradeFBC = NULL; - } -} - -void CTv::onEvent ( const CTvScanner::ScannerEvent &ev ) -{ - LOGD ( "%s, CTv::onEvent lockStatus = %d type = %d\n", __FUNCTION__, ev.mLockedStatus, ev.mType ); - - if ( mDtvScanRunningStatus == DTV_SCAN_RUNNING_ANALYZE_CHANNEL ) { - if ( ev.mType == CTvScanner::ScannerEvent::EVENT_SCAN_END ) { - CMessage msg; - msg.mType = CTvMsgQueue::TV_MSG_STOP_ANALYZE_TS; - msg.mpData = this; - mTvMsgQueue.sendMsg ( msg ); - } else if ( ev.mType == CTvScanner::ScannerEvent::EVENT_STORE_END ) { - CTvEpg::EpgEvent epgev; - epgev.type = CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE_END; - mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; - sendTvEvent ( epgev ); - } - } else { - sendTvEvent ( ev ); - } -} - -void CTv::onEvent ( const CFrontEnd::FEEvent &ev ) -{ - const char *config_value = NULL; - LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction); - if (mTvAction & TV_ACTION_SCANNING) return; - - //前端事件响应处理 - if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定 - if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //atv and other tvin source not to use it, and if not playing, not use have sig - if ( m_win_mode == PREVIEW_WONDOW ) { - //mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); - mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); - } - - if ( m_autoset_displayfreq) { - mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mB_hdmiout_fbc); - } - TvEvent::SignalInfoEvent ev; - ev.mStatus = TVIN_SIG_STATUS_STABLE; - ev.mTrans_fmt = TVIN_TFMT_2D; - ev.mFmt = TVIN_SIG_FMT_NULL; - ev.mReserved = 0; - sendTvEvent ( ev ); - //if (mAv.WaittingVideoPlaying() == 0) { - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mAv.getVideoResolutionToFmt()); - usleep(50 * 1000); - mAv.EnableVideoNow(); - SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); - //} - Tv_SetAudioInSource(SOURCE_DTV); - } - } else if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_NO_SIG ) { //作为信号消失 - if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //just playing - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - // - TvEvent::SignalInfoEvent ev; - ev.mStatus = TVIN_SIG_STATUS_NOSIG; - ev.mTrans_fmt = TVIN_TFMT_2D; - ev.mFmt = TVIN_SIG_FMT_NULL; - ev.mReserved = 0; - sendTvEvent ( ev ); - } - } - -} - -void CTv::onEvent ( const CTvEpg::EpgEvent &ev ) -{ - switch ( ev.type ) { - case CTvEpg::EpgEvent::EVENT_TDT_END: - LOGD ( "%s, CTv::onEvent epg time = %ld", __FUNCTION__, ev.time ); - mTvTime.setTime ( ev.time ); - break; - - case CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE: { - LOGD ( "%s, CTv:: onEvent channel update", __FUNCTION__ ); - CMessage msg; - msg.mType = CTvMsgQueue::TV_MSG_START_ANALYZE_TS; - msg.mpData = this; - mCurAnalyzeTsChannelID = ev.channelID; - mTvMsgQueue.sendMsg ( msg ); - break; - } - - default: - break; - } - - sendTvEvent ( ev ); -} - - -void CTv::onEvent(const CAv::AVEvent &ev) -{ - const char *config_value = NULL; - LOGD("AVEvent = %d", ev.type); - switch ( ev.type ) { - case CAv::AVEvent::EVENT_AV_STOP: { - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - // - TvEvent::SignalInfoEvent ev; - ev.mStatus = TVIN_SIG_STATUS_NOSIG; - ev.mTrans_fmt = TVIN_TFMT_2D; - ev.mFmt = TVIN_SIG_FMT_NULL; - ev.mReserved = 0; - sendTvEvent ( ev ); - break; - } - case CAv::AVEvent::EVENT_AV_RESUEM: { - //if (mAv.WaittingVideoPlaying() == 0) { - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mAv.getVideoResolutionToFmt()); - usleep(50 * 1000); - mAv.EnableVideoNow(); - SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); - //} - TvEvent::AVPlaybackEvent AvPlayBackEvt; - AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_PLAYBACK_RESUME; - AvPlayBackEvt.mProgramId = ( int ) ev.param; - sendTvEvent(AvPlayBackEvt ); - break; - } - case CAv::AVEvent::EVENT_AV_SCAMBLED: { - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - TvEvent::AVPlaybackEvent AvPlayBackEvt; - AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_SCAMBLED; - AvPlayBackEvt.mProgramId = ( int ) ev.param; - sendTvEvent(AvPlayBackEvt ); - break; - } - case CAv::AVEvent::EVENT_AV_UNSUPPORT: { - LOGD("To AVS or AVS+ format");//just avs format, not unsupport, and avs avs+ - break; - } - default: - break; - } -} - -CTv::CTvMsgQueue::CTvMsgQueue(CTv *tv) -{ - mpTv = tv; -} - -CTv::CTvMsgQueue::~CTvMsgQueue() -{ -} - -void CTv::CTvMsgQueue::handleMessage ( CMessage &msg ) -{ - LOGD ( "%s, CTv::CTvMsgQueue::handleMessage type = %d", __FUNCTION__, msg.mType ); - - switch ( msg.mType ) { - case TV_MSG_COMMON: - break; - - case TV_MSG_STOP_ANALYZE_TS: { - //mpTv->Tv_Stop_Analyze_Ts(); - break; - } - - case TV_MSG_START_ANALYZE_TS: { - //mpTv->Tv_Start_Analyze_Ts ( pTv->mCurAnalyzeTsChannelID ); - break; - } - - case TV_MSG_CHECK_FE_DELAY: { - mpTv->mFrontDev.checkStatusOnce(); - break; - } - case TV_MSG_AV_EVENT: { - mpTv->onEvent(*((CAv::AVEvent *)(msg.mpPara))); - break; - } - case TV_MSG_FE_EVENT: { - mpTv->onEvent(*((CFrontEnd::FEEvent *)(msg.mpPara))); - break; - } - case TV_MSG_SCAN_EVENT: { - mpTv->onEvent(*((CTvScanner::ScannerEvent *)(msg.mpPara))); - break; - } - case TV_MSG_EPG_EVENT: { - mpTv->onEvent(*((CTvEpg::EpgEvent *)(msg.mpPara))); - break; - } - - case TV_MSG_HDMI_SR_CHANGED: { - int sr = ((int *)(msg.mpPara))[0]; - mpTv->onHdmiSrChanged(sr, (((int *)(msg.mpPara))[1] == 0) ? true : false); - break; - } - case TV_MSG_ENABLE_VIDEO_LATER: { - int fc = msg.mpPara[0]; - mpTv->onEnableVideoLater(fc); - break; - } - default: - break; - } -} - -void CTv::onHdmiSrChanged(int sr, bool bInit) -{ - if (bInit) { - LOGD ( "%s, Init HDMI audio, sampling rate:%d", __FUNCTION__, sr ); - sr = HanldeAudioInputSr(sr); - InitTvAudio (sr, CC_IN_USE_SPDIF_DEVICE); - } else { - LOGD ( "%s, Reset HDMI sampling rate to %d", __FUNCTION__, sr ); - AudioChangeSampleRate ( sr ); - } -} - -void CTv::onHMDIAudioStatusChanged(int status) -{ - if (status == 0) {//change to no audio data - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - } else if (status == 1) {//change to audio data come - Tv_SetAudioInSource(m_source_input); - usleep(200 * 1000); - SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); - } -} - -void CTv::CTvMsgQueue::onEvent ( const CTvScanner::ScannerEvent &ev ) -{ - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_SCAN_EVENT; - memcpy(msg.mpPara, &ev, sizeof(ev)); - this->sendMsg ( msg ); -} - -void CTv::CTvMsgQueue::onEvent ( const CFrontEnd::FEEvent &ev ) -{ - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_FE_EVENT; - memcpy(msg.mpPara, &ev, sizeof(ev)); - this->sendMsg ( msg ); -} - -void CTv::CTvMsgQueue::onEvent ( const CTvEpg::EpgEvent &ev ) -{ - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_EPG_EVENT; - memcpy(msg.mpPara, &ev, sizeof(ev)); - this->sendMsg ( msg ); -} - - -void CTv::CTvMsgQueue::onEvent(const CAv::AVEvent &ev) -{ - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_AV_EVENT; - memcpy(msg.mpPara, &ev, sizeof(ev)); - this->sendMsg ( msg ); -} - -int CTv::setTvObserver ( TvIObserver *ob ) -{ - mpObserver = ob; - return 0; -} - -void CTv::sendTvEvent ( const CTvEv &ev ) -{ - //AutoMutex lock(mLock); - /* send sigstate to AutoBackLight */ - if (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT) { - TvEvent::SignalInfoEvent *pEv = (TvEvent::SignalInfoEvent *)(&ev); - if (pEv->mStatus == TVIN_SIG_STATUS_STABLE) { - mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_STABLE); - } else { - mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_NOSIG); - } - } - - LOGD ( "%s, tvaction=%x", __FUNCTION__, mTvAction); - if ((mTvAction & TV_ACTION_SCANNING) && (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT)) { - LOGD("%s, when scanning, not send sig detect event", __FUNCTION__); - return; - } - if ( mpObserver != NULL ) { - mpObserver->onTvEvent ( ev ); - } - - return; -} - -int CTv::ClearAnalogFrontEnd() -{ - return mFrontDev.ClearAnalogFrontEnd (); -} - -int CTv::dtvAutoScan() -{ - AutoMutex lock ( mLock ); - mTvAction = mTvAction | TV_ACTION_SCANNING; - mTvEpg.leaveChannel(); - mAv.StopTS (); - mAv.DisableVideoWithBlueColor(); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); - CTvEvent::CleanAllEvent(); - mTvScanner.setObserver ( &mTvMsgQueue ); - mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; - mFrontDev.Open(FE_DTMB); - mTvScanner.autoDtmbScan();//dtmb - return 0; -} - -int CTv::dtvCleanProgramByFreq ( int freq ) -{ - int iOutRet = 0; - CTvChannel channel; - iOutRet = CTvChannel::SelectByFreq ( freq, channel ); - if ( -1 == iOutRet ) { - LOGD ( "%s, Warnning: Current Freq not have program info in the ts_table\n", __FUNCTION__ ); - } - - iOutRet == CTvProgram::deleteChannelsProgram ( channel ); - return iOutRet; -} - -int CTv::dtvManualScan (int beginFreq, int endFreq, int modulation) -{ - AutoMutex lock ( mLock ); - mTvAction = mTvAction | TV_ACTION_SCANNING; - mTvEpg.leaveChannel(); - mAv.StopTS (); - mAv.DisableVideoWithBlueColor(); - CTvChannel::DeleteBetweenFreq(beginFreq, endFreq); - mTvScanner.setObserver ( &mTvMsgQueue ); - mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; - mFrontDev.Open(FE_DTMB); - int iOutRet = mTvScanner.manualDtmbScan (beginFreq, endFreq, modulation); //dtmb - return iOutRet; -} - -int CTv::dtvAutoScanAtscLock(int attenna, int videoStd, int audioStd) -{ - //showboz - /* int minScanFreq, maxScanFreq, vStd, aStd; - vStd = CC_ATV_VIDEO_STD_PAL; - aStd = CC_ATV_AUDIO_STD_DK; - v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); - - AutoMutex lock ( mLock ); - mTvAction = mTvAction | TV_ACTION_SCANNING; - mTvEpg.leaveChannel(); - mAv.StopTS (); - mAv.DisableVideoWithBlueColor(); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); - CTvEvent::CleanAllEvent(); - mTvScanner.setObserver ( &mTvMsgQueue ); - mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; - mFrontDev.Open(FE_ATSC); - mTvScanner.autoAtscScan(CTvScanner::AM_ATSC_ATTENNA_TYPE_AIR, stdAndColor);//dtmb*/ - return 0; +CTv::~CTv() { + int iRet; + mpObserver = NULL; + CTvSettingunLoad(); + CTvDatabase::deleteTvDb(); + tv_config_unload(); + mAv.Close(); + mTvStatus = TV_INIT_ED; + mFrontDev.Close(); + + if (mpUpgradeFBC != NULL) { + delete mpUpgradeFBC; + mpUpgradeFBC = NULL; + } +} + +void CTv::onEvent ( const CTvScanner::ScannerEvent &ev ) { + LOGD ( "%s, CTv::onEvent lockStatus = %d type = %d\n", __FUNCTION__, ev.mLockedStatus, ev.mType ); + + if ( mDtvScanRunningStatus == DTV_SCAN_RUNNING_ANALYZE_CHANNEL ) { + if ( ev.mType == CTvScanner::ScannerEvent::EVENT_SCAN_END ) { + CMessage msg; + msg.mType = CTvMsgQueue::TV_MSG_STOP_ANALYZE_TS; + msg.mpData = this; + mTvMsgQueue.sendMsg ( msg ); + } else if ( ev.mType == CTvScanner::ScannerEvent::EVENT_STORE_END ) { + CTvEpg::EpgEvent epgev; + epgev.type = CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE_END; + mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; + sendTvEvent ( epgev ); + } + } else { + sendTvEvent ( ev ); + } +} + +void CTv::onEvent ( const CFrontEnd::FEEvent &ev ) { + const char *config_value = NULL; + LOGD ( "%s, FE event type = %d tvaction=%x", __FUNCTION__, ev.mCurSigStaus, mTvAction); + if (mTvAction & TV_ACTION_SCANNING) return; + + //前端事件响应处理 + if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_HAS_SIG ) { //作为信号稳定 + if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //atv and other tvin source not to use it, and if not playing, not use have sig + if ( m_win_mode == PREVIEW_WONDOW ) { + //mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); + mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); + } + + if ( m_autoset_displayfreq) { + mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution() , mHdmiOutFbc); + } + TvEvent::SignalInfoEvent ev; + ev.mStatus = TVIN_SIG_STATUS_STABLE; + ev.mTrans_fmt = TVIN_TFMT_2D; + ev.mFmt = TVIN_SIG_FMT_NULL; + ev.mReserved = 0; + sendTvEvent ( ev ); + //if (mAv.WaittingVideoPlaying() == 0) { + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mAv.getVideoResolutionToFmt()); + usleep(50 * 1000); + mAv.EnableVideoNow(); + SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); + //} + Tv_SetAudioInSource(SOURCE_DTV); + } + } else if ( ev.mCurSigStaus == CFrontEnd::FEEvent::EVENT_FE_NO_SIG ) { //作为信号消失 + if (/*m_source_input == SOURCE_TV || */m_source_input == SOURCE_DTV && (mTvAction & TV_ACTION_PLAYING)) { //just playing + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( config_value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + + TvEvent::SignalInfoEvent ev; + ev.mStatus = TVIN_SIG_STATUS_NOSIG; + ev.mTrans_fmt = TVIN_TFMT_2D; + ev.mFmt = TVIN_SIG_FMT_NULL; + ev.mReserved = 0; + sendTvEvent ( ev ); + } + } +} + +void CTv::onEvent ( const CTvEpg::EpgEvent &ev ) { + switch ( ev.type ) { + case CTvEpg::EpgEvent::EVENT_TDT_END: + LOGD ( "%s, CTv::onEvent epg time = %ld", __FUNCTION__, ev.time ); + mTvTime.setTime ( ev.time ); + break; + + case CTvEpg::EpgEvent::EVENT_CHANNEL_UPDATE: { + LOGD ( "%s, CTv:: onEvent channel update", __FUNCTION__ ); + CMessage msg; + msg.mType = CTvMsgQueue::TV_MSG_START_ANALYZE_TS; + msg.mpData = this; + mCurAnalyzeTsChannelID = ev.channelID; + mTvMsgQueue.sendMsg ( msg ); + break; + } + + default: + break; + } + + sendTvEvent ( ev ); +} + +void CTv::onEvent(const CAv::AVEvent &ev) { + const char *config_value = NULL; + LOGD("AVEvent = %d", ev.type); + switch ( ev.type ) { + case CAv::AVEvent::EVENT_AV_STOP: { + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( config_value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + + TvEvent::SignalInfoEvent ev; + ev.mStatus = TVIN_SIG_STATUS_NOSIG; + ev.mTrans_fmt = TVIN_TFMT_2D; + ev.mFmt = TVIN_SIG_FMT_NULL; + ev.mReserved = 0; + sendTvEvent ( ev ); + break; + } + + case CAv::AVEvent::EVENT_AV_RESUEM: { + //if (mAv.WaittingVideoPlaying() == 0) { + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), + CTvin::Tvin_SourceInputToSourceInputType(m_source_input), + mAv.getVideoResolutionToFmt()); + usleep(50 * 1000); + mAv.EnableVideoNow(); + SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); + //} + TvEvent::AVPlaybackEvent AvPlayBackEvt; + AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_PLAYBACK_RESUME; + AvPlayBackEvt.mProgramId = ( int ) ev.param; + sendTvEvent(AvPlayBackEvt ); + break; + } + + case CAv::AVEvent::EVENT_AV_SCAMBLED: { + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( config_value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + TvEvent::AVPlaybackEvent AvPlayBackEvt; + AvPlayBackEvt.mMsgType = TvEvent::AVPlaybackEvent::EVENT_AV_SCAMBLED; + AvPlayBackEvt.mProgramId = ( int ) ev.param; + sendTvEvent(AvPlayBackEvt ); + break; + } + + case CAv::AVEvent::EVENT_AV_UNSUPPORT: { + LOGD("To AVS or AVS+ format");//just avs format, not unsupport, and avs avs+ + break; + } + + default: + break; + } +} + +CTv::CTvMsgQueue::CTvMsgQueue(CTv *tv) { + mpTv = tv; +} + +CTv::CTvMsgQueue::~CTvMsgQueue() { +} + +void CTv::CTvMsgQueue::handleMessage ( CMessage &msg ) { + LOGD ("%s, CTv::CTvMsgQueue::handleMessage type = %d", __FUNCTION__, msg.mType); + + switch ( msg.mType ) { + case TV_MSG_COMMON: + break; + + case TV_MSG_STOP_ANALYZE_TS: + //mpTv->Tv_Stop_Analyze_Ts(); + break; + + case TV_MSG_START_ANALYZE_TS: + //mpTv->Tv_Start_Analyze_Ts ( pTv->mCurAnalyzeTsChannelID ); + break; + + case TV_MSG_CHECK_FE_DELAY: { + mpTv->mFrontDev.checkStatusOnce(); + break; + } + + case TV_MSG_AV_EVENT: { + mpTv->onEvent(*((CAv::AVEvent *)(msg.mpPara))); + break; + } + + case TV_MSG_FE_EVENT: { + mpTv->onEvent(*((CFrontEnd::FEEvent *)(msg.mpPara))); + break; + } + + case TV_MSG_SCAN_EVENT: { + mpTv->onEvent(*((CTvScanner::ScannerEvent *)(msg.mpPara))); + break; + } + + case TV_MSG_EPG_EVENT: { + mpTv->onEvent(*((CTvEpg::EpgEvent *)(msg.mpPara))); + break; + } + + case TV_MSG_HDMI_SR_CHANGED: { + int sr = ((int *)(msg.mpPara))[0]; + mpTv->onHdmiSrChanged(sr, (((int *)(msg.mpPara))[1] == 0) ? true : false); + break; + } + + case TV_MSG_ENABLE_VIDEO_LATER: { + int fc = msg.mpPara[0]; + mpTv->onEnableVideoLater(fc); + break; + } + + default: + break; + } +} + +void CTv::onHdmiSrChanged(int sr, bool bInit) { + if (bInit) { + LOGD ( "%s, Init HDMI audio, sampling rate:%d", __FUNCTION__, sr ); + sr = HanldeAudioInputSr(sr); + InitTvAudio (sr, CC_IN_USE_SPDIF_DEVICE); + } else { + LOGD ( "%s, Reset HDMI sampling rate to %d", __FUNCTION__, sr ); + AudioChangeSampleRate ( sr ); + } +} + +void CTv::onHMDIAudioStatusChanged(int status) { + if (status == 0) {//change to no audio data + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + } else if (status == 1) {//change to audio data come + Tv_SetAudioInSource(m_source_input); + usleep(200 * 1000); + SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); + } +} + +void CTv::CTvMsgQueue::onEvent ( const CTvScanner::ScannerEvent &ev ) { + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_SCAN_EVENT; + memcpy(msg.mpPara, &ev, sizeof(ev)); + this->sendMsg ( msg ); +} + +void CTv::CTvMsgQueue::onEvent ( const CFrontEnd::FEEvent &ev ) { + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_FE_EVENT; + memcpy(msg.mpPara, &ev, sizeof(ev)); + this->sendMsg ( msg ); +} + +void CTv::CTvMsgQueue::onEvent ( const CTvEpg::EpgEvent &ev ) { + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_EPG_EVENT; + memcpy(msg.mpPara, &ev, sizeof(ev)); + this->sendMsg ( msg ); +} + +void CTv::CTvMsgQueue::onEvent(const CAv::AVEvent &ev) { + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_AV_EVENT; + memcpy(msg.mpPara, &ev, sizeof(ev)); + this->sendMsg ( msg ); +} + +int CTv::setTvObserver ( TvIObserver *ob ) { + mpObserver = ob; + return 0; +} + +void CTv::sendTvEvent ( const CTvEv &ev ) { + //AutoMutex lock(mLock); + /* send sigstate to AutoBackLight */ + if (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT) { + TvEvent::SignalInfoEvent *pEv = (TvEvent::SignalInfoEvent *)(&ev); + if (pEv->mStatus == TVIN_SIG_STATUS_STABLE) { + mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_STABLE); + } else { + mAutoBackLight.updateSigState(mAutoBackLight.SIG_STATE_NOSIG); + } + } + + LOGD ( "%s, tvaction=%x", __FUNCTION__, mTvAction); + if ((mTvAction & TV_ACTION_SCANNING) && (ev.getEvType() == CTvEv::TV_EVENT_SIGLE_DETECT)) { + LOGD("%s, when scanning, not send sig detect event", __FUNCTION__); + return; + } + if ( mpObserver != NULL ) { + mpObserver->onTvEvent ( ev ); + } +} + +int CTv::ClearAnalogFrontEnd() { + return mFrontDev.ClearAnalogFrontEnd (); +} + +int CTv::dtvAutoScan() { + AutoMutex lock ( mLock ); + mTvAction |= TV_ACTION_SCANNING; + mTvEpg.leaveChannel(); + mAv.StopTS (); + mAv.DisableVideoWithBlueColor(); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); + CTvEvent::CleanAllEvent(); + mTvScanner.setObserver ( &mTvMsgQueue ); + mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; + mFrontDev.Open(FE_DTMB); + mTvScanner.autoDtmbScan();//dtmb + return 0; +} + +int CTv::dtvCleanProgramByFreq ( int freq ) { + int iOutRet = 0; + CTvChannel channel; + iOutRet = CTvChannel::SelectByFreq ( freq, channel ); + if ( -1 == iOutRet ) { + LOGD ( "%s, Warnning: Current Freq not have program info in the ts_table\n", __FUNCTION__ ); + } + + iOutRet == CTvProgram::deleteChannelsProgram ( channel ); + return iOutRet; +} + +int CTv::dtvManualScan (int beginFreq, int endFreq, int modulation) { + AutoMutex lock ( mLock ); + mTvAction |= TV_ACTION_SCANNING; + mTvEpg.leaveChannel(); + mAv.StopTS (); + mAv.DisableVideoWithBlueColor(); + CTvChannel::DeleteBetweenFreq(beginFreq, endFreq); + mTvScanner.setObserver ( &mTvMsgQueue ); + mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; + mFrontDev.Open(FE_DTMB); + int iOutRet = mTvScanner.manualDtmbScan (beginFreq, endFreq, modulation); //dtmb + return iOutRet; +} + +int CTv::dtvAutoScanAtscLock(int attenna, int videoStd, int audioStd) { + //for warning + attenna = attenna; + videoStd = videoStd; + audioStd= audioStd; + //showboz + /* int minScanFreq, maxScanFreq, vStd, aStd; + vStd = CC_ATV_VIDEO_STD_PAL; + aStd = CC_ATV_AUDIO_STD_DK; + v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); + + AutoMutex lock ( mLock ); + mTvAction |= TV_ACTION_SCANNING; + mTvEpg.leaveChannel(); + mAv.StopTS (); + mAv.DisableVideoWithBlueColor(); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO ); + CTvEvent::CleanAllEvent(); + mTvScanner.setObserver ( &mTvMsgQueue ); + mDtvScanRunningStatus = DTV_SCAN_RUNNING_NORMAL; + mFrontDev.Open(FE_ATSC); + mTvScanner.autoAtscScan(CTvScanner::AM_ATSC_ATTENNA_TYPE_AIR, stdAndColor);//dtmb*/ + return 0; } //searchType 0:not 256 1:is 256 Program -int CTv::atvAutoScan(int videoStd, int audioStd, int searchType) -{ - int minScanFreq, maxScanFreq, vStd, aStd; - AutoMutex lock ( mLock ); - mAv.DisableVideoWithBlueColor(); - mTvAction = mTvAction | TV_ACTION_SCANNING; - stopPlaying(); - mTvScanner.setObserver ( &mTvMsgQueue ); - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - getATVMinMaxFreq (&minScanFreq, &maxScanFreq ); - if ( minScanFreq == 0 || maxScanFreq == 0 || minScanFreq > maxScanFreq ) { - LOGE ( "%s, auto scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); - return -1; - } - mSigDetectThread.setVdinNoSigCheckKeepTimes(1000, false); - mSigDetectThread.requestAndWaitPauseDetect(); - mSigDetectThread.setObserver(&mTvScannerDetectObserver); - mTvin.Tvin_StopDecoder(); - //if set std null AUTO, use default PAL/DK - //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { - // vStd = CC_ATV_VIDEO_STD_PAL; - // aStd = CC_ATV_AUDIO_STD_DK; - //} else { - vStd = CC_ATV_VIDEO_STD_PAL; - aStd = CC_ATV_AUDIO_STD_DK; - //} - tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); - mTvin.VDIN_OpenPort ( source_port ); - v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); - - int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); - mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); - - if (searchType == 0) { - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); - } else if (searchType == 1) { //type for skyworth, and insert 256 prog, and just update ts table - } - minScanFreq = mFrontDev.formatATVFreq ( minScanFreq ); - maxScanFreq = mFrontDev.formatATVFreq ( maxScanFreq ); - LOGD("%s, atv auto scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); - mFrontDev.Open(FE_ANALOG); - mSigDetectThread.initSigState(); - mSigDetectThread.resumeDetect(); - mTvScanner.autoAtvScan ( minScanFreq, maxScanFreq, stdAndColor, searchType); - return 0; -} - -int CTv::clearAllProgram(int arg0) -{ - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_TV ); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); - CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO); - return 0; -} - -int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, int store_Type , int channel_num ) -{ - int minScanFreq, maxScanFreq, vStd, aStd; - - minScanFreq = mFrontDev.formatATVFreq ( startFreq ); - maxScanFreq = mFrontDev.formatATVFreq ( endFreq ); - if ( minScanFreq == 0 || maxScanFreq == 0 ) { - LOGE ( "%s, munual scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); - return -1; - } - - //if set std null AUTO, use default PAL/DK - //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { - // vStd = CC_ATV_VIDEO_STD_PAL; - // aStd = CC_ATV_AUDIO_STD_DK; - // } else { - vStd = videoStd; - aStd = audioStd; - // } - - AutoMutex lock ( mLock ); - mAv.DisableVideoWithBlueColor(); - mTvAction = mTvAction | TV_ACTION_SCANNING; - mTvScanner.setObserver ( &mTvMsgQueue ); - - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); - - - tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); - mTvin.VDIN_OpenPort ( source_port ); - - int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); - mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); - LOGD("%s, atv manual scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); - mFrontDev.Open(FE_ANALOG); - return mTvScanner.ATVManualScan ( minScanFreq, maxScanFreq, stdAndColor, store_Type, channel_num); -} - -int CTv::getVideoFormatInfo ( int *pWidth, int *pHeight, int *pFPS, int *pInterlace ) -{ - int iOutRet = -1; - AM_AV_VideoStatus_t video_status; - - do { - if ( NULL == pWidth || NULL == pHeight || NULL == pFPS || NULL == pInterlace ) { - break; - } - - iOutRet = mAv.GetVideoStatus (&video_status ); - - if ( AM_SUCCESS != iOutRet ) { - LOGD ( "%s, ERROR: Cann't Get video format info\n", __FUNCTION__); - break; - } - - *pWidth = video_status.src_w; - *pHeight = video_status.src_h; - *pFPS = video_status.fps; - *pInterlace = video_status.interlaced; - //LOGD("%s, w : %d h : %d fps : %d interlaced: %d\n", __FUNCTION__, video_status.src_w,video_status.src_h,video_status.fps,video_status.interlaced); - } while ( false ); - - return iOutRet; - -} - -int CTv::stopScanLock() -{ - AutoMutex lock ( mLock ); - return stopScan(); -} - -int CTv::stopScan() -{ - const char *config_value = NULL; - if (!(mTvAction & TV_ACTION_SCANNING)) { - LOGD("%s, tv not scanning ,return\n", __FUNCTION__); - return 0; - } else { - LOGD("%s, tv scanning , stop it\n", __FUNCTION__); - } - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - mSigDetectThread.requestAndWaitPauseDetect(); - mSigDetectThread.setObserver(this); - mTvEpg.leaveChannel(); - mTvScanner.stopScan(); - mFrontDev.Close(); - mTvAction = mTvAction & ~TV_ACTION_SCANNING; - return 0; -} - -int CTv::playProgramLock ( int progId ) -{ - /*AutoMutex lock ( mLock ); - CTvProgram prog; - int ret = CTvProgram::selectByID ( progId, prog ); - - if ( ret != 0 ) { - return -1; - } - int type = prog.getProgType(); - LOGD ( "%s, blackout = %dprog type = %d id = %d name = %s\n", __FUNCTION__, m_blackout_enable, type, progId, prog.getName().string() ); - if (m_blackout_enable == 1) { - mAv.EnableVideoBlackout(); - }else if (m_blackout_enable == 0){ - mAv.DisableVideoBlackout(); - } - - mTvAction = mTvAction | TV_ACTION_PLAYING; - m_cur_playing_prog_id = progId; - mFrontDev.Open(FE_ANALOG); - if ( m_source_input == SOURCE_TV && type == CTvProgram::TYPE_ATV ) { - playAtvProgram ( progId ); - } else if ( m_source_input == SOURCE_DTV && ( type == CTvProgram::TYPE_DTV || type == CTvProgram::TYPE_RADIO ) ) { - playDtmbProgram ( progId ); - } else { - LOGD ( "%s, source(%d) != type(%d),not play\n", __FUNCTION__, m_source_input, type ); - } - //just for ui,left/right/stereo - int audio_ch = prog.getAudioChannel(); - AM_AOUT_OutputMode_t channel = AM_AOUT_OUTPUT_STEREO; - if (audio_ch == 1) { - channel = AM_AOUT_OUTPUT_STEREO; - } else if (audio_ch == 2) { - channel = AM_AOUT_OUTPUT_DUAL_LEFT; - } else if (audio_ch == 3) { - channel = AM_AOUT_OUTPUT_DUAL_RIGHT; - } - setAudioChannel((int)channel);*/ - return 0; -} - -int CTv::playDvbcProgram ( int progId ) -{ - LOGD ( "%s, progId = %d\n", __FUNCTION__, progId ); - - CTvProgram prog; - int ret = CTvProgram::selectByID ( progId, prog ); - - if ( ret != 0 ) { - return -1; - } - - LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() ); - CTvChannel channel; - prog.getChannel ( channel ); - - mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getSymbolRate(), channel.getModulation() ); - - int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; - - CTvProgram::Video *pV = prog.getVideo(); - CTvProgram::Audio *pA; - - if ( pV != NULL ) { - vpid = pV->getPID(); - vfmt = pV->getFormat(); - } - - int aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); - - if ( aindex >= 0 ) { - pA = prog.getAudio ( aindex ); - - if ( pA != NULL ) { - apid = pA->getPID(); - afmt = pA->getFormat(); - } - } - mTvEpg.leaveProgram(); - mTvEpg.leaveChannel(); - startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); - - mTvEpg.enterChannel ( channel.getID() ); - mTvEpg.enterProgram ( prog.getID() ); - return 0; -} - -int CTv::getAudioTrackNum ( int progId ) -{ - int iRet, iOutCnt = 0; - CTvProgram prog; - - do { - if ( 0 > progId ) { - break; - } - - iRet = CTvProgram::selectByID ( progId, prog ); - - if ( 0 != iRet ) { - break; - } - - iOutCnt = prog.getAudioTrackSize(); - - } while ( false ); - - return iOutCnt; -} - -int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang ) -{ - int iRet, iOutRet = -1; - CTvProgram prog; - CTvProgram::Audio *pA = NULL; - - do { - if ( NULL == pAFmt || idx < 0 ) { - break; - } - - iRet = CTvProgram::selectByID ( progId, prog ); - - if ( 0 != iRet ) { - break; - } - - if ( idx >= prog.getAudioTrackSize() ) { - break; - } - - pA = prog.getAudio ( idx ); - - if ( NULL == pA ) { - break; - } - - *pAFmt = pA->getFormat(); - lang = pA->getLang(); - } while ( false ); - - return iOutRet; -} - -int CTv::switchAudioTrack ( int aPid, int aFmt, int aParam ) -{ - int iOutRet = 0; - - do { - if ( aPid < 0 || aFmt < 0 ) { - break; - } - - iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); - - LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); - } while ( false ); - - return iOutRet; -} - -int CTv::switchAudioTrack ( int progId, int idx ) -{ - int iOutRet = 0; - CTvProgram prog; - CTvProgram::Audio *pAudio = NULL; - int aPid = -1; - int aFmt = -1; - - do { - if ( idx < 0 ) { - break; - } - - iOutRet = CTvProgram::selectByID ( progId, prog ); - - if ( 0 != iOutRet ) { - break; - } - if (prog.getAudioTrackSize() <= 1) { - LOGD("%s, just one audio track, not to switch", __FUNCTION__); - break; - } - if ( idx >= prog.getAudioTrackSize() ) { - break; - } - - pAudio = prog.getAudio ( idx ); - - if ( NULL == pAudio ) { - break; - } - - aPid = pAudio->getPID(); - aFmt = pAudio->getFormat(); - - if ( aPid < 0 || aFmt < 0 ) { - break; - } - - iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); - - LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); - } while ( false ); - - return iOutRet; -} - -int CTv::ResetAudioDecoderForPCMOutput() -{ - int iOutRet = 0; - - iOutRet = mAv.ResetAudioDecoder (); - LOGD ( "%s, iOutRet = %d AM_AV_ResetAudioDecoder\n", __FUNCTION__, iOutRet ); - return iOutRet; -} - -int CTv::playDtvProgram ( int mode, int freq, int para1, int para2, int vpid, int vfmt, int apid, int afmt, int pcr, int audioCompetation) -{ - AutoMutex lock ( mLock ); - mTvAction = mTvAction | TV_ACTION_PLAYING; - if ( m_blackout_enable == 1 ) { - mAv.EnableVideoBlackout(); - } else if ( m_blackout_enable == 0 ) { - mAv.DisableVideoBlackout(); - } - mFrontDev.Open(FE_ANALOG); - mFrontDev.setPara ( mode, freq, para1, para2); - mTvAction = mTvAction | TV_ACTION_PLAYING; - startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); - // - CMessage msg; - msg.mDelayMs = 2000; - msg.mType = CTvMsgQueue::TV_MSG_CHECK_FE_DELAY; - mTvMsgQueue.sendMsg ( msg ); - SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); - return 0; -} - - -int CTv::playDtmbProgram ( int progId ) -{ - CTvProgram prog; - CTvChannel channel; - int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; - int aindex; - CTvProgram::Audio *pA; - CTvProgram::Video *pV; - int ret = CTvProgram::selectByID ( progId, prog ); - - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - saveDTVProgramID ( progId ); - prog.getChannel ( channel ); - //音量补偿 - int chanVolCompValue = 0; - chanVolCompValue = GetAudioVolumeCompensationVal(progId); - SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue ); - - mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 ); - - pV = prog.getVideo(); - - if ( pV != NULL ) { - vpid = pV->getPID(); - vfmt = pV->getFormat(); - } - - aindex = prog.getCurrAudioTrackIndex(); - - if ( -1 == aindex ) { //db is default - aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); - - if ( aindex >= 0 ) { - prog.setCurrAudioTrackIndex ( progId, aindex ); - } - } - - if ( aindex >= 0 ) { - pA = prog.getAudio ( aindex ); - - if ( pA != NULL ) { - apid = pA->getPID(); - afmt = pA->getFormat(); - } - } - - mTvEpg.leaveProgram(); - mTvEpg.leaveChannel(); - startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); - mTvEpg.enterChannel ( channel.getID() ); - mTvEpg.enterProgram ( prog.getID() ); - return 0; -} - -int CTv::playAtvProgram (int freq, int videoStd, int audioStd, int fineTune, int audioCompetation) -{ - mTvAction = mTvAction | TV_ACTION_PLAYING; - if ( m_blackout_enable == 1 ) { - mAv.EnableVideoBlackout(); - } else if ( m_blackout_enable == 0 ) { - mAv.DisableVideoBlackout(); - } - SetAudioMuteForTv ( CC_AUDIO_MUTE ); - //image selecting channel - mSigDetectThread.requestAndWaitPauseDetect(); - mTvin.Tvin_StopDecoder(); - mFrontDev.Open(FE_ANALOG); - //set CVBS - int fmt = CFrontEnd::stdEnumToCvbsFmt (videoStd, audioStd); - mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); - - v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (videoStd, audioStd); - //set TUNER - mFrontDev.setPara (FE_ANALOG, freq, stdAndColor, 1); - - - mSigDetectThread.setObserver ( this ); - mSigDetectThread.initSigState(); - mSigDetectThread.resumeDetect(1000); - - SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); - return 0; -} - -int CTv::resetFrontEndPara ( frontend_para_set_t feParms ) -{ - if ( feParms.mode == FE_ANALOG ) { - int progID = -1; - int tmpFreq = feParms.freq; - int tmpfineFreq = feParms.para2; - int mode = feParms.mode; - - //get tunerStd from videoStd and audioStd - v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (feParms.videoStd, feParms.audioStd); - - LOGD("%s, resetFrontEndPara- vstd=%d astd=%d stdandcolor=%lld", __FUNCTION__, feParms.videoStd, feParms.audioStd, stdAndColor); - - //set frontend parameters to tuner dev - mSigDetectThread.requestAndWaitPauseDetect(); - mTvin.Tvin_StopDecoder(); - - //set CVBS - int fmt = CFrontEnd::stdEnumToCvbsFmt (feParms.videoStd, feParms.audioStd ); - mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); - - //set TUNER - usleep(400 * 1000); - mFrontDev.setPara ( FE_ANALOG, tmpFreq, stdAndColor, 1 ); - usleep(400 * 1000); - if ( tmpfineFreq != 0 ) { - mFrontDev.fineTune ( tmpfineFreq / 1000 ); - } - - mSigDetectThread.initSigState(); - mSigDetectThread.resumeDetect(); - } else if ( feParms.mode == FE_DTMB ) { - mFrontDev.setPara ( FE_DTMB, feParms.freq, feParms.para1, feParms.para2 ); - } - - return 0; -} - -int CTv::resetDmxAndAvSource() -{ - AM_DMX_Source_t curdmxSource; - mFrontDev.GetTSSource ( &curdmxSource ); - LOGD ( "%s, AM_FEND_GetTSSource %d", __FUNCTION__, curdmxSource ); - mTvDmx.Close(); - AM_DMX_OpenPara_t para; - memset ( ¶, 0, sizeof ( para ) ); - mTvDmx.Open (para); - mTvDmx.SetSource(curdmxSource ); - AM_AV_TSSource_t ts_source = ( AM_AV_TSSource_t ) curdmxSource; - mAv.SetTSSource (ts_source ); - return 0; -} - -int CTv::SetCurProgramAudioVolumeCompensationVal ( int tmpVal ) -{ - SetAudioVolumeCompensationVal ( tmpVal ); - SetAudioMasterVolume (GetAudioMasterVolume() ); - - LOGD ( "%s, VolumeCompensationVal = %d, id = %d\n", __FUNCTION__, tmpVal, m_cur_playing_prog_id ); - CTvProgram prog; - if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { - LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); - return -1; - } - - if (prog.updateVolComp ( m_cur_playing_prog_id, tmpVal ) != 0 ) { - LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__); - return -1; - } - return 0; -} - -int CTv::GetAudioVolumeCompensationVal(int progxxId) -{ - int tmpVolValue = 0; - CTvProgram prog; - if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { - LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); - return tmpVolValue; - } - tmpVolValue = prog.getChanVolume (); - LOGD ( "%s,progid = %d CompensationVal = %d\n", __FUNCTION__, m_cur_playing_prog_id, tmpVolValue ); - if (tmpVolValue > 20 || tmpVolValue < -20) tmpVolValue = 0; - return tmpVolValue; -} - -int CTv::startPlayTv ( int source, int vid, int aid, int vfat, int afat ) -{ - int ret = 0; - - if ( source == SOURCE_DTV ) { - AM_FileEcho ( DEVICE_CLASS_TSYNC_AV_THRESHOLD_MIN, AV_THRESHOLD_MIN_MS ); - LOGD ( "%s, startPlayTv", __FUNCTION__); - mAv.StartTS (vid, aid, ( AM_AV_VFormat_t ) vfat, ( AM_AV_AFormat_t ) afat ); - } else { - - } - return ret; -} - -int CTv::stopPlayingLock() -{ - AutoMutex lock ( mLock ); - if (getSubSwitchStatus() == 1) - stopSubtitle(); - return stopPlaying(); -} - -int CTv::stopPlaying() -{ - const char *config_value = NULL; - if (!(mTvAction & TV_ACTION_PLAYING)) { - LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction); - return 0; - } - mSigDetectThread.requestAndWaitPauseDetect(); - mAv.EnableVideoBlackout(); - if (m_source_input == SOURCE_TV) { - //first mute - SetAudioMuteForTv(CC_AUDIO_MUTE); - ClearAnalogFrontEnd(); - } else if (m_source_input == SOURCE_DTV) { - //mFrontDev.setPara(FE_DTMB, 51000000, 0, 0); - mAv.StopTS (); - mTvEpg.leaveChannel(); - mTvEpg.leaveProgram(); - } - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - mTvAction = mTvAction & ~TV_ACTION_PLAYING; - return 0; -} - -int CTv::GetATVAFCType() -{ - return 1; -} - -int CTv::GetATVSourceTimerSwitch() -{ - return 1; -} -int CTv::getAudioChannel() -{ - int iRet = -1; - AM_AOUT_OutputMode_t audioChanneleMod; - do { - iRet = mAv.AudioGetOutputMode (&audioChanneleMod ); - if ( AM_SUCCESS != iRet ) { - LOGD ( "%s, jianfei.lan GetOutputMode is FAILED %d\n", __FUNCTION__, iRet ); - break; - } - LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod ); - } while ( 0 ); - return audioChanneleMod; -} - -int CTv::setAudioChannel ( int channelIdx ) -{ - int iOutRet = 0; - AM_AOUT_OutputMode_t audioChanneleMod; - LOGD ( "%s, channelIdx : %d\n", __FUNCTION__, channelIdx ); - audioChanneleMod = ( AM_AOUT_OutputMode_t ) channelIdx; - iOutRet = mAv.AudioSetOutputMode (audioChanneleMod ); - int aud_ch = 1; - if (audioChanneleMod == AM_AOUT_OUTPUT_STEREO) { - aud_ch = 1; - } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_LEFT) { - aud_ch = 2; - } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_RIGHT) { - aud_ch = 3; - } - CTvProgram::updateAudioChannel(m_cur_playing_prog_id, aud_ch); - if ( AM_SUCCESS != iOutRet) { - LOGD ( "%s, jianfei.lan %s AM_AOUT_SetOutputMode device is FAILED %d\n", __FUNCTION__, "TV", iOutRet ); - } - return 0; -} - -int CTv::getFrontendSignalStrength() -{ - int Strength = 0; - Strength = mFrontDev.getStrength(); - return Strength; -} - -int CTv::getFrontendSNR() -{ - int snr = 0; - snr = mFrontDev.getSNR(); - return snr; -} - -int CTv::getFrontendBER() -{ - int ber = 0; - ber = mFrontDev.getBER(); - return ber; - -} - -int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info ) -{ - CTvProgram prog; - CTvChannel channel; - Vector > out; - memset ( &chan_info, sizeof ( chan_info ), 0 ); - chan_info.freq = 44250000; - chan_info.uInfo.atvChanInfo.videoStd = CC_ATV_VIDEO_STD_PAL; - chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; - static const int CVBS_ID = -1; - if (dbID == CVBS_ID) { - unsigned char std; - SSMReadCVBSStd(&std); - chan_info.uInfo.atvChanInfo.videoStd = (atv_video_std_t)std; - chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; - chan_info.uInfo.atvChanInfo.isAutoStd = (std == CC_ATV_VIDEO_STD_AUTO) ? 1 : 0; - return 0; - } - - int ret = CTvProgram::selectByID ( dbID, prog ); - if ( ret != 0 ) { - LOGD ( "getChannelinfo , select dbid=%d,is not exist", dbID); - return -1; - } - prog.getChannel ( channel ); - - if ( CTvProgram::TYPE_ATV == prog.getProgType() ) { - chan_info.freq = channel.getFrequency(); - chan_info.uInfo.atvChanInfo.finefreq = channel.getAfcData(); - LOGD("%s, get channel std = %lld", __FUNCTION__, channel.getStd()); - chan_info.uInfo.atvChanInfo.videoStd = - ( atv_video_std_t ) CFrontEnd::stdAndColorToVideoEnum ( channel.getStd() ); - chan_info.uInfo.atvChanInfo.audioStd = - ( atv_audio_std_t ) CFrontEnd::stdAndColorToAudioEnum ( channel.getStd() ); - chan_info.uInfo.atvChanInfo.isAutoStd = ((channel.getStd() & V4L2_COLOR_STD_AUTO) == V4L2_COLOR_STD_AUTO) ? 1 : 0; - } else if ( CTvProgram::TYPE_DTV == prog.getProgType() || CTvProgram::TYPE_RADIO == prog.getProgType()) { - chan_info.freq = channel.getFrequency(); - chan_info.uInfo.dtvChanInfo.strength = getFrontendSignalStrength(); - chan_info.uInfo.dtvChanInfo.quality = getFrontendSNR(); - chan_info.uInfo.dtvChanInfo.ber = getFrontendBER(); - } - - return 0; -} - -bool CTv::Tv_Start_Analyze_Ts ( int channelID ) -{ - int freq, ret; - CTvChannel channel; - - AutoMutex lock ( mLock ); - mAv.StopTS (); - mAv.DisableVideoWithBlueColor(); - ret = CTvChannel::selectByID ( channelID, channel ); - - if ( ret != 0 ) { - LOGD ( "%s, CTv tv_updatats can not get freq by channel ID", __FUNCTION__ ); - return false; - } - - mTvAction = mTvAction | TV_ACTION_SCANNING; - freq = channel.getFrequency(); - LOGD ( "%s, the freq = %d", __FUNCTION__, freq ); - mDtvScanRunningStatus = DTV_SCAN_RUNNING_ANALYZE_CHANNEL; - mTvScanner.setObserver ( &mTvMsgQueue ); - mTvScanner.manualDtmbScan ( freq, freq ); //dtmb - return true; -} - -bool CTv::Tv_Stop_Analyze_Ts() -{ - stopScanLock(); - return true; -} - - -int CTv::saveATVProgramID ( int dbID ) -{ - config_set_int ( "TV", "atv.get.program.id", dbID ); - return 0; -} - -int CTv::getATVProgramID ( void ) -{ - return config_get_int ( "TV", "atv.get.program.id", -1 ); -} - -int CTv::saveDTVProgramID ( int dbID ) -{ - config_set_int ( "TV", "dtv.get.program.id", dbID ); - return 0;; -} - -int CTv::getDTVProgramID ( void ) -{ - return config_get_int ( "TV", "dtv.get.program.id", -1 ); -} - -int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq ) -{ - int tmpVal, i = 0; - const char *config_value; - const char *strDelimit = ","; - char *token = NULL; - - *scanMinFreq = 44250000; - *scanMaxFreq = 868250000; - - config_value = config_get_str ( "ATV", "atv.get.min.max.freq", "null" ); - - if ( strcmp ( config_value, "null" ) == 0 ) { - LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ ); - return -1; - } - - char data_str[512]; - memset ( ( void * ) data_str, 0, sizeof ( data_str ) ); - strncpy ( data_str, config_value, sizeof ( data_str ) - 1 ); - - char *pSave; - token = strtok_r ( data_str, strDelimit, &pSave); - sscanf ( token, "%d", scanMinFreq ); - token = strtok_r ( NULL, strDelimit , &pSave); - - if ( token != NULL ) { - sscanf ( token, "%d", scanMaxFreq ); - return 0; - } - return 0; -} - -int CTv::IsDVISignal() -{ - return ( ( TVIN_SIG_FMT_NULL != mSigDetectThread.getCurSigInfo().fmt ) && ( mSigDetectThread.getCurSigInfo().reserved & 0x1 ) ); -} - -int CTv::getHDMIFrameRate() -{ - int ConstRate[5] = {24, 25, 30, 50, 60}; - float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; //偏差便 - int fps = mSigDetectThread.getCurSigInfo().fps; - int i = 0; - for (; i < 5; i++) { - if (abs(ConstRate[i] - fps) < ConstRateDiffHz[i]) - fps = ConstRate[i]; - } - return fps; -} - -tv_source_input_t CTv::GetLastSourceInput ( void ) -{ - return m_last_source_input; -} - -int CTv::isVgaFmtInHdmi ( void ) -{ - tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; - - if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { - return -1; - } - - return CTvin::isVgaFmtInHdmi ( fmt ); -} - -int CTv::isSDFmtInHdmi ( void ) -{ - tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; - - if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { - return -1; - } - - - return CTvin::isSDFmtInHdmi ( fmt ); -} - -void CTv::print_version_info ( void ) -{ - // print tvapi version info - LOGD ( "libtvservice git branch:%s\n", tvservice_get_git_branch_info() ); - LOGD ( "libtvservice git version:%s\n", tvservice_get_git_version_info() ); - LOGD ( "libtvservice Last Changed:%s\n", tvservice_get_last_chaned_time_info() ); - LOGD ( "libtvservice Last Build:%s\n", tvservice_get_build_time_info() ); - LOGD ( "libtvservice Builer Name:%s\n", tvservice_get_build_name_info() ); - LOGD ( "libtvservice board version:%s\n", tvservice_get_board_version_info() ); - LOGD ( "\n\n"); - // print dvb version info - LOGD ( "libdvb git branch:%s\n", dvb_get_git_branch_info() ); - LOGD ( "libdvb git version:%s\n", dvb_get_git_version_info() ); - LOGD ( "libdvb Last Changed:%s\n", dvb_get_last_chaned_time_info() ); - LOGD ( "libdvb Last Build:%s\n", dvb_get_build_time_info() ); - LOGD ( "libdvb Builer Name:%s\n", dvb_get_build_name_info() ); -} - -int CTv::Tvin_GetTvinConfig ( void ) -{ - const char *config_value; - int i = 0; - - - config_value = config_get_str ( "TV", "tvin.kernelpet_disable", "null" ); - - if ( strcmp ( config_value, "disable" ) == 0 ) { - gTvinConfig.kernelpet_disable = true; - } else { - gTvinConfig.kernelpet_disable = false; - } - - config_value = config_get_str ( "TV", "tvin.kernelpet.timeout", "null" ); - gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); - - if ( gTvinConfig.kernelpet_timeout <= 0 || gTvinConfig.kernelpet_timeout > 40 ) { - gTvinConfig.kernelpet_timeout = 10; - } - - - config_value = config_get_str ( "TV", "tvin.userpet", "null" ); - - if ( strcmp ( config_value, "enable" ) == 0 ) { - gTvinConfig.userpet = true; - } else { - gTvinConfig.userpet = false; - } - - config_value = config_get_str ( "TV", "tvin.userpet.timeout", "null" ); - gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); - - if ( gTvinConfig.userpet_timeout <= 0 || gTvinConfig.userpet_timeout > 100 ) { - gTvinConfig.userpet_timeout = 10; - } - - config_value = config_get_str ( "TV", "tvin.userpet.reset", "null" ); - - if ( strcmp ( config_value, "disable" ) == 0 ) { - gTvinConfig.userpet_reset = 0; - } else { - gTvinConfig.userpet_reset = 1; - } - - - - return 0; -} - -TvRunStatus_t CTv::GetTvStatus() -{ - Mutex::Autolock _l ( mLock ); - return mTvStatus; -} - -int CTv::OpenTv ( void ) -{ - int tmp_val = 0; - const char *value; - Tv_Spread_Spectrum(); - //reboot system by fbc setting. - value = config_get_str ( "TV", "fbc.get.panelinfo", "null" ); - LOGD("%s fbc-------------------\n", value); - if ( strcmp ( value, "edid" ) == 0 ) { - if (reboot_sys_by_fbc_edid_info() == 0) { - } - } else if ( strcmp ( value, "uart" ) == 0 ) { - if (reboot_sys_by_fbc_uart_panel_info(fbcIns) == 0) { - } - } - - LOGD ( "%s, tv open\n", __FUNCTION__); - char prop_value[PROPERTY_VALUE_MAX]; - memset ( prop_value, '\0', PROPERTY_VALUE_MAX ); - - mTvin.Tvin_LoadSourceInputToPortMap(); - - SSMHandlePreCopying(); - // - if ( SSMDeviceMarkCheck() < 0 ) { - SSMRestoreDeviceMarkValues(); - Tv_SSMRestoreDefaultSetting(); - } - mTvin.OpenTvin(); - mTvin.init_vdin(); - mTvin.Tv_init_afe(); - mVpp.Vpp_Init(getPqDbPath()); - TvAudioOpen(); - SetAudioVolDigitLUTTable(SOURCE_MPEG); - - SSMSetHDCPKey(); - system ( "/system/bin/dec" ); - - //set color filter - // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" ); - - - value = config_get_str ( "TV", "ssm.hdmi_av.hotplug.detect.en", "null" ); - if ( strtoul(value, NULL, 10) == 1 ) { - m_hdmiav_hotplugdetect_en = 1; - } else { - m_hdmiav_hotplugdetect_en = 0; - } - - value = config_get_str ( "TV", "tvin.autoset.displayfreq", "null" ); - - if ( strcmp ( value, "enable" ) == 0 ) { - m_autoset_displayfreq = true; - } else { - m_autoset_displayfreq = false; - } - - if (mTvin.VDIN_GetDisplayVFreq() == 30) { - m_autoset_displayfreq = false; - } - - Tv_HandeHDMIEDIDFilePathConfig(); - - value = config_get_str ( "TV", "ssm.handle.hdmi.edid.en", "null" ); - - if ( strtoul(value, NULL, 10) == 1 ) { - LOGD( "%s, get config \"%s\" is \"%s\".\n", - __FUNCTION__, "ssm.handle.hdmi.edid.en", value ); - //get hdmi edid use mode - char prop_value[256]; - memset( prop_value, '\0', 256 ); - property_get( "ubootenv.var.outputmode", prop_value, "null" ); - LOGD( "%s, get property \"%s\" is \"%s\".\n", - __FUNCTION__, "ubootenv.var.outputmode", prop_value ); - if ( strcmp ( prop_value, "null" ) != 0 ) { - config_set_str ( "TV", "ssm.handle.hdmi.edid.use", prop_value ); - int i; - char edid_path[256]; - char edid_path_cfg[256]; - //set file's path for hdmi edid of each port - for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { - memset( edid_path, '\0', 256 ); - memset( edid_path_cfg, '\0', 256 ); - sprintf ( edid_path, "/system/etc/%s_port%d.bin", prop_value, i ); - sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); - config_set_str ( "TV", edid_path_cfg, edid_path ); - } - } else { - //set default hdmi edid - config_set_str ( "TV", "ssm.handle.hdmi.edid.use", "hdmi_edid" ); - int i; - char edid_path[256]; - char edid_path_cfg[256]; - //set file's path for hdmi edid of each port - for ( i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { - memset( edid_path, '\0', 256 ); - memset( edid_path_cfg, '\0', 256 ); - sprintf ( edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i ); - sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); - config_set_str ( "TV", edid_path_cfg, edid_path ); - } - } - m_is_set_hdmi_edid = true; - } - // - unsigned char val = 0; - Tvin_GetTvinConfig(); - m_last_source_input = SOURCE_INVALID; - m_source_input = SOURCE_INVALID; - m_mode_3d = VIDEO_3D_MODE_DISABLE; - m_hdmi_sampling_rate = 0; - int8_t blackout_enable; - SSMReadBlackoutEnable(&blackout_enable); - m_blackout_enable = blackout_enable; - - - // - //dtv init - int rt = -1; - //opendemux(); - //rt = mFrontDev.Open(FE_ANALOG); - //mFrontDev.autoLoadFE(); - //rt = mFrontDev.Open(FE_ANALOG); - AM_DMX_OpenPara_t para_dmx; - memset ( ¶_dmx, 0, sizeof ( AM_DMX_OpenPara_t ) ); - mTvDmx.Open(para_dmx ); - mTvDmx.SetSource (AM_DMX_SRC_TS2); - mAv.Open(); - mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" ); - resetDmxAndAvSource(); -// mSourceConnectDetectThread.startDetect(); - mSourceConnectDetectThread.startDetect(); - - if (SSMReadSerialCMDSwitchValue() == 1) { - SetSerialSwitch(SERIAL_A, 1); - } - ClearAnalogFrontEnd(); - - mTvStatus = TV_OPEN_ED; - - mHDMIRxCEC.start(); - mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); - return 0; -} - -int CTv::CloseTv ( void ) -{ - LOGD ( "tv close"); - mSigDetectThread.stopDetect(); - if (mpUpgradeFBC != NULL) { - mpUpgradeFBC->stop(); - } - mTvin.Tv_uninit_afe(); - mTvin.uninit_vdin(); - mVpp.Vpp_Uninit(); - TvMisc_DisableWDT ( gTvinConfig.userpet ); - mTvStatus = TV_CLOSE_ED; - return 0; -} - - -int CTv::StartTvLock () -{ - LOGD ( "%s, tv start status = %d", __FUNCTION__, mTvStatus); - if (mTvStatus == TV_START_ED) - return 0; - - Mutex::Autolock _l ( mLock ); - mTvAction = mTvAction | TV_ACTION_STARTING; - mAv.ClearVideoBuffer(); - SwitchAVOutBypass(0); - InitSetTvAudioCard(); - SetAudioMuteForTv(CC_AUDIO_MUTE); - mFrontDev.Open(FE_ANALOG); - mFrontDev.autoLoadFE(); - mSigDetectThread.startDetect(); - mSigDetectThread.initSigState(); - mTvMsgQueue.startMsgQueue(); - resetDmxAndAvSource(); - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); - TvMisc_EnableWDT ( gTvinConfig.kernelpet_disable, gTvinConfig.userpet, gTvinConfig.kernelpet_timeout, gTvinConfig.userpet_timeout, gTvinConfig.userpet_reset ); - am_phase_t am_phase; - if (mVpp.getPqData()->PQ_GetPhaseArray ( &am_phase ) == 0 ) { - mTvin.TvinApi_SetCompPhase(am_phase); - } - mTvin.TvinApi_SetCompPhaseEnable ( 1 ); - mTvin.VDIN_EnableRDMA ( 1 ); - - //win pos - tvin_window_pos_t win_pos; - Vpp_GetDisplayResolutionInfo(&win_pos); - SetPreviewWindow ( win_pos ); - - mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); - if ( mTvin.Tvin_RemovePath ( TV_PATH_TYPE_DEFAULT ) ) { - mTvin.Tvin_AddPath ( TV_PATH_DECODER_NEW3D_WITHOUTPPMGR_AMVIDEO ); - } - - mAv.SetVideoWindow (0, 0, 0, 0 ); - - mTvAction = mTvAction & ~TV_ACTION_STARTING; - mTvStatus = TV_START_ED; - return 0; -} - -int CTv::DoInstabootSuspend() -{ - CTvDatabase::GetTvDb()->UnInitTvDb(); - CTvSettingdoSuspend(); - mVpp.doSuspend(); - LOGD("%s, \n", __FUNCTION__); - return 0; -} - -int CTv::DoInstabootResume() -{ - CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); - CTvSettingdoResume(); - mVpp.doResume(); - LOGD("%s, \n", __FUNCTION__); - return 0; -} - -int CTv::DoSuspend(int type) -{ - if (type == 1) - { - DoInstabootSuspend(); - } - return 0; -} - -int CTv::DoResume(int type) -{ - if (type == 1) - { - DoInstabootResume(); - } - return 0; -} - -int CTv::StopTvLock ( void ) -{ - LOGD("%s, call Tv_Stop status = %d \n", __FUNCTION__, mTvStatus); - const char *value; - Mutex::Autolock _l ( mLock ); - mAv.DisableVideoWithBlackColor(); +int CTv::atvAutoScan(int videoStd, int audioStd, int searchType) { + int minScanFreq, maxScanFreq, vStd, aStd; + AutoMutex lock ( mLock ); + mAv.DisableVideoWithBlueColor(); + mTvAction |= TV_ACTION_SCANNING; + stopPlaying(); + mTvScanner.setObserver ( &mTvMsgQueue ); + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + getATVMinMaxFreq (&minScanFreq, &maxScanFreq ); + if ( minScanFreq == 0 || maxScanFreq == 0 || minScanFreq > maxScanFreq ) { + LOGE ( "%s, auto scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); + return -1; + } + mSigDetectThread.setVdinNoSigCheckKeepTimes(1000, false); + mSigDetectThread.requestAndWaitPauseDetect(); + mSigDetectThread.setObserver(&mTvScannerDetectObserver); + mTvin.Tvin_StopDecoder(); + //if set std null AUTO, use default PAL/DK + //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { + // vStd = CC_ATV_VIDEO_STD_PAL; + // aStd = CC_ATV_AUDIO_STD_DK; + //} else { + vStd = CC_ATV_VIDEO_STD_PAL; + aStd = CC_ATV_AUDIO_STD_DK; + //} + tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); + mTvin.VDIN_OpenPort ( source_port ); + v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); + + int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); + mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); + + if (searchType == 0) { + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); + } else if (searchType == 1) { //type for skyworth, and insert 256 prog, and just update ts table + } + minScanFreq = mFrontDev.formatATVFreq ( minScanFreq ); + maxScanFreq = mFrontDev.formatATVFreq ( maxScanFreq ); + LOGD("%s, atv auto scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); + mFrontDev.Open(FE_ANALOG); + mSigDetectThread.initSigState(); + mSigDetectThread.resumeDetect(); + mTvScanner.autoAtvScan ( minScanFreq, maxScanFreq, stdAndColor, searchType); + return 0; +} + +int CTv::clearAllProgram(int arg0) { + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_ATV ); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_TV ); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_DTV ); + CTvProgram::CleanAllProgramBySrvType ( CTvProgram::TYPE_RADIO); + return 0; +} + +int CTv::atvMunualScan ( int startFreq, int endFreq, int videoStd, int audioStd, + int store_Type , int channel_num ) { + int minScanFreq, maxScanFreq, vStd, aStd; + + minScanFreq = mFrontDev.formatATVFreq ( startFreq ); + maxScanFreq = mFrontDev.formatATVFreq ( endFreq ); + if ( minScanFreq == 0 || maxScanFreq == 0 ) { + LOGE ( "%s, munual scan freq set is error min=%d, max=%d", __FUNCTION__, minScanFreq, maxScanFreq ); + return -1; + } + + //if set std null AUTO, use default PAL/DK + //if(videoStd == CC_ATV_VIDEO_STD_AUTO) { + // vStd = CC_ATV_VIDEO_STD_PAL; + // aStd = CC_ATV_AUDIO_STD_DK; + // } else { + vStd = videoStd; + aStd = audioStd; + // } + + AutoMutex lock ( mLock ); + mAv.DisableVideoWithBlueColor(); + mTvAction |= TV_ACTION_SCANNING; + mTvScanner.setObserver ( &mTvMsgQueue ); + + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor(vStd, aStd); + + + tvin_port_t source_port = mTvin.Tvin_GetSourcePortBySourceInput(SOURCE_TV); + mTvin.VDIN_OpenPort ( source_port ); + + int fmt = CFrontEnd::stdEnumToCvbsFmt (vStd, aStd); + mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) TVIN_SIG_FMT_NULL ); + LOGD("%s, atv manual scan vstd=%d, astd=%d stdandcolor=%lld", __FUNCTION__, vStd, aStd, stdAndColor); + mFrontDev.Open(FE_ANALOG); + return mTvScanner.ATVManualScan ( minScanFreq, maxScanFreq, stdAndColor, store_Type, channel_num); +} + +int CTv::getVideoFormatInfo ( int *pWidth, int *pHeight, int *pFPS, int *pInterlace ) { + int iOutRet = -1; + AM_AV_VideoStatus_t video_status; + + do { + if ( NULL == pWidth || NULL == pHeight || NULL == pFPS || NULL == pInterlace ) { + break; + } + + iOutRet = mAv.GetVideoStatus (&video_status ); + + if ( AM_SUCCESS != iOutRet ) { + LOGD ( "%s, ERROR: Cann't Get video format info\n", __FUNCTION__); + break; + } + + *pWidth = video_status.src_w; + *pHeight = video_status.src_h; + *pFPS = video_status.fps; + *pInterlace = video_status.interlaced; + //LOGD("%s, w : %d h : %d fps : %d interlaced: %d\n", __FUNCTION__, video_status.src_w,video_status.src_h,video_status.fps,video_status.interlaced); + } while ( false ); + + return iOutRet; +} + +int CTv::stopScanLock() { + AutoMutex lock ( mLock ); + return stopScan(); +} + +int CTv::stopScan() { + const char *config_value = NULL; + if (!(mTvAction & TV_ACTION_SCANNING)) { + LOGD("%s, tv not scanning ,return\n", __FUNCTION__); + return 0; + } + + LOGD("%s, tv scanning , stop it\n", __FUNCTION__); + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( config_value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + mSigDetectThread.requestAndWaitPauseDetect(); + mSigDetectThread.setObserver(this); + mTvEpg.leaveChannel(); + mTvScanner.stopScan(); + mFrontDev.Close(); + mTvAction &= ~TV_ACTION_SCANNING; + return 0; +} + +int CTv::playProgramLock ( int progId ) { + /*AutoMutex lock ( mLock ); + CTvProgram prog; + int ret = CTvProgram::selectByID ( progId, prog ); + + if ( ret != 0 ) { + return -1; + } + int type = prog.getProgType(); + LOGD ( "%s, blackout = %dprog type = %d id = %d name = %s\n", __FUNCTION__, m_blackout_enable, type, progId, prog.getName().string() ); + if (m_blackout_enable == 1) { + mAv.EnableVideoBlackout(); + }else if (m_blackout_enable == 0){ + mAv.DisableVideoBlackout(); + } + + mTvAction |= TV_ACTION_PLAYING; + m_cur_playing_prog_id = progId; + mFrontDev.Open(FE_ANALOG); + if ( m_source_input == SOURCE_TV && type == CTvProgram::TYPE_ATV ) { + playAtvProgram ( progId ); + } else if ( m_source_input == SOURCE_DTV && ( type == CTvProgram::TYPE_DTV || type == CTvProgram::TYPE_RADIO ) ) { + playDtmbProgram ( progId ); + } else { + LOGD ( "%s, source(%d) != type(%d),not play\n", __FUNCTION__, m_source_input, type ); + } + //just for ui,left/right/stereo + int audio_ch = prog.getAudioChannel(); + AM_AOUT_OutputMode_t channel = AM_AOUT_OUTPUT_STEREO; + if (audio_ch == 1) { + channel = AM_AOUT_OUTPUT_STEREO; + } else if (audio_ch == 2) { + channel = AM_AOUT_OUTPUT_DUAL_LEFT; + } else if (audio_ch == 3) { + channel = AM_AOUT_OUTPUT_DUAL_RIGHT; + } + setAudioChannel((int)channel);*/ + return 0; +} + +int CTv::playDvbcProgram ( int progId ) { + LOGD ( "%s, progId = %d\n", __FUNCTION__, progId ); + + CTvProgram prog; + int ret = CTvProgram::selectByID ( progId, prog ); + + if ( ret != 0 ) { + return -1; + } + + LOGD ( "%s, prog name = %s\n", __FUNCTION__, prog.getName().string() ); + CTvChannel channel; + prog.getChannel ( channel ); + + mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getSymbolRate(), channel.getModulation() ); + + int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; + + CTvProgram::Video *pV = prog.getVideo(); + CTvProgram::Audio *pA; + + if ( pV != NULL ) { + vpid = pV->getPID(); + vfmt = pV->getFormat(); + } + + int aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); + + if ( aindex >= 0 ) { + pA = prog.getAudio ( aindex ); + + if ( pA != NULL ) { + apid = pA->getPID(); + afmt = pA->getFormat(); + } + } + mTvEpg.leaveProgram(); + mTvEpg.leaveChannel(); + startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); + + mTvEpg.enterChannel ( channel.getID() ); + mTvEpg.enterProgram ( prog.getID() ); + return 0; +} + +int CTv::getAudioTrackNum ( int progId ) { + int iRet, iOutCnt = 0; + CTvProgram prog; + + do { + if ( 0 > progId ) { + break; + } + + iRet = CTvProgram::selectByID ( progId, prog ); + if ( 0 != iRet ) { + break; + } + + iOutCnt = prog.getAudioTrackSize(); + } while ( false ); + + return iOutCnt; +} + +int CTv::getAudioInfoByIndex ( int progId, int idx, int *pAFmt, String8 &lang ) { + int iRet, iOutRet = -1; + CTvProgram prog; + CTvProgram::Audio *pA = NULL; + + do { + if ( NULL == pAFmt || idx < 0 ) { + break; + } + + iRet = CTvProgram::selectByID ( progId, prog ); + + if ( 0 != iRet ) { + break; + } + + if ( idx >= prog.getAudioTrackSize() ) { + break; + } + + pA = prog.getAudio ( idx ); + + if ( NULL == pA ) { + break; + } + + *pAFmt = pA->getFormat(); + lang = pA->getLang(); + } while ( false ); + + return iOutRet; +} + +int CTv::switchAudioTrack ( int aPid, int aFmt, int aParam ) { + int iOutRet = 0; + + do { + if ( aPid < 0 || aFmt < 0 ) { + break; + } + + iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); + LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); + } while ( false ); + + return iOutRet; +} + +int CTv::switchAudioTrack ( int progId, int idx ) { + int iOutRet = 0; + CTvProgram prog; + CTvProgram::Audio *pAudio = NULL; + int aPid = -1; + int aFmt = -1; + + do { + if ( idx < 0 ) { + break; + } + + iOutRet = CTvProgram::selectByID ( progId, prog ); + + if ( 0 != iOutRet ) { + break; + } + if (prog.getAudioTrackSize() <= 1) { + LOGD("%s, just one audio track, not to switch", __FUNCTION__); + break; + } + if ( idx >= prog.getAudioTrackSize() ) { + break; + } + + pAudio = prog.getAudio ( idx ); + if ( NULL == pAudio ) { + break; + } + + aPid = pAudio->getPID(); + aFmt = pAudio->getFormat(); + if ( aPid < 0 || aFmt < 0 ) { + break; + } + + iOutRet = mAv.SwitchTSAudio (( uint16_t ) aPid, ( AM_AV_AFormat_t ) aFmt ); + LOGD ( "%s, iOutRet = %d AM_AV_SwitchTSAudio\n", __FUNCTION__, iOutRet ); + } while ( false ); + + return iOutRet; +} + +int CTv::ResetAudioDecoderForPCMOutput() { + int iOutRet = 0; + + iOutRet = mAv.ResetAudioDecoder (); + LOGD ( "%s, iOutRet = %d AM_AV_ResetAudioDecoder\n", __FUNCTION__, iOutRet ); + return iOutRet; +} + +int CTv::playDtvProgram ( int mode, int freq, int para1, int para2, + int vpid, int vfmt, int apid, int afmt, int pcr, int audioCompetation) { + AutoMutex lock ( mLock ); + mTvAction |= TV_ACTION_PLAYING; + if ( m_blackout_enable == 1 ) { + mAv.EnableVideoBlackout(); + } else if ( m_blackout_enable == 0 ) { + mAv.DisableVideoBlackout(); + } + mFrontDev.Open(FE_ANALOG); + mFrontDev.setPara ( mode, freq, para1, para2); + mTvAction |= TV_ACTION_PLAYING; + startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); + // + CMessage msg; + msg.mDelayMs = 2000; + msg.mType = CTvMsgQueue::TV_MSG_CHECK_FE_DELAY; + mTvMsgQueue.sendMsg ( msg ); + SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); + return 0; +} + + +int CTv::playDtmbProgram ( int progId ) { + CTvProgram prog; + CTvChannel channel; + int vpid = 0x1fff, apid = 0x1fff, vfmt = -1, afmt = -1; + int aindex; + CTvProgram::Audio *pA; + CTvProgram::Video *pV; + int ret = CTvProgram::selectByID ( progId, prog ); + + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + saveDTVProgramID ( progId ); + prog.getChannel ( channel ); + //音量补偿 + int chanVolCompValue = 0; + chanVolCompValue = GetAudioVolumeCompensationVal(progId); + SetCurProgramAudioVolumeCompensationVal ( chanVolCompValue ); + + mFrontDev.setPara ( channel.getMode(), channel.getFrequency(), channel.getBandwidth(), 0 ); + + pV = prog.getVideo(); + + if ( pV != NULL ) { + vpid = pV->getPID(); + vfmt = pV->getFormat(); + } + + aindex = prog.getCurrAudioTrackIndex(); + if ( -1 == aindex ) { //db is default + aindex = prog.getCurrentAudio ( String8 ( "eng" ) ); + if ( aindex >= 0 ) { + prog.setCurrAudioTrackIndex ( progId, aindex ); + } + } + + if ( aindex >= 0 ) { + pA = prog.getAudio ( aindex ); + if ( pA != NULL ) { + apid = pA->getPID(); + afmt = pA->getFormat(); + } + } + + mTvEpg.leaveProgram(); + mTvEpg.leaveChannel(); + startPlayTv ( SOURCE_DTV, vpid, apid, vfmt, afmt ); + mTvEpg.enterChannel ( channel.getID() ); + mTvEpg.enterProgram ( prog.getID() ); + return 0; +} + +int CTv::playAtvProgram (int freq, int videoStd, int audioStd, int fineTune, int audioCompetation) { + mTvAction |= TV_ACTION_PLAYING; + if ( m_blackout_enable == 1 ) { + mAv.EnableVideoBlackout(); + } else if ( m_blackout_enable == 0 ) { + mAv.DisableVideoBlackout(); + } + SetAudioMuteForTv ( CC_AUDIO_MUTE ); + //image selecting channel + mSigDetectThread.requestAndWaitPauseDetect(); + mTvin.Tvin_StopDecoder(); + mFrontDev.Open(FE_ANALOG); + //set CVBS + int fmt = CFrontEnd::stdEnumToCvbsFmt (videoStd, audioStd); + mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); + + v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (videoStd, audioStd); + //set TUNER + mFrontDev.setPara (FE_ANALOG, freq, stdAndColor, 1); + + mSigDetectThread.setObserver ( this ); + mSigDetectThread.initSigState(); + mSigDetectThread.resumeDetect(1000); + + SetCurProgramAudioVolumeCompensationVal ( audioCompetation ); + return 0; +} + +int CTv::resetFrontEndPara ( frontend_para_set_t feParms ) { + if ( feParms.mode == FE_ANALOG ) { + int progID = -1; + int tmpFreq = feParms.freq; + int tmpfineFreq = feParms.para2; + int mode = feParms.mode; + + //get tunerStd from videoStd and audioStd + v4l2_std_id stdAndColor = mFrontDev.enumToStdAndColor (feParms.videoStd, feParms.audioStd); + + LOGD("%s, resetFrontEndPara- vstd=%d astd=%d stdandcolor=%lld", __FUNCTION__, feParms.videoStd, feParms.audioStd, stdAndColor); + + //set frontend parameters to tuner dev + mSigDetectThread.requestAndWaitPauseDetect(); + mTvin.Tvin_StopDecoder(); + + //set CVBS + int fmt = CFrontEnd::stdEnumToCvbsFmt (feParms.videoStd, feParms.audioStd ); + mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); + + //set TUNER + usleep(400 * 1000); + mFrontDev.setPara ( FE_ANALOG, tmpFreq, stdAndColor, 1 ); + usleep(400 * 1000); + if ( tmpfineFreq != 0 ) { + mFrontDev.fineTune ( tmpfineFreq / 1000 ); + } + + mSigDetectThread.initSigState(); + mSigDetectThread.resumeDetect(); + } else if ( feParms.mode == FE_DTMB ) { + mFrontDev.setPara ( FE_DTMB, feParms.freq, feParms.para1, feParms.para2 ); + } + + return 0; +} + +int CTv::resetDmxAndAvSource() { + AM_DMX_Source_t curdmxSource; + mFrontDev.GetTSSource ( &curdmxSource ); + LOGD ( "%s, AM_FEND_GetTSSource %d", __FUNCTION__, curdmxSource ); + mTvDmx.Close(); + AM_DMX_OpenPara_t para; + memset ( ¶, 0, sizeof ( para ) ); + mTvDmx.Open (para); + mTvDmx.SetSource(curdmxSource ); + AM_AV_TSSource_t ts_source = ( AM_AV_TSSource_t ) curdmxSource; + mAv.SetTSSource (ts_source ); + return 0; +} + +int CTv::SetCurProgramAudioVolumeCompensationVal ( int tmpVal ) { + SetAudioVolumeCompensationVal ( tmpVal ); + SetAudioMasterVolume (GetAudioMasterVolume() ); + + LOGD ( "%s, VolumeCompensationVal = %d, id = %d\n", __FUNCTION__, tmpVal, m_cur_playing_prog_id ); + CTvProgram prog; + if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { + LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); + return -1; + } + + if (prog.updateVolComp ( m_cur_playing_prog_id, tmpVal ) != 0 ) { + LOGE ( "%s, atv progID is not matching the db's\n", __FUNCTION__); + return -1; + } + return 0; +} + +int CTv::GetAudioVolumeCompensationVal(int progxxId) { + int tmpVolValue = 0; + CTvProgram prog; + if ( CTvProgram::selectByID ( m_cur_playing_prog_id, prog ) != 0 ) { + LOGE ( "%s, atv progID is not matching the db's ret = 0\n", __FUNCTION__ ); + return tmpVolValue; + } + tmpVolValue = prog.getChanVolume (); + LOGD ( "%s,progid = %d CompensationVal = %d\n", __FUNCTION__, m_cur_playing_prog_id, tmpVolValue ); + if (tmpVolValue > 20 || tmpVolValue < -20) tmpVolValue = 0; + return tmpVolValue; +} + +int CTv::startPlayTv ( int source, int vid, int aid, int vfat, int afat ) { + if ( source == SOURCE_DTV ) { + AM_FileEcho ( DEVICE_CLASS_TSYNC_AV_THRESHOLD_MIN, AV_THRESHOLD_MIN_MS ); + LOGD ( "%s, startPlayTv", __FUNCTION__); + mAv.StartTS (vid, aid, ( AM_AV_VFormat_t ) vfat, ( AM_AV_AFormat_t ) afat ); + } + return 0; +} + +int CTv::stopPlayingLock() { + AutoMutex lock ( mLock ); + if (getSubSwitchStatus() == 1) + stopSubtitle(); + return stopPlaying(); +} + +int CTv::stopPlaying() { + const char *config_value = NULL; + if (!(mTvAction & TV_ACTION_PLAYING)) { + LOGD("%s, stopplay cur action = %x not playing , return", __FUNCTION__, mTvAction); + return 0; + } + mSigDetectThread.requestAndWaitPauseDetect(); + mAv.EnableVideoBlackout(); + if (m_source_input == SOURCE_TV) { + //first mute + SetAudioMuteForTv(CC_AUDIO_MUTE); + ClearAnalogFrontEnd(); + } else if (m_source_input == SOURCE_DTV) { + //mFrontDev.setPara(FE_DTMB, 51000000, 0, 0); + mAv.StopTS (); + mTvEpg.leaveChannel(); + mTvEpg.leaveProgram(); + } + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( config_value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + mTvAction &= ~TV_ACTION_PLAYING; + return 0; +} + +int CTv::GetATVAFCType() { + return 1; +} + +int CTv::GetATVSourceTimerSwitch() { + return 1; +} + +int CTv::getAudioChannel() { + int iRet = -1; + AM_AOUT_OutputMode_t audioChanneleMod; + do { + iRet = mAv.AudioGetOutputMode (&audioChanneleMod ); + if ( AM_SUCCESS != iRet ) { + LOGD ( "%s, jianfei.lan GetOutputMode is FAILED %d\n", __FUNCTION__, iRet ); + break; + } + LOGD ( "%s, jianfei.lan getAudioChannel iRet : %d audioChanneleMod %d\n", __FUNCTION__, iRet, audioChanneleMod ); + } while ( 0 ); + return audioChanneleMod; +} + +int CTv::setAudioChannel ( int channelIdx ) { + int iOutRet = 0; + AM_AOUT_OutputMode_t audioChanneleMod; + LOGD ( "%s, channelIdx : %d\n", __FUNCTION__, channelIdx ); + audioChanneleMod = ( AM_AOUT_OutputMode_t ) channelIdx; + iOutRet = mAv.AudioSetOutputMode (audioChanneleMod ); + int aud_ch = 1; + if (audioChanneleMod == AM_AOUT_OUTPUT_STEREO) { + aud_ch = 1; + } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_LEFT) { + aud_ch = 2; + } else if (audioChanneleMod == AM_AOUT_OUTPUT_DUAL_RIGHT) { + aud_ch = 3; + } + CTvProgram::updateAudioChannel(m_cur_playing_prog_id, aud_ch); + if ( AM_SUCCESS != iOutRet) { + LOGD ( "%s, jianfei.lan TV AM_AOUT_SetOutputMode device is FAILED %d\n", __FUNCTION__, iOutRet ); + } + return 0; +} + +int CTv::getFrontendSignalStrength() { + int Strength = 0; + Strength = mFrontDev.getStrength(); + return Strength; +} + +int CTv::getFrontendSNR() { + int snr = 0; + snr = mFrontDev.getSNR(); + return snr; +} + +int CTv::getFrontendBER() { + int ber = 0; + ber = mFrontDev.getBER(); + return ber; +} + +int CTv::getChannelInfoBydbID ( int dbID, channel_info_t &chan_info ) { + CTvProgram prog; + CTvChannel channel; + Vector > out; + memset ( &chan_info, sizeof ( chan_info ), 0 ); + chan_info.freq = 44250000; + chan_info.uInfo.atvChanInfo.videoStd = CC_ATV_VIDEO_STD_PAL; + chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; + static const int CVBS_ID = -1; + if (dbID == CVBS_ID) { + unsigned char std; + SSMReadCVBSStd(&std); + chan_info.uInfo.atvChanInfo.videoStd = (atv_video_std_t)std; + chan_info.uInfo.atvChanInfo.audioStd = CC_ATV_AUDIO_STD_DK; + chan_info.uInfo.atvChanInfo.isAutoStd = (std == CC_ATV_VIDEO_STD_AUTO) ? 1 : 0; + return 0; + } + + int ret = CTvProgram::selectByID ( dbID, prog ); + if ( ret != 0 ) { + LOGD ( "getChannelinfo , select dbid=%d,is not exist", dbID); + return -1; + } + prog.getChannel ( channel ); + + if ( CTvProgram::TYPE_ATV == prog.getProgType() ) { + chan_info.freq = channel.getFrequency(); + chan_info.uInfo.atvChanInfo.finefreq = channel.getAfcData(); + LOGD("%s, get channel std = %lld", __FUNCTION__, channel.getStd()); + chan_info.uInfo.atvChanInfo.videoStd = + ( atv_video_std_t ) CFrontEnd::stdAndColorToVideoEnum ( channel.getStd() ); + chan_info.uInfo.atvChanInfo.audioStd = + ( atv_audio_std_t ) CFrontEnd::stdAndColorToAudioEnum ( channel.getStd() ); + chan_info.uInfo.atvChanInfo.isAutoStd = ((channel.getStd() & V4L2_COLOR_STD_AUTO) == V4L2_COLOR_STD_AUTO) ? 1 : 0; + } else if ( CTvProgram::TYPE_DTV == prog.getProgType() || CTvProgram::TYPE_RADIO == prog.getProgType()) { + chan_info.freq = channel.getFrequency(); + chan_info.uInfo.dtvChanInfo.strength = getFrontendSignalStrength(); + chan_info.uInfo.dtvChanInfo.quality = getFrontendSNR(); + chan_info.uInfo.dtvChanInfo.ber = getFrontendBER(); + } + + return 0; +} + +bool CTv::Tv_Start_Analyze_Ts ( int channelID ) { + int freq, ret; + CTvChannel channel; + + AutoMutex lock ( mLock ); + mAv.StopTS (); + mAv.DisableVideoWithBlueColor(); + ret = CTvChannel::selectByID ( channelID, channel ); + if ( ret != 0 ) { + LOGD ( "%s, CTv tv_updatats can not get freq by channel ID", __FUNCTION__ ); + return false; + } + + mTvAction |= TV_ACTION_SCANNING; + freq = channel.getFrequency(); + LOGD ( "%s, the freq = %d", __FUNCTION__, freq ); + mDtvScanRunningStatus = DTV_SCAN_RUNNING_ANALYZE_CHANNEL; + mTvScanner.setObserver ( &mTvMsgQueue ); + mTvScanner.manualDtmbScan ( freq, freq ); //dtmb + return true; +} + +bool CTv::Tv_Stop_Analyze_Ts() { + stopScanLock(); + return true; +} + +int CTv::saveATVProgramID ( int dbID ) { + config_set_int ( CFG_SECTION_TV, "atv.get.program.id", dbID ); + return 0; +} + +int CTv::getATVProgramID ( void ) { + return config_get_int ( CFG_SECTION_TV, "atv.get.program.id", -1 ); +} + +int CTv::saveDTVProgramID ( int dbID ) { + config_set_int ( CFG_SECTION_TV, "dtv.get.program.id", dbID ); + return 0; +} + +int CTv::getDTVProgramID ( void ) { + return config_get_int ( CFG_SECTION_TV, "dtv.get.program.id", -1 ); +} + +int CTv::getATVMinMaxFreq ( int *scanMinFreq, int *scanMaxFreq ) { + int tmpVal, i = 0; + const char *config_value; + const char *strDelimit = ","; + char *token = NULL; + + *scanMinFreq = 44250000; + *scanMaxFreq = 868250000; + + config_value = config_get_str ( CFG_SECTION_ATV, "atv.get.min.max.freq", "null" ); + + if ( strcmp ( config_value, "null" ) == 0 ) { + LOGD ( "%s, atv.get.min.max.freq not set config\n", __FUNCTION__ ); + return -1; + } + + char data_str[512]; + memset ( ( void * ) data_str, 0, sizeof ( data_str ) ); + strncpy ( data_str, config_value, sizeof ( data_str ) - 1 ); + + char *pSave; + token = strtok_r ( data_str, strDelimit, &pSave); + sscanf ( token, "%d", scanMinFreq ); + token = strtok_r ( NULL, strDelimit , &pSave); + + if ( token != NULL ) { + sscanf ( token, "%d", scanMaxFreq ); + } + return 0; +} + +int CTv::IsDVISignal() { + return ( ( TVIN_SIG_FMT_NULL != mSigDetectThread.getCurSigInfo().fmt ) && ( mSigDetectThread.getCurSigInfo().reserved & 0x1 ) ); +} + +int CTv::getHDMIFrameRate() { + int ConstRate[5] = {24, 25, 30, 50, 60}; + float ConstRateDiffHz[5] = {0.5, 0.5, 0.5, 2, 2}; //偏差便 + int fps = mSigDetectThread.getCurSigInfo().fps; + int i = 0; + for (; i < 5; i++) { + if (abs(ConstRate[i] - fps) < ConstRateDiffHz[i]) + fps = ConstRate[i]; + } + return fps; +} + +tv_source_input_t CTv::GetLastSourceInput ( void ) { + return m_last_source_input; +} + +int CTv::isVgaFmtInHdmi ( void ) { + tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; + + if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { + return -1; + } + return CTvin::isVgaFmtInHdmi ( fmt ); +} + +int CTv::isSDFmtInHdmi ( void ) { + tvin_sig_fmt_t fmt = mSigDetectThread.getCurSigInfo().fmt; + + if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { + return -1; + } + return CTvin::isSDFmtInHdmi ( fmt ); +} + +void CTv::print_version_info ( void ) { + // print tvapi version info + LOGD ( "libtvservice git branch:%s\n", tvservice_get_git_branch_info() ); + LOGD ( "libtvservice git version:%s\n", tvservice_get_git_version_info() ); + LOGD ( "libtvservice Last Changed:%s\n", tvservice_get_last_chaned_time_info() ); + LOGD ( "libtvservice Last Build:%s\n", tvservice_get_build_time_info() ); + LOGD ( "libtvservice Builer Name:%s\n", tvservice_get_build_name_info() ); + LOGD ( "libtvservice board version:%s\n", tvservice_get_board_version_info() ); + LOGD ( "\n\n"); + // print dvb version info + LOGD ( "libdvb git branch:%s\n", dvb_get_git_branch_info() ); + LOGD ( "libdvb git version:%s\n", dvb_get_git_version_info() ); + LOGD ( "libdvb Last Changed:%s\n", dvb_get_last_chaned_time_info() ); + LOGD ( "libdvb Last Build:%s\n", dvb_get_build_time_info() ); + LOGD ( "libdvb Builer Name:%s\n", dvb_get_build_name_info() ); +} + +int CTv::Tvin_GetTvinConfig ( void ) { + const char *config_value; + int i = 0; + + config_value = config_get_str ( CFG_SECTION_TV, "tvin.kernelpet_disable", "null" ); + if ( strcmp ( config_value, "disable" ) == 0 ) { + gTvinConfig.kernelpet_disable = true; + } else { + gTvinConfig.kernelpet_disable = false; + } + + config_value = config_get_str ( CFG_SECTION_TV, "tvin.kernelpet.timeout", "null" ); + gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); + + if ( gTvinConfig.kernelpet_timeout <= 0 || gTvinConfig.kernelpet_timeout > 40 ) { + gTvinConfig.kernelpet_timeout = 10; + } + + config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet", "null" ); + if ( strcmp ( config_value, "enable" ) == 0 ) { + gTvinConfig.userpet = true; + } else { + gTvinConfig.userpet = false; + } + + config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet.timeout", "null" ); + gTvinConfig.userpet_timeout = ( unsigned int ) strtol ( config_value, NULL, 10 ); + + if ( gTvinConfig.userpet_timeout <= 0 || gTvinConfig.userpet_timeout > 100 ) { + gTvinConfig.userpet_timeout = 10; + } + + config_value = config_get_str ( CFG_SECTION_TV, "tvin.userpet.reset", "null" ); + if ( strcmp ( config_value, "disable" ) == 0 ) { + gTvinConfig.userpet_reset = 0; + } else { + gTvinConfig.userpet_reset = 1; + } + return 0; +} + +TvRunStatus_t CTv::GetTvStatus() { + Mutex::Autolock _l ( mLock ); + return mTvStatus; +} + +int CTv::OpenTv ( void ) { + int tmp_val = 0; + const char *value; + Tv_Spread_Spectrum(); + //reboot system by fbc setting. + value = config_get_str ( CFG_SECTION_TV, "fbc.get.panelinfo", "null" ); + LOGD("%s fbc-------------------\n", value); + if ( strcmp ( value, "edid" ) == 0 ) { + reboot_sys_by_fbc_edid_info(); + } else if ( strcmp ( value, "uart" ) == 0 ) { + reboot_sys_by_fbc_uart_panel_info(fbcIns); + } + + LOGD ( "%s, tv open\n", __FUNCTION__); + char prop_value[PROPERTY_VALUE_MAX] = {0}; + + mTvin.Tvin_LoadSourceInputToPortMap(); + + SSMHandlePreCopying(); + if ( SSMDeviceMarkCheck() < 0 ) { + SSMRestoreDeviceMarkValues(); + Tv_SSMRestoreDefaultSetting(); + } + mTvin.OpenTvin(); + mTvin.init_vdin(); + mTvin.Tv_init_afe(); + mVpp.Vpp_Init(getPqDbPath()); + TvAudioOpen(); + SetAudioVolDigitLUTTable(SOURCE_MPEG); + + SSMSetHDCPKey(); + system ( "/system/bin/dec" ); + + //set color filter + // SetFileAttrValue ( "/sys/module/amvideo/parameters/filt_mode", "0x2100" ); + value = config_get_str ( CFG_SECTION_TV, "ssm.hdmi_av.hotplug.detect.en", "null" ); + if ( strtoul(value, NULL, 10) == 1 ) { + m_hdmiav_hotplugdetect_en = 1; + } else { + m_hdmiav_hotplugdetect_en = 0; + } + + value = config_get_str ( CFG_SECTION_TV, "tvin.autoset.displayfreq", "null" ); + + if ( strcmp ( value, "enable" ) == 0 ) { + m_autoset_displayfreq = true; + } else { + m_autoset_displayfreq = false; + } + + if (mTvin.VDIN_GetDisplayVFreq() == 30) { + m_autoset_displayfreq = false; + } + + Tv_HandeHDMIEDIDFilePathConfig(); + + value = config_get_str ( CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null" ); + + if ( strtoul(value, NULL, 10) == 1 ) { + LOGD( "%s, get config \"%s\" is \"%s\".\n", __FUNCTION__, "ssm.handle.hdmi.edid.en", value ); + //get hdmi edid use mode + char prop_value[256] = {0}; + property_get( "ubootenv.var.outputmode", prop_value, "null" ); + LOGD( "%s, get property \"%s\" is \"%s\".\n", __FUNCTION__, "ubootenv.var.outputmode", prop_value ); + if ( strcmp ( prop_value, "null" ) != 0 ) { + config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, prop_value ); + char edid_path[256]; + char edid_path_cfg[256]; + //set file's path for hdmi edid of each port + for (int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { + memset( edid_path, '\0', 256 ); + memset( edid_path_cfg, '\0', 256 ); + sprintf ( edid_path, "/system/etc/%s_port%d.bin", prop_value, i ); + sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); + config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); + } + } else { + //set default hdmi edid + config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid" ); + char edid_path[256]; + char edid_path_cfg[256]; + //set file's path for hdmi edid of each port + for ( int i = 1; i <= SSM_HDMI_PORT_MAX; i++ ) { + memset( edid_path, '\0', 256 ); + memset( edid_path_cfg, '\0', 256 ); + sprintf ( edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i ); + sprintf ( edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i ); + config_set_str ( CFG_SECTION_TV, edid_path_cfg, edid_path ); + } + } + m_is_set_hdmi_edid = true; + } + // + unsigned char val = 0; + Tvin_GetTvinConfig(); + m_last_source_input = SOURCE_INVALID; + m_source_input = SOURCE_INVALID; + m_mode_3d = VIDEO_3D_MODE_DISABLE; + m_hdmi_sampling_rate = 0; + int8_t blackout_enable; + SSMReadBlackoutEnable(&blackout_enable); + m_blackout_enable = blackout_enable; + + //dtv init + int rt = -1; + //opendemux(); + //rt = mFrontDev.Open(FE_ANALOG); + //mFrontDev.autoLoadFE(); + //rt = mFrontDev.Open(FE_ANALOG); + AM_DMX_OpenPara_t para_dmx; + memset ( ¶_dmx, 0, sizeof ( AM_DMX_OpenPara_t ) ); + mTvDmx.Open(para_dmx ); + mTvDmx.SetSource (AM_DMX_SRC_TS2); + mAv.Open(); + mTvEpg.Init ( 0, 0, 1, "eng zho chi", "GB2312" ); + resetDmxAndAvSource(); + // mSourceConnectDetectThread.startDetect(); + mSourceConnectDetectThread.startDetect(); + + if (SSMReadSerialCMDSwitchValue() == 1) { + SetSerialSwitch(SERIAL_A, 1); + } + ClearAnalogFrontEnd(); + + mTvStatus = TV_OPEN_ED; + + mHDMIRxCEC.start(); + mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); + return 0; +} + +int CTv::CloseTv ( void ) { + LOGD ( "tv close"); + mSigDetectThread.stopDetect(); + if (mpUpgradeFBC != NULL) { + mpUpgradeFBC->stop(); + } + mTvin.Tv_uninit_afe(); + mTvin.uninit_vdin(); + mVpp.Vpp_Uninit(); + TvMisc_DisableWDT ( gTvinConfig.userpet ); + mTvStatus = TV_CLOSE_ED; + return 0; +} + +int CTv::StartTvLock () { + LOGD ( "%s, tv start status = %d", __FUNCTION__, mTvStatus); + if (mTvStatus == TV_START_ED) + return 0; + + Mutex::Autolock _l ( mLock ); + mTvAction |= TV_ACTION_STARTING; + mAv.ClearVideoBuffer(); + SwitchAVOutBypass(0); + InitSetTvAudioCard(); + SetAudioMuteForTv(CC_AUDIO_MUTE); + mFrontDev.Open(FE_ANALOG); + mFrontDev.autoLoadFE(); + mSigDetectThread.startDetect(); + mSigDetectThread.initSigState(); + mTvMsgQueue.startMsgQueue(); + resetDmxAndAvSource(); + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); + TvMisc_EnableWDT ( gTvinConfig.kernelpet_disable, gTvinConfig.userpet, gTvinConfig.kernelpet_timeout, gTvinConfig.userpet_timeout, gTvinConfig.userpet_reset ); + am_phase_t am_phase; + if (mVpp.getPqData()->PQ_GetPhaseArray ( &am_phase ) == 0 ) { + mTvin.TvinApi_SetCompPhase(am_phase); + } + mTvin.TvinApi_SetCompPhaseEnable ( 1 ); + mTvin.VDIN_EnableRDMA ( 1 ); + + //win pos + tvin_window_pos_t win_pos; + Vpp_GetDisplayResolutionInfo(&win_pos); + SetPreviewWindow ( win_pos ); + + mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); + if ( mTvin.Tvin_RemovePath ( TV_PATH_TYPE_DEFAULT ) ) { + mTvin.Tvin_AddPath ( TV_PATH_DECODER_NEW3D_WITHOUTPPMGR_AMVIDEO ); + } + + mAv.SetVideoWindow (0, 0, 0, 0 ); + + mTvAction &= ~TV_ACTION_STARTING; + mTvStatus = TV_START_ED; + return 0; +} + +int CTv::DoInstabootSuspend() { + CTvDatabase::GetTvDb()->UnInitTvDb(); + CTvSettingdoSuspend(); + mVpp.doSuspend(); + LOGD("%s, \n", __FUNCTION__); + return 0; +} + +int CTv::DoInstabootResume() { + CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); + CTvSettingdoResume(); + mVpp.doResume(); + LOGD("%s, \n", __FUNCTION__); + return 0; +} + +int CTv::DoSuspend(int type) { + if (type == 1) { + DoInstabootSuspend(); + } + return 0; +} + +int CTv::DoResume(int type) { + if (type == 1) { + DoInstabootResume(); + } + return 0; +} + +int CTv::StopTvLock ( void ) { + LOGD("%s, call Tv_Stop status = %d \n", __FUNCTION__, mTvStatus); + const char *value; + Mutex::Autolock _l ( mLock ); + mAv.DisableVideoWithBlackColor(); mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); - //we should stop audio first for audio mute. - mTvAction = mTvAction | TV_ACTION_STOPING; - mTvin.Tvin_StopDecoder(); - mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); - mTvin.VDIN_ClosePort(); - mTvMsgQueue.clearMsg(); - mSigDetectThread.requestAndWaitPauseDetect(); - //stop scan if scanning - stopScan(); - mFrontDev.SetAnalogFrontEndTimerSwitch(0); - //first stop play(if playing) - stopPlaying(); - // - setAudioChannel(AM_AOUT_OUTPUT_STEREO); - mTvin.setMpeg2Vdin(0); - mAv.setLookupPtsForDtmb(0); - SwitchAVOutBypass(0); - tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); - AudioLineInSelectChannel( audio_channel ); - AudioCtlUninit(); - SetAudioVolDigitLUTTable(SOURCE_MPEG); - Tv_SetAudioInSource(SOURCE_MPEG); - tvin_window_pos_t win_pos; - Vpp_GetDisplayResolutionInfo(&win_pos); - SetPreviewWindow (win_pos ); - //mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG) ), CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG), mSigDetectThread.getCurSigInfo().fmt); - RefreshAudioMasterVolume ( SOURCE_MPEG ); - mVpp.VPP_SetScalerPathSel(0); - mVpp.VPP_SetVideoCrop ( 0, 0, 0, 0 ); - m_last_source_input = SOURCE_INVALID; - m_source_input = SOURCE_INVALID; - mFrontDev.Close(); - mTvAction = mTvAction & ~TV_ACTION_STOPING; - mTvStatus = TV_STOP_ED; - if ( Get2d4gHeadsetEnable() == 1 ) { - property_set("audio.tv_open.flg", "0"); - } - - Tv_SetDDDRCMode(SOURCE_MPEG); - mAv.DisableVideoWithBlackColor(); - //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); - mAv.ClearVideoBuffer(); - mAv.EnableVideoBlackout(); - SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); - return 0; -} - -const char *CTv::getPqDbPath() -{ - return config_get_str("TV", "pq_db_path", "/param/pq.db"); -} -int CTv::Tv_MiscSetBySource ( tv_source_input_t source_input ) -{ - int ret = -1; - - switch ( source_input ) { - case SOURCE_TV: - mVpp.VPP_SetScalerPathSel(1); - ret = SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "4" ); - break; - - case SOURCE_HDMI1: - case SOURCE_HDMI2: - case SOURCE_HDMI3: - mVpp.VPP_SetScalerPathSel(0); - //ret = mVpp.Tv_SavePanoramaMode ( VPP_PANORAMA_MODE_FULL, SOURCE_TYPE_HDMI ); - ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); - break; - - case SOURCE_DTV: - mVpp.VPP_SetScalerPathSel(0); - - case SOURCE_AV1: - case SOURCE_AV2: - case SOURCE_VGA: - mVpp.VPP_SetScalerPathSel(1); - ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); - break; - - case SOURCE_SVIDEO: - case SOURCE_IPTV: - mVpp.VPP_SetScalerPathSel(1); - default: - mVpp.VPP_SetScalerPathSel(0); - ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); - break; - } - - return ret; -} - -int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) -{ - Mutex::Autolock _l ( mLock ); - LOGD ( "%s, source input = %d", __FUNCTION__, source_input ); - tv_source_input_t cur_source_input = m_source_input; - tvin_port_t cur_port; - const char *config_value = NULL; - - Tv_SetDDDRCMode(source_input); - - if (source_input == cur_source_input ) { - LOGW ( "%s,same input change display mode", __FUNCTION__ ); - return 0; - } - - //if HDMI, need to set EDID of each port - if (m_is_set_hdmi_edid) { - int tmp_ret = 0; - switch ( source_input ) { - case SOURCE_HDMI1: - tmp_ret = SSMSetHDMIEdid(1); - break; - case SOURCE_HDMI2: - tmp_ret = SSMSetHDMIEdid(2); - break; - case SOURCE_HDMI3: - tmp_ret = SSMSetHDMIEdid(3); - break; - default: - tmp_ret = -1; - break; - } - if (tmp_ret < 0) - LOGE ( "%s, do not set hdmi port%d edid.ret=%d", __FUNCTION__, source_input - 4, tmp_ret ); - } - mTvAction = mTvAction | TV_ACTION_SOURCE_SWITCHING; - m_cur_playing_prog_id = -1; - // - SetAudioMuteForTv(CC_AUDIO_MUTE); - mSigDetectThread.requestAndWaitPauseDetect(); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - //if ( strcmp ( config_value, "black" ) == 0 ) { - // mAv.DisableVideoWithBlackColor(); - //} else { - // mAv.DisableVideoWithBlueColor(); - //} - mAv.DisableVideoWithBlackColor(); - //enable blackout, when play,disable it - mAv.EnableVideoBlackout(); - //set front dev mode - if ( source_input == SOURCE_TV ) { - mFrontDev.Close(); - mFrontDev.Open(FE_ANALOG); - mFrontDev.SetAnalogFrontEndTimerSwitch(GetATVSourceTimerSwitch()); - //mFrontDev.setMode ( FE_ANALOG ); - } else if ( source_input == SOURCE_DTV ) { - mFrontDev.Close(); - mFrontDev.Open(FE_ANALOG); - //mFrontDev.setMode ( FE_DTMB); - mFrontDev.SetAnalogFrontEndTimerSwitch(0); - } else { - mFrontDev.Close(); - mFrontDev.SetAnalogFrontEndTimerSwitch(0); - } - - //ok - m_last_source_input = m_source_input; - m_source_input = source_input; - SSMSaveSourceInput ( source_input ); - - tv_source_input_t pre_source_input = cur_source_input;//change - cur_source_input = source_input; - - SetAudioVolumeCompensationVal ( 0 ); - - if ( source_input == SOURCE_DTV ) { - //we should stop audio first for audio mute. - SwitchAVOutBypass(0); - tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); - AudioLineInSelectChannel( audio_channel ); - AudioCtlUninit(); - SetAudioVolDigitLUTTable(SOURCE_MPEG); - // - mTvin.Tvin_StopDecoder(); - mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); - mTvin.VDIN_ClosePort(); - //double confirm we set the main volume lut buffer to mpeg - RefreshAudioMasterVolume ( SOURCE_MPEG ); - RefreshSrsEffectAndDacGain(); - SetCustomEQGain(); - mTvin.setMpeg2Vdin(1); - mAv.setLookupPtsForDtmb(1); - //mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); - //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_DTV)); - Tv_SetAudioInSource ( source_input ); - } else { - mAutoPQparam.stopAutoPQ(); - mTvin.setMpeg2Vdin(0); - mAv.setLookupPtsForDtmb(0); - mTvin.Tvin_AddPath ( TV_PATH_VDIN_NEW3D_WITHOUTPPMGR_AMVIDEO ); - } - cur_port = mTvin.Tvin_GetSourcePortBySourceInput ( cur_source_input ); - Tv_MiscSetBySource ( source_input ); - - //only DTV->TVIN or TVIN->DTV need start resource detect thread - if ( ( pre_source_input == SOURCE_DTV || cur_source_input == SOURCE_DTV ) && ( cur_source_input != pre_source_input ) ) { - LOGD ( "%s, dtv need resource detect\n", __FUNCTION__ ); - int isNeedCheckD2D3 = ( gTvinConfig.memory512m) ? 1 : 0; - static int sigchkcnt = 0; - while ( true ) { - if ( ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_DEFAULT, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) - && ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_TVIN, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) ) { - LOGD("%s, path check is ok, and break\n", __FUNCTION__) - break; - } else { - if (sigchkcnt++ > 20) { - sigchkcnt = 0; - break; - } - - LOGW ( "%s,resource is busy.", __FUNCTION__); - } - }//while - }//if need check,and check return - - if ( source_input != SOURCE_DTV ) { - // Uninit data - UnInitTvAudio(); - if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 || - source_input == SOURCE_MPEG || source_input == SOURCE_DTV ) { - SwitchAVOutBypass(0); - } else { - SwitchAVOutBypass(1); - } - - tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (source_input); - AudioLineInSelectChannel( audio_channel ); - - Tv_SetAudioInSource ( source_input ); - if ( source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ) { - m_hdmi_sampling_rate = 0; - m_hdmi_audio_data = 0; - } else { - InitTvAudio ( 48000, CC_IN_USE_I2S_DEVICE); - HanldeAudioInputSr(-1); - } - //=========================================== - if ( mTvin.SwitchPort ( cur_port ) == 0 ) { //ok - //========================================== - unsigned char std; - SSMReadCVBSStd(&std); - int fmt = CFrontEnd::stdEnumToCvbsFmt (std, CC_ATV_AUDIO_STD_AUTO); - mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); - - //for HDMI source connect detect - mTvin.VDIN_OpenHDMIPinMuxOn(true); - mVpp.Vpp_ResetLastVppSettingsSourceType(); - //========================================== - m_sig_stable_nums = 0; - mSigDetectThread.setObserver ( this ); - mSigDetectThread.initSigState(); - int resumeLater = 0; - if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { - resumeLater = 1000; - } else { - resumeLater = 1500; - } - mSigDetectThread.setVdinNoSigCheckKeepTimes(150, true); - mSigDetectThread.resumeDetect(resumeLater); - } else { - } - } - - Tv_SetAudioSourceType(source_input); - RefreshAudioMasterVolume(source_input); - Tv_SetAudioOutputSwap_Type(source_input); - //Tv_ADCDigitalCapture_Volume(); - Tv_SetAVOutPut_Input_gain(source_input); - - mTvAction = mTvAction & ~ TV_ACTION_SOURCE_SWITCHING; - return 0; -} - -void CTv::onSigToStable() -{ - if ( m_autoset_displayfreq) { - if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { - int fps = getHDMIFrameRate(); - LOGD("onSigToStable HDMI fps get = %d", fps); - if ((30 == fps) || (60 == fps)) { - mTvin.VDIN_SetDisplayVFreq ( 60, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 60HZ.", __FUNCTION__); - } else { - mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 50HZ.", __FUNCTION__); - } - } else if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { - mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 50HZ.", __FUNCTION__); - } else { - mTvin.VDIN_SetDisplayVFreq ( 60, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 60HZ.", __FUNCTION__); - } - } - //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d - - mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); - - if ( m_win_mode == PREVIEW_WONDOW ) { - mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); - mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); - } else { - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); - } - m_sig_stable_nums = 0; -} - -void CTv::onSigStillStable() -{ - if ( m_sig_stable_nums == 20) { - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = getHDMIFrameRate(); - sendTvEvent ( ev ); - } - if (m_sig_stable_nums == 2) { - LOGD("still stable , to start decoder"); - int startdec_status = mTvin.Tvin_StartDecoder ( mSigDetectThread.getCurSigInfo() ); - if ( startdec_status == 0 ) { //showboz codes from start decode fun - const char *value; - value = config_get_str ( "TV", "tvin.db.reg.en", "null" ); - if ( strcmp ( value, "enable" ) == 0 ) { - usleep ( 20 * 1000 ); - Tvin_SetPLLValues (); - usleep ( 20 * 1000 ); - SetCVD2Values (); - } - } - } - if ( m_sig_stable_nums == 3) { - LOGD("still stable , to unmute audio/video"); - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_ENABLE_VIDEO_LATER; - msg.mpPara[0] = 2; - mTvMsgQueue.sendMsg ( msg ); - m_hdmi_audio_data = 0; - } - m_sig_stable_nums++; -} - -void CTv::onEnableVideoLater(int framecount) -{ - LOGD("onEnableVideoLater framecount = %d", framecount); - mAv.EnableVideoWhenVideoPlaying(2); - //if(CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ){ - if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { - SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); - Tv_SetAudioInSource(m_source_input); - //} - } -} - -void CTv::Tv_SetAVOutPut_Input_gain(tv_source_input_t source_input) -{ - int nPgaValueIndex = 0; - int nAdcValueIndex = 0; - int nDdcValueIndex= 0; - int tmpAvoutBufPtr[9]; - - if (GetAvOutGainBuf_Cfg(tmpAvoutBufPtr) != 0) - { - GetDefaultAvOutGainBuf(tmpAvoutBufPtr); - } - - switch (source_input) - { - case SOURCE_AV1: - case SOURCE_AV2: - nPgaValueIndex = 0; - nAdcValueIndex = 1; - nDdcValueIndex = 2; - break; - case SOURCE_HDMI1: - case SOURCE_HDMI2: - case SOURCE_HDMI3: - case SOURCE_DTV: - case SOURCE_MPEG: - nPgaValueIndex = 3; - nAdcValueIndex = 4; - nDdcValueIndex = 5; - break; - case SOURCE_TV: - nPgaValueIndex = 6; - nAdcValueIndex = 7; - nDdcValueIndex = 8; - break; - default: - break; - } - - SetPGA_IN_Value(tmpAvoutBufPtr[nPgaValueIndex]); - SetADC_Digital_Capture_Volume(tmpAvoutBufPtr[nAdcValueIndex]); - SetDAC_Digital_PlayBack_Volume(tmpAvoutBufPtr[nDdcValueIndex]); -} - -void CTv::onSigStableToUnstable() -{ - LOGD ( "%s, stable to unstable\n", __FUNCTION__); - SetAudioMuteForTv(CC_AUDIO_MUTE); - mAv.DisableVideoWithBlackColor(); - mTvin.Tvin_StopDecoder(); -} -void CTv::onSigStableToUnSupport() -{ - SetAudioMuteForTv(CC_AUDIO_MUTE); - mAv.DisableVideoWithBlackColor(); - mTvin.Tvin_StopDecoder(); - - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = info.reserved; - sendTvEvent ( ev ); - LOGD ( "%s, Enable blackscreen for signal change in StableToUnSupport!", __FUNCTION__ ); -} -void CTv::onSigStableToNoSig() -{ - const char *config_value = NULL; - SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - //SetAudioMuteForTv(CC_AUDIO_MUTE); - mTvin.Tvin_StopDecoder(); - - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = info.reserved; - sendTvEvent ( ev ); - LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); -} -void CTv::onSigUnStableToUnSupport() -{ - mAv.DisableVideoWithBlackColor(); - mTvin.Tvin_StopDecoder(); - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - - - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = info.reserved; - sendTvEvent ( ev ); - LOGD ( "%s, Enable blackscreen for signal change in UnStableToUnSupport!", __FUNCTION__); -} -void CTv::onSigUnStableToNoSig() -{ - const char *config_value = NULL; - SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - //SetAudioMuteForTv(CC_AUDIO_MUTE); - } - mTvin.Tvin_StopDecoder(); - - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = info.reserved; - sendTvEvent ( ev ); - LOGD ( "%s, Enable bluescreen for signal change in UnStableToNoSig! status = %d", __FUNCTION__, ev.mStatus ); -} -void CTv::onSigNullToNoSig() -{ - const char *config_value = NULL; - SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - //SetAudioMuteForTv(CC_AUDIO_MUTE); - } - mTvin.Tvin_StopDecoder(); - - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - - - TvEvent::SignalInfoEvent ev; - ev.mTrans_fmt = info.trans_fmt; - ev.mFmt = info.fmt; - ev.mStatus = info.status; - ev.mReserved = info.reserved; - sendTvEvent ( ev ); - LOGD ( "%s, Enable bluescreen for signal change in NullToNoSig!", __FUNCTION__); -} - -void CTv::onSigNoSigToUnstable() -{ - const char *config_value = NULL; - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mAv.DisableVideoWithBlackColor(); - } else { - mAv.DisableVideoWithBlueColor(); - } - LOGD("Enable bluescreen for signal change in NoSigToUnstable\n"); -} - - -void CTv::onSigStillUnstable() -{ -} -void CTv::onSigStillNosig() -{ - -} -void CTv::onSigStillNoSupport() -{ + //we should stop audio first for audio mute. + mTvAction |= TV_ACTION_STOPING; + mTvin.Tvin_StopDecoder(); + mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); + mTvin.VDIN_ClosePort(); + mTvMsgQueue.clearMsg(); + mSigDetectThread.requestAndWaitPauseDetect(); + //stop scan if scanning + stopScan(); + mFrontDev.SetAnalogFrontEndTimerSwitch(0); + //first stop play(if playing) + stopPlaying(); + // + setAudioChannel(AM_AOUT_OUTPUT_STEREO); + mTvin.setMpeg2Vdin(0); + mAv.setLookupPtsForDtmb(0); + SwitchAVOutBypass(0); + tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); + AudioLineInSelectChannel( audio_channel ); + AudioCtlUninit(); + SetAudioVolDigitLUTTable(SOURCE_MPEG); + Tv_SetAudioInSource(SOURCE_MPEG); + tvin_window_pos_t win_pos; + Vpp_GetDisplayResolutionInfo(&win_pos); + SetPreviewWindow (win_pos ); + //mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG) ), CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG), mSigDetectThread.getCurSigInfo().fmt); + RefreshAudioMasterVolume ( SOURCE_MPEG ); + mVpp.VPP_SetScalerPathSel(0); + mVpp.VPP_SetVideoCrop ( 0, 0, 0, 0 ); + m_last_source_input = SOURCE_INVALID; + m_source_input = SOURCE_INVALID; + mFrontDev.Close(); + mTvAction &= ~TV_ACTION_STOPING; + mTvStatus = TV_STOP_ED; + if ( Get2d4gHeadsetEnable() == 1 ) { + property_set("audio.tv_open.flg", "0"); + } + + Tv_SetDDDRCMode(SOURCE_MPEG); + mAv.DisableVideoWithBlackColor(); + //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_MPEG)); + mAv.ClearVideoBuffer(); + mAv.EnableVideoBlackout(); + SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); + return 0; +} + +const char *CTv::getPqDbPath() { + return config_get_str(CFG_SECTION_TV, "pq_db_path", "/param/pq.db"); +} + +int CTv::Tv_MiscSetBySource ( tv_source_input_t source_input ) { + int ret = -1; + + switch ( source_input ) { + case SOURCE_TV: + mVpp.VPP_SetScalerPathSel(1); + ret = SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "4" ); + break; + + case SOURCE_HDMI1: + case SOURCE_HDMI2: + case SOURCE_HDMI3: + mVpp.VPP_SetScalerPathSel(0); + //ret = mVpp.Tv_SavePanoramaMode ( VPP_PANORAMA_MODE_FULL, SOURCE_TYPE_HDMI ); + ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); + break; + + case SOURCE_DTV: + mVpp.VPP_SetScalerPathSel(0); + + case SOURCE_AV1: + case SOURCE_AV2: + case SOURCE_VGA: + mVpp.VPP_SetScalerPathSel(1); + ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); + break; + + case SOURCE_SVIDEO: + case SOURCE_IPTV: + mVpp.VPP_SetScalerPathSel(1); + default: + mVpp.VPP_SetScalerPathSel(0); + ret |= SetFileAttrValue ( "/sys/module/am_vecm/parameters/dnlp_adj_level", "5" ); + break; + } + return ret; +} + +int CTv::SetSourceSwitchInput (tv_source_input_t source_input ) { + Mutex::Autolock _l ( mLock ); + LOGD ( "%s, source input = %d", __FUNCTION__, source_input ); + tv_source_input_t cur_source_input = m_source_input; + tvin_port_t cur_port; + const char *config_value = NULL; + + Tv_SetDDDRCMode(source_input); + if (source_input == cur_source_input ) { + LOGW ( "%s,same input change display mode", __FUNCTION__ ); + return 0; + } + + //if HDMI, need to set EDID of each port + if (m_is_set_hdmi_edid) { + int tmp_ret = 0; + switch ( source_input ) { + case SOURCE_HDMI1: + tmp_ret = SSMSetHDMIEdid(1); + break; + case SOURCE_HDMI2: + tmp_ret = SSMSetHDMIEdid(2); + break; + case SOURCE_HDMI3: + tmp_ret = SSMSetHDMIEdid(3); + break; + default: + tmp_ret = -1; + break; + } + if (tmp_ret < 0) + LOGE ( "%s, do not set hdmi port%d edid.ret=%d", __FUNCTION__, source_input - 4, tmp_ret ); + } + mTvAction |= TV_ACTION_SOURCE_SWITCHING; + m_cur_playing_prog_id = -1; + // + SetAudioMuteForTv(CC_AUDIO_MUTE); + mSigDetectThread.requestAndWaitPauseDetect(); + config_value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + //if ( strcmp ( config_value, "black" ) == 0 ) { + // mAv.DisableVideoWithBlackColor(); + //} else { + // mAv.DisableVideoWithBlueColor(); + //} + mAv.DisableVideoWithBlackColor(); + //enable blackout, when play,disable it + mAv.EnableVideoBlackout(); + //set front dev mode + if ( source_input == SOURCE_TV ) { + mFrontDev.Close(); + mFrontDev.Open(FE_ANALOG); + mFrontDev.SetAnalogFrontEndTimerSwitch(GetATVSourceTimerSwitch()); + //mFrontDev.setMode ( FE_ANALOG ); + } else if ( source_input == SOURCE_DTV ) { + mFrontDev.Close(); + mFrontDev.Open(FE_ANALOG); + //mFrontDev.setMode ( FE_DTMB); + mFrontDev.SetAnalogFrontEndTimerSwitch(0); + } else { + mFrontDev.Close(); + mFrontDev.SetAnalogFrontEndTimerSwitch(0); + } + + //ok + m_last_source_input = m_source_input; + m_source_input = source_input; + SSMSaveSourceInput ( source_input ); + + tv_source_input_t pre_source_input = cur_source_input;//change + cur_source_input = source_input; + + SetAudioVolumeCompensationVal ( 0 ); + + if ( source_input == SOURCE_DTV ) { + //we should stop audio first for audio mute. + SwitchAVOutBypass(0); + tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (SOURCE_MPEG); + AudioLineInSelectChannel( audio_channel ); + AudioCtlUninit(); + SetAudioVolDigitLUTTable(SOURCE_MPEG); + // + mTvin.Tvin_StopDecoder(); + mTvin.Tvin_RemovePath ( TV_PATH_TYPE_TVIN ); + mTvin.VDIN_ClosePort(); + //double confirm we set the main volume lut buffer to mpeg + RefreshAudioMasterVolume ( SOURCE_MPEG ); + RefreshSrsEffectAndDacGain(); + SetCustomEQGain(); + mTvin.setMpeg2Vdin(1); + mAv.setLookupPtsForDtmb(1); + //mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, TVIN_SIG_FMT_NULL, INDEX_2D, TVIN_TFMT_2D ); + //mAutoPQparam.startAutoPQ(CTvin::Tvin_SourceInputToSourceInputType(SOURCE_DTV)); + Tv_SetAudioInSource ( source_input ); + } else { + mAutoPQparam.stopAutoPQ(); + mTvin.setMpeg2Vdin(0); + mAv.setLookupPtsForDtmb(0); + mTvin.Tvin_AddPath ( TV_PATH_VDIN_NEW3D_WITHOUTPPMGR_AMVIDEO ); + } + cur_port = mTvin.Tvin_GetSourcePortBySourceInput ( cur_source_input ); + Tv_MiscSetBySource ( source_input ); + + //only DTV->TVIN or TVIN->DTV need start resource detect thread + if ( ( pre_source_input == SOURCE_DTV || cur_source_input == SOURCE_DTV ) && + ( cur_source_input != pre_source_input ) ) { + LOGD ( "%s, dtv need resource detect\n", __FUNCTION__ ); + int isNeedCheckD2D3 = ( gTvinConfig.memory512m) ? 1 : 0; + static int sigchkcnt = 0; + while ( true ) { + if ( ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_DEFAULT, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) + && ( mTvin.Tvin_CheckPathActive ( TV_PATH_TYPE_TVIN, isNeedCheckD2D3 ) == TV_PATH_STATUS_INACTIVE ) ) { + LOGD("%s, path check is ok, and break\n", __FUNCTION__); + break; + } else { + if (sigchkcnt++ > 20) { + sigchkcnt = 0; + break; + } + LOGW ( "%s,resource is busy.", __FUNCTION__); + } + } + } + + if ( source_input != SOURCE_DTV ) { + // Uninit data + UnInitTvAudio(); + if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 || + source_input == SOURCE_MPEG || source_input == SOURCE_DTV ) { + SwitchAVOutBypass(0); + } else { + SwitchAVOutBypass(1); + } + + tv_audio_channel_e audio_channel = mTvin.Tvin_GetInputSourceAudioChannelIndex (source_input); + AudioLineInSelectChannel( audio_channel ); + + Tv_SetAudioInSource ( source_input ); + if ( source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3 ) { + m_hdmi_sampling_rate = 0; + m_hdmi_audio_data = 0; + } else { + InitTvAudio ( 48000, CC_IN_USE_I2S_DEVICE); + HanldeAudioInputSr(-1); + } + //=========================================== + if ( mTvin.SwitchPort ( cur_port ) == 0 ) { //ok + //========================================== + unsigned char std; + SSMReadCVBSStd(&std); + int fmt = CFrontEnd::stdEnumToCvbsFmt (std, CC_ATV_AUDIO_STD_AUTO); + mTvin.AFE_SetCVBSStd ( ( tvin_sig_fmt_t ) fmt ); + + //for HDMI source connect detect + mTvin.VDIN_OpenHDMIPinMuxOn(true); + mVpp.Vpp_ResetLastVppSettingsSourceType(); + //========================================== + m_sig_stable_nums = 0; + mSigDetectThread.setObserver ( this ); + mSigDetectThread.initSigState(); + int resumeLater = 0; + if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { + resumeLater = 1000; + } else { + resumeLater = 1500; + } + mSigDetectThread.setVdinNoSigCheckKeepTimes(150, true); + mSigDetectThread.resumeDetect(resumeLater); + } + } + + Tv_SetAudioSourceType(source_input); + RefreshAudioMasterVolume(source_input); + Tv_SetAudioOutputSwap_Type(source_input); + //Tv_ADCDigitalCapture_Volume(); + Tv_SetAVOutPut_Input_gain(source_input); + + mTvAction &= ~ TV_ACTION_SOURCE_SWITCHING; + return 0; +} + +void CTv::onSigToStable() { + if (m_autoset_displayfreq) { + int freq = 60; + if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { + int fps = getHDMIFrameRate(); + LOGD("onSigToStable HDMI fps = %d", fps); + if ((30 == fps) || (60 == fps)) { + freq = 60; + } else { + freq = 50; + } + } else if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { + freq = 50; + } + + mTvin.VDIN_SetDisplayVFreq ( freq, mAv.getVideoDisplayResolution(), mHdmiOutFbc ); + LOGD ( "%s, SetDisplayVFreq %dHZ.", __FUNCTION__, freq); + } + //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d + + mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); + + if ( m_win_mode == PREVIEW_WONDOW ) { + mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); + mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); + } else { + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); + } + m_sig_stable_nums = 0; +} + +void CTv::onSigStillStable() { + if ( m_sig_stable_nums == 20) { + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = getHDMIFrameRate(); + sendTvEvent ( ev ); + } + if (m_sig_stable_nums == 2) { + LOGD("still stable , to start decoder"); + int startdec_status = mTvin.Tvin_StartDecoder ( mSigDetectThread.getCurSigInfo() ); + if ( startdec_status == 0 ) { //showboz codes from start decode fun + const char *value = config_get_str ( CFG_SECTION_TV, "tvin.db.reg.en", "null" ); + if ( strcmp ( value, "enable" ) == 0 ) { + usleep ( 20 * 1000 ); + Tvin_SetPLLValues (); + usleep ( 20 * 1000 ); + SetCVD2Values (); + } + } + } + if ( m_sig_stable_nums == 3) { + LOGD("still stable , to unmute audio/video"); + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_ENABLE_VIDEO_LATER; + msg.mpPara[0] = 2; + mTvMsgQueue.sendMsg ( msg ); + m_hdmi_audio_data = 0; + } + m_sig_stable_nums++; +} + +void CTv::onEnableVideoLater(int framecount) { + LOGD("onEnableVideoLater framecount = %d", framecount); + mAv.EnableVideoWhenVideoPlaying(2); + //if(CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ){ + if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI ) { + SetAudioMuteForTv ( CC_AUDIO_UNMUTE ); + Tv_SetAudioInSource(m_source_input); + //} + } +} + +void CTv::Tv_SetAVOutPut_Input_gain(tv_source_input_t source_input) { + int nPgaValueIndex = 0; + int nAdcValueIndex = 0; + int nDdcValueIndex= 0; + int tmpAvoutBufPtr[9]; + + if (GetAvOutGainBuf_Cfg(tmpAvoutBufPtr) != 0) { + GetDefaultAvOutGainBuf(tmpAvoutBufPtr); + } + + switch (source_input) { + case SOURCE_AV1: + case SOURCE_AV2: + nPgaValueIndex = 0; + nAdcValueIndex = 1; + nDdcValueIndex = 2; + break; + case SOURCE_HDMI1: + case SOURCE_HDMI2: + case SOURCE_HDMI3: + case SOURCE_DTV: + case SOURCE_MPEG: + nPgaValueIndex = 3; + nAdcValueIndex = 4; + nDdcValueIndex = 5; + break; + case SOURCE_TV: + nPgaValueIndex = 6; + nAdcValueIndex = 7; + nDdcValueIndex = 8; + break; + default: + break; + } + + SetPGA_IN_Value(tmpAvoutBufPtr[nPgaValueIndex]); + SetADC_Digital_Capture_Volume(tmpAvoutBufPtr[nAdcValueIndex]); + SetDAC_Digital_PlayBack_Volume(tmpAvoutBufPtr[nDdcValueIndex]); +} + +void CTv::onSigStableToUnstable() { + LOGD ( "%s, stable to unstable\n", __FUNCTION__); + SetAudioMuteForTv(CC_AUDIO_MUTE); + mAv.DisableVideoWithBlackColor(); + mTvin.Tvin_StopDecoder(); +} + +void CTv::onSigStableToUnSupport() { + SetAudioMuteForTv(CC_AUDIO_MUTE); + mAv.DisableVideoWithBlackColor(); + mTvin.Tvin_StopDecoder(); + + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = info.reserved; + sendTvEvent ( ev ); + LOGD ( "%s, Enable blackscreen for signal change in StableToUnSupport!", __FUNCTION__ ); +} + +void CTv::onSigStableToNoSig() { + SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + //SetAudioMuteForTv(CC_AUDIO_MUTE); + mTvin.Tvin_StopDecoder(); + + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = info.reserved; + sendTvEvent ( ev ); + LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); +} + +void CTv::onSigUnStableToUnSupport() { + mAv.DisableVideoWithBlackColor(); + mTvin.Tvin_StopDecoder(); + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = info.reserved; + sendTvEvent ( ev ); + LOGD ( "%s, Enable blackscreen for signal change in UnStableToUnSupport!", __FUNCTION__); +} + +void CTv::onSigUnStableToNoSig() { + SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + //SetAudioMuteForTv(CC_AUDIO_MUTE); + } + mTvin.Tvin_StopDecoder(); + + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = info.reserved; + sendTvEvent ( ev ); + LOGD ( "%s, Enable bluescreen for signal change in UnStableToNoSig! status = %d", __FUNCTION__, ev.mStatus ); +} + +void CTv::onSigNullToNoSig() { + SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + //SetAudioMuteForTv(CC_AUDIO_MUTE); + } + mTvin.Tvin_StopDecoder(); + + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + + TvEvent::SignalInfoEvent ev; + ev.mTrans_fmt = info.trans_fmt; + ev.mFmt = info.fmt; + ev.mStatus = info.status; + ev.mReserved = info.reserved; + sendTvEvent ( ev ); + LOGD ( "%s, Enable bluescreen for signal change in NullToNoSig!", __FUNCTION__); +} + +void CTv::onSigNoSigToUnstable() { + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mAv.DisableVideoWithBlackColor(); + } else { + mAv.DisableVideoWithBlueColor(); + } + LOGD("Enable bluescreen for signal change in NoSigToUnstable\n"); +} + +void CTv::onSigStillUnstable(){ +} + +void CTv::onSigStillNosig(){ +} + +void CTv::onSigStillNoSupport() { return;//change for gxtvbb, don't send event when sitll not support - tvin_info_t info = mSigDetectThread.getCurSigInfo(); - TvEvent::SignalInfoEvent SigEv; - SigEv.mTrans_fmt = info.trans_fmt; - SigEv.mFmt = info.fmt; - SigEv.mStatus = info.status; - SigEv.mReserved = info.reserved; - sendTvEvent ( SigEv ); - LOGD ( "%s, Unsupport signal", __FUNCTION__); -} -void CTv::onSigStillNull() -{ -} -void CTv::onStableSigFmtChange() -{ - if ( m_autoset_displayfreq) { - if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { - int fps = getHDMIFrameRate(); - LOGD("onSigToStable HDMI fps get = %d", fps); - } - if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { - mTvin.VDIN_SetDisplayVFreq ( 50, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 50HZ.", __FUNCTION__); - } else { - mTvin.VDIN_SetDisplayVFreq ( 60, mAv.getVideoDisplayResolution(), mB_hdmiout_fbc ); - LOGD ( "%s, SetDisplayVFreq 60HZ.", __FUNCTION__); - } - } - //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d - LOGD("hdmi trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); - - //load pq parameters - mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); - - if ( m_win_mode == PREVIEW_WONDOW ) { - mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); - mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); - } else { - SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); - } -} -void CTv::onStableTransFmtChange() -{ - LOGD("onStableTransFmtChange trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); -} -void CTv::onSigDetectEnter() -{ -} - -void CTv::onSigDetectLoop() -{ - if (( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) ) { - int sr = mTvin.get_hdmi_sampling_rate(); - if ( ( sr > 0 ) && ( sr != m_hdmi_sampling_rate ) ) { - LOGD("HDMI SR CHANGED"); - CMessage msg; - msg.mDelayMs = 0; - msg.mType = CTvMsgQueue::TV_MSG_HDMI_SR_CHANGED; - ((int *)(msg.mpPara))[0] = sr; - ((int *)(msg.mpPara))[1] = m_hdmi_sampling_rate; - mTvMsgQueue.sendMsg ( msg ); - m_hdmi_sampling_rate = sr; - } - - // - int hdmi_audio_data = mTvin.TvinApi_GetHDMIAudioStatus(); - if (hdmi_audio_data != m_hdmi_audio_data)//m_hdmi_audio_data init is 0, not audio data , when switch to HDMI - { - LOGD("HDMI auds_rcv_sts CHANGED = %d", hdmi_audio_data); - m_hdmi_audio_data = hdmi_audio_data; - onHMDIAudioStatusChanged(m_hdmi_audio_data); - } - } -} - -CTv::CTvDetectObserverForScanner::CTvDetectObserverForScanner(CTv *pTv) -{ - mpTv = pTv; - m_sig_stable_nums = 0; -} - -void CTv::CTvDetectObserverForScanner::onSigStableToUnstable() -{ - const char *config_value = NULL; - LOGD ( "%s, stable to unstable\n", __FUNCTION__); - mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); - mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mpTv->mAv.DisableVideoWithBlackColor(); - } else { - mpTv->mAv.DisableVideoWithBlueColor(); - } - mpTv->mTvin.Tvin_StopDecoder(); -} - -void CTv::CTvDetectObserverForScanner::onSigUnStableToNoSig() -{ - const char *config_value = NULL; - mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mpTv->mAv.DisableVideoWithBlackColor(); - } else { - mpTv->mAv.DisableVideoWithBlueColor(); - } - mpTv->mTvin.Tvin_StopDecoder(); -} -void CTv::CTvDetectObserverForScanner::onSigStableToNoSig() -{ - const char *config_value = NULL; - mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); - config_value = config_get_str ( "TV", "tvin.bluescreen.color", "null" ); - if ( strcmp ( config_value, "black" ) == 0 ) { - mpTv->mAv.DisableVideoWithBlackColor(); - } else { - mpTv->mAv.DisableVideoWithBlueColor(); - } - mpTv->mTvin.Tvin_StopDecoder(); - LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); -} - -void CTv::CTvDetectObserverForScanner::onSigToStable() -{ - mpTv->mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_16_9 ); - m_sig_stable_nums = 0; -} - -void CTv::CTvDetectObserverForScanner::onSigStillStable() -{ - if (m_sig_stable_nums == 1) { - LOGD("%s still stable , to start decoder", __FUNCTION__); - int startdec_status = mpTv->mTvin.Tvin_StartDecoder (mpTv->mSigDetectThread.getCurSigInfo() ); - if ( startdec_status == 0 ) { - const char *value; - value = config_get_str ( "TV", "tvin.db.reg.en", "null" ); - if ( strcmp ( value, "enable" ) == 0 ) { - usleep ( 20 * 1000 ); - mpTv->Tvin_SetPLLValues (); - usleep ( 20 * 1000 ); - mpTv->SetCVD2Values (); - } - } - } - if ( m_sig_stable_nums == 10 ) { - mpTv->mAv.EnableVideoWhenVideoPlaying(); - } - m_sig_stable_nums++; -} - -void CTv::onSourceConnect(int source_type, int connect_status) -{ - TvEvent::SourceConnectEvent ev; - ev.mSourceInput = source_type; - ev.connectionState = connect_status; - sendTvEvent(ev); -} - -void CTv::onVframeSizeChange() -{ - if (m_source_input == SOURCE_DTV) { - mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); - }else if (m_source_input == SOURCE_INVALID) { - mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); - } -} - - -int CTv::GetSourceConnectStatus(tv_source_input_t source_input) -{ - return mSourceConnectDetectThread.GetSourceConnectStatus((tv_source_input_t)source_input); -} - -tv_source_input_t CTv::GetCurrentSourceInputLock ( void ) -{ - Mutex::Autolock _l ( mLock ); - return m_source_input; + /* + tvin_info_t info = mSigDetectThread.getCurSigInfo(); + TvEvent::SignalInfoEvent SigEv; + SigEv.mTrans_fmt = info.trans_fmt; + SigEv.mFmt = info.fmt; + SigEv.mStatus = info.status; + SigEv.mReserved = info.reserved; + sendTvEvent ( SigEv ); + LOGD ( "%s, Unsupport signal", __FUNCTION__); + */ +} + +void CTv::onSigStillNull(){ +} + +void CTv::onStableSigFmtChange() { + if ( m_autoset_displayfreq) { + if (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { + int fps = getHDMIFrameRate(); + LOGD("onSigToStable HDMI fps get = %d", fps); + } + int freq = 60; + if ( CTvin::Tvin_is50HzFrameRateFmt ( mSigDetectThread.getCurSigInfo().fmt ) ) { + freq = 50; + } + + mTvin.VDIN_SetDisplayVFreq ( freq, mAv.getVideoDisplayResolution(), mHdmiOutFbc ); + LOGD ( "%s, SetDisplayVFreq %dHZ.", __FUNCTION__, freq); + } + //showbo mark hdmi auto 3d, tran fmt is 3d, so switch to 3d + LOGD("hdmi trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); + + //load pq parameters + mVpp.LoadVppSettings (CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt ); + + if ( m_win_mode == PREVIEW_WONDOW ) { + mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); + mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_FULL_STRETCH ); + } else { + SetDisplayMode ( mVpp.GetDisplayMode ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) ), CTvin::Tvin_SourceInputToSourceInputType(m_source_input), mSigDetectThread.getCurSigInfo().fmt); + } +} + +void CTv::onStableTransFmtChange() { + LOGD("onStableTransFmtChange trans_fmt = %d", mSigDetectThread.getCurSigInfo().trans_fmt); +} + +void CTv::onSigDetectEnter(){ +} + +void CTv::onSigDetectLoop() { + if (( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) ) { + int sr = mTvin.get_hdmi_sampling_rate(); + if ( ( sr > 0 ) && ( sr != m_hdmi_sampling_rate ) ) { + LOGD("HDMI SR CHANGED"); + CMessage msg; + msg.mDelayMs = 0; + msg.mType = CTvMsgQueue::TV_MSG_HDMI_SR_CHANGED; + ((int *)(msg.mpPara))[0] = sr; + ((int *)(msg.mpPara))[1] = m_hdmi_sampling_rate; + mTvMsgQueue.sendMsg ( msg ); + m_hdmi_sampling_rate = sr; + } + + //m_hdmi_audio_data init is 0, not audio data , when switch to HDMI + int hdmi_audio_data = mTvin.TvinApi_GetHDMIAudioStatus(); + if (hdmi_audio_data != m_hdmi_audio_data) { + LOGD("HDMI auds_rcv_sts CHANGED = %d", hdmi_audio_data); + m_hdmi_audio_data = hdmi_audio_data; + onHMDIAudioStatusChanged(m_hdmi_audio_data); + } + } +} + +CTv::CTvDetectObserverForScanner::CTvDetectObserverForScanner(CTv *pTv) { + mpTv = pTv; + m_sig_stable_nums = 0; +} + +void CTv::CTvDetectObserverForScanner::onSigStableToUnstable() { + LOGD ( "%s, stable to unstable\n", __FUNCTION__); + mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); + mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mpTv->mAv.DisableVideoWithBlackColor(); + } else { + mpTv->mAv.DisableVideoWithBlueColor(); + } + mpTv->mTvin.Tvin_StopDecoder(); +} + +void CTv::CTvDetectObserverForScanner::onSigUnStableToNoSig() { + mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mpTv->mAv.DisableVideoWithBlackColor(); + } else { + mpTv->mAv.DisableVideoWithBlueColor(); + } + mpTv->mTvin.Tvin_StopDecoder(); +} + +void CTv::CTvDetectObserverForScanner::onSigStableToNoSig() { + mpTv->SetAudioMuteForTv(CC_AUDIO_MUTE); + const char * value = config_get_str ( CFG_SECTION_TV, CFG_BLUE_SCREEN_COLOR, "null" ); + if ( strcmp ( value, "black" ) == 0 ) { + mpTv->mAv.DisableVideoWithBlackColor(); + } else { + mpTv->mAv.DisableVideoWithBlueColor(); + } + mpTv->mTvin.Tvin_StopDecoder(); + LOGD ( "%s, Enable bluescreen for signal change in StableToNoSig!", __FUNCTION__); +} + +void CTv::CTvDetectObserverForScanner::onSigToStable() { + mpTv->mAv.setVideoScreenMode ( CAv::VIDEO_WIDEOPTION_16_9 ); + m_sig_stable_nums = 0; +} + +void CTv::CTvDetectObserverForScanner::onSigStillStable() { + if (m_sig_stable_nums == 1) { + LOGD("%s still stable , to start decoder", __FUNCTION__); + int startdec_status = mpTv->mTvin.Tvin_StartDecoder (mpTv->mSigDetectThread.getCurSigInfo() ); + if ( startdec_status == 0 ) { + const char * value = config_get_str ( CFG_SECTION_TV, "tvin.db.reg.en", "null" ); + if ( strcmp ( value, "enable" ) == 0 ) { + usleep ( 20 * 1000 ); + mpTv->Tvin_SetPLLValues (); + usleep ( 20 * 1000 ); + mpTv->SetCVD2Values (); + } + } + } + if ( m_sig_stable_nums == 10 ) { + mpTv->mAv.EnableVideoWhenVideoPlaying(); + } + m_sig_stable_nums++; +} + +void CTv::onSourceConnect(int source_type, int connect_status) { + TvEvent::SourceConnectEvent ev; + ev.mSourceInput = source_type; + ev.connectionState = connect_status; + sendTvEvent(ev); +} + +void CTv::onVframeSizeChange() { + if (m_source_input == SOURCE_DTV) { + mVpp.LoadVppSettings ( SOURCE_TYPE_DTV, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); + } else if (m_source_input == SOURCE_INVALID) { + mVpp.LoadVppSettings ( SOURCE_TYPE_MPEG, mAv.getVideoResolutionToFmt(), INDEX_2D, TVIN_TFMT_2D ); + } +} + +int CTv::GetSourceConnectStatus(tv_source_input_t source_input) { + return mSourceConnectDetectThread.GetSourceConnectStatus((tv_source_input_t)source_input); +} + +tv_source_input_t CTv::GetCurrentSourceInputLock ( void ) { + Mutex::Autolock _l ( mLock ); + return m_source_input; } //dtv and tvin -tvin_info_t CTv::GetCurrentSignalInfo ( void ) -{ - tvin_trans_fmt det_fmt = TVIN_TFMT_2D; - tvin_sig_status_t signalState = TVIN_SIG_STATUS_NULL; - tvin_info_t signal_info = mSigDetectThread.getCurSigInfo(); - - int feState = mFrontDev.getStatus(); - if ( (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) ) { - det_fmt = mTvin.TvinApi_Get3DDectMode(); - if ((feState & FE_HAS_LOCK) == FE_HAS_LOCK) { - signal_info.status = TVIN_SIG_STATUS_STABLE; - - } else if ((feState & FE_TIMEDOUT) == FE_TIMEDOUT) { - signal_info.status = TVIN_SIG_STATUS_NOSIG; - } - if ( det_fmt != TVIN_TFMT_2D ) { - signal_info.trans_fmt = det_fmt; - } - signal_info.fmt = mAv.getVideoResolutionToFmt(); - } - return signal_info; -} - -int CTv::Tv_GetHistgram(int *histgram_buf) -{ - if (histgram_buf == NULL) { - return -1; - } - return mTvin.VDIN_GetHistgram(histgram_buf); -} - -int CTv::Tv_Set3DMode ( VIDEO_3D_MODE_T mode ) -{ - if (mode == VIDEO_3D_MODE_AUTO) { - mTvin.VDIN_SetDI3DDetc (1); - } else { - mTvin.VDIN_SetDI3DDetc (0); - } - - mAv.set3DMode(mode, 0, 0); - m_mode_3d = mode; - SSMSave3DMode ( ( unsigned char ) mode ); - return 0; -} - -VIDEO_3D_MODE_T CTv::Tv_Get3DMode ( void ) -{ - return m_mode_3d; -} - -int CTv::Tv_Set3DLRSwith ( int on_off) -{ - LOGW ( "%s,Set3D LRSwith on_off %d ,status %d !!! ", __FUNCTION__, on_off); - mAv.set3DMode(m_mode_3d, on_off, 0); - SSMSave3DLRSwitch(on_off); - return 0; -} - -int CTv::Tv_Get3DLRSwith ( void ) -{ - unsigned char val = 0; - SSMRead3DLRSwitch ( &val ); - return ( int ) val; -} - -int CTv::Tv_Set3DTo2DMode ( int mode) -{ - LOGW ( "%s,Set3D to 2D mode %d ,status %d !!! ", __FUNCTION__ , mode); - mAv.set3DMode(m_mode_3d, 0, mode); - SSMSave3DTO2D ( mode ); - return 0; -} - -int CTv::Tv_Get3DTo2DMode ( void ) -{ - unsigned char val = 0; - SSMRead3DTO2D ( &val ); - return val; -} - -int CTv::Tv_Set3DDepth ( int value ) -{ - mTvin.Tvin_SetDepthOf2Dto3D( value ); - SSMSave3DDepth ( value ); - return 0; -} - -int CTv::GetSave3DDepth ( void ) -{ - unsigned char val = 0; - SSMRead3DDepth ( &val ); - return val; -} - -is_3d_type_t CTv::Check2Dor3D ( VIDEO_3D_MODE_T mode3d, tvin_trans_fmt_t trans_fmt ) -{ - if ( mode3d == VIDEO_3D_MODE_DISABLE ) { - return INDEX_2D; - } else if ( mode3d == VIDEO_3D_MODE_AUTO ) { - if ( trans_fmt == TVIN_TFMT_2D ) { - return INDEX_2D; - } else { - return INDEX_3D; - } - } else { - return INDEX_3D; - } -} - - -int CTv::Tvin_SetPLLValues () -{ - tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); - am_regs_t regs; - - if ( mVpp.getPqData()->PQ_GetPLLParams ( source_port, sig_fmt, ®s ) == 0 ) { - LOGD ("%s,PQ_GetPLLParams(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, source_port, sig_fmt ); - - if ( mTvin.TvinApi_LoadPLLValues ( regs ) < 0 ) { - LOGE ( "%s, TvinApi_LoadPLLValues failed!\n", __FUNCTION__ ); - return -1; - } - } else { - LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ ); - return -1; - } - - return 0; -} -int CTv::SetCVD2Values () -{ - tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; - tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); - am_regs_t regs; - - if (mVpp.getPqData()->PQ_GetCVD2Params ( source_port, sig_fmt, ®s ) == 0) { - LOGD ( "%s, PQ_GetCVD2Params(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, - source_port, sig_fmt ); - - if ( mTvin.TvinApi_LoadCVD2Values ( regs ) < 0 ) { - LOGE ( "%s, TvinApi_LoadCVD2Values failed!\n", __FUNCTION__); - return -1; - } - } else { - LOGE ( "%s, PQ_GetCVD2Params failed!\n", __FUNCTION__); - return -1; - } - - return 0; -} - -int CTv::SetPreviewWindow ( tvin_window_pos_t pos ) -{ - m_win_pos.x1 = pos.x1; - m_win_pos.y1 = pos.y1; - m_win_pos.x2 = pos.x2; - m_win_pos.y2 = pos.y2; - LOGD ( "%s, SetPreviewWindow x = %d y=%d", __FUNCTION__, pos.x2, pos.y2 ); - - tvin_window_pos_t def_pos; - Vpp_GetDisplayResolutionInfo(&def_pos); - - if (pos.x1 != 0 || pos.y1 != 0 || pos.x2 != def_pos.x2 || pos.y2 != def_pos.y2) { - m_win_mode = PREVIEW_WONDOW; - } else { - m_win_mode = NORMAL_WONDOW; - } - - return mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); -} +tvin_info_t CTv::GetCurrentSignalInfo ( void ) { + tvin_trans_fmt det_fmt = TVIN_TFMT_2D; + tvin_sig_status_t signalState = TVIN_SIG_STATUS_NULL; + tvin_info_t signal_info = mSigDetectThread.getCurSigInfo(); -/*********************** Audio start **********************/ -int CTv::SetAudioVolDigitLUTTable ( tv_source_input_t source_input ) -{ - int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; - int lut_table_index = 0; - if (source_input == SOURCE_TV) { - lut_table_index = CC_GET_LUT_TV; - } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { - lut_table_index = CC_GET_LUT_AV; - } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2) { - lut_table_index = CC_GET_LUT_COMP; - } else if (source_input == SOURCE_VGA) { - lut_table_index = CC_GET_LUT_VGA; - } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { - lut_table_index = CC_GET_LUT_HDMI; - } else if ( source_input == SOURCE_MPEG ) { - lut_table_index = CC_GET_LUT_MPEG; - } else if ( source_input == SOURCE_DTV ) { - lut_table_index = CC_GET_LUT_MPEG; - } else if ( source_input == SOURCE_MAX) { - return 0; - } - char MainVolLutTableName[128]; - const char *baseName = GetAudioAmpMainvolTableBaseName(lut_table_index); - strcpy(MainVolLutTableName, baseName); - char *dName = "."; - strcat(MainVolLutTableName, dName); - strcat(MainVolLutTableName, GetMainVolLutTableExtraName()); - if ( GetAudioAmpMainvolBuf(MainVolLutTableName, tmpDefDigitLutBuf) == 0) { - AudioSetVolumeDigitLUTBuf ( lut_table_index, tmpDefDigitLutBuf); - } - return 0; -} - -void CTv::RefreshAudioMasterVolume ( tv_source_input_t source_input ) -{ - if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { - if ( GetAudioDVISupportEnable() == 1 ) { - if ( IsDVISignal() ) { - SetAudioVolDigitLUTTable ( SOURCE_MPEG ); - SetAudioMasterVolume ( GetAudioMasterVolume() ); - return; - } - } - } - - SetAudioVolDigitLUTTable ( source_input ); - SetAudioMasterVolume ( GetAudioMasterVolume() ); -} - -int CTv::Tv_SetAudioInSource (tv_source_input_t source_input) -{ - int vol = 255; - if (source_input == SOURCE_TV) { - if (mTvin.Tvin_GetAudioInSourceType(source_input) == TV_AUDIO_IN_SOURCE_TYPE_ATV) { - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_ATV); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_ATV); - LOGD("%s, atv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); - } else { - LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); - } - } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); - } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); - } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || - source_input == SOURCE_TYPE_VGA) { - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); - } else if (source_input == SOURCE_MPEG) { - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); - } else if (source_input == SOURCE_DTV) { - - AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); - vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); - LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); - } - LOGD("%s, we have read SetDAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); - - return 0; -} - -int CTv::Tv_SetAudioSourceType (tv_source_input_t source_input) -{ - int audio_source = -1; - - if (source_input == SOURCE_TV) { - audio_source = AUDIO_ATV_SOURCE; - } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { - audio_source = AUDIO_AV_SOURCE; - } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { - audio_source = AUDIO_HDMI_SOURCE; - } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || - source_input == SOURCE_TYPE_VGA) { - audio_source = AUDIO_AV_SOURCE; - } else if (source_input == SOURCE_DTV) { - audio_source = AUDIO_MPEG_SOURCE; - } else { - audio_source = AUDIO_MPEG_SOURCE; - } - - return AudioSetAudioSourceType(audio_source); -} -void CTv::Tv_SetAudioOutputSwap_Type (tv_source_input_t source_input) -{ - int sw_status = GetAudioOutputSwapStatus(source_input); - SetOutput_Swap(sw_status); -} -void CTv::Tv_ADCDigitalCapture_Volume (void) -{ - int capture_vol = GetADCDigitalCaptureVol_Cfg(); - LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, capture_vol); - SetADC_Digital_Capture_Volume(capture_vol); -} - -void CTv::Tv_SetPGAIn_Gain (void) -{ - int gain_val = GetAudioInternalDacPGAInGain_Cfg(); - LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, gain_val); - SetPGA_IN_Value(gain_val); -} - -void CTv::Tv_SetDACDigitalPlayBack_Volume (int audio_src_in_type) -{ - int vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(audio_src_in_type); - LOGD("%s, we have read DACDigitalPlayBackVolume config = %d \n", __FUNCTION__, vol); - SetDAC_Digital_PlayBack_Volume(vol); + int feState = mFrontDev.getStatus(); + if ( (CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_DTV ) ) { + det_fmt = mTvin.TvinApi_Get3DDectMode(); + if ((feState & FE_HAS_LOCK) == FE_HAS_LOCK) { + signal_info.status = TVIN_SIG_STATUS_STABLE; + } else if ((feState & FE_TIMEDOUT) == FE_TIMEDOUT) { + signal_info.status = TVIN_SIG_STATUS_NOSIG; + } + if ( det_fmt != TVIN_TFMT_2D ) { + signal_info.trans_fmt = det_fmt; + } + signal_info.fmt = mAv.getVideoResolutionToFmt(); + } + return signal_info; } -/*********************** Audio end **********************/ -unsigned int CTv::Vpp_GetDisplayResolutionInfo(tvin_window_pos_t *win_pos) -{ - int display_resolution = mAv.getVideoDisplayResolution(); - unsigned int tmp_ret = 0; - - switch (display_resolution) { - case VPP_DISPLAY_RESOLUTION_1366X768: - tmp_ret |= (CC_RESOLUTION_1366X768_W << 16); - tmp_ret |= (CC_RESOLUTION_1366X768_H << 0); - break; - case VPP_DISPLAY_RESOLUTION_1920X1080: - tmp_ret |= (CC_RESOLUTION_1920X1080_W << 16); - tmp_ret |= (CC_RESOLUTION_1920X1080_H << 0); - break; - case VPP_DISPLAY_RESOLUTION_3840X2160: - tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16); - tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0); - break; - default: - tmp_ret |= (CC_RESOLUTION_3840X2160_W << 16); - tmp_ret |= (CC_RESOLUTION_3840X2160_H << 0); - break; - } - - if (win_pos != NULL) { - win_pos->x1 = 0; - win_pos->y1 = 0; - win_pos->x2 = ((tmp_ret >> 16) & 0xFFFF) - 1; - win_pos->y2 = ((tmp_ret >> 0) & 0xFFFF) - 1; - } - - return 0; -} - - -int CTv::setBlackoutEnable(int enable) -{ - m_blackout_enable = enable; - return SSMSaveBlackoutEnable(enable); -} - -int CTv::getSaveBlackoutEnable() -{ - int8_t enable; - SSMReadBlackoutEnable(&enable); - return enable; -} -void CTv::startAutoBackLight() -{ - if (mB_hdmiout_fbc) { - Tv_FactorySet_FBC_Auto_Backlight_OnOff(1); - } else { - mAutoBackLight.startAutoBacklight(CTvin::Tvin_SourceInputToSourceInputType(m_source_input)); - } - -} -void CTv::stopAutoBackLight() -{ - if (mB_hdmiout_fbc) { - Tv_FactorySet_FBC_Auto_Backlight_OnOff(0); - } else { - mAutoBackLight.stopAutoBacklight(); - } -} - -int CTv::getAutoBackLight_on_off() -{ - if (mB_hdmiout_fbc) { - return Tv_FactoryGet_FBC_Auto_Backlight_OnOff(); - } else { - return mAutoBackLight.isAutoBacklightOn() ? 1 : 0; - } -} - -int CTv::getAverageLuma() -{ - return mTvin.VDIN_Get_avg_luma(); -} - -int CTv::setAutobacklightData(const char* value){ - int i = 0; - const char *tmp_ptr = NULL; - const char *end_str_buf =".opc"; - project_info_t tmp_info; - char tmp_buf[128]; - const char* key_buf ="haier.autobacklight.mp.data"; - - tmp_ptr = config_get_str("TV", key_buf, "null"); - if (strcmp(tmp_ptr, value) != 0) { - config_set_str("TV", key_buf, value); - LOGD("%s, config string now set as: %s \n", __FUNCTION__, tmp_buf); - } else { - LOGD("%s, config string has been set as: %s \n", __FUNCTION__, tmp_buf); - } - return 0; -} - -int CTv::getAutoBacklightData(int* data){ - const char *opc_buf; - char str_data[512] ={0,}; - char delims[] = ","; - char *result = NULL; - const char* key_buf ="haier.autobacklight.mp.data"; - int i=0; - - if (NULL == data) { - LOGD("%s, data is null", __FUNCTION__); - } - - opc_buf = config_get_str("TV", key_buf, (char *) "null"); - if (strcmp(opc_buf,"null") == 0) { - LOGD("%s, value is NULL\n",__FUNCTION__); - return -1; - } - - memset( str_data,0, sizeof(str_data)); - strncpy(str_data,opc_buf,sizeof(str_data)-1); - result = strtok( str_data, delims ); - while ( result != NULL ) { - char *pd =NULL; - pd = strstr(result, ":"); - if (pd != NULL) { - data[i] =strtol(pd+1, NULL, 10 ); - i++; - } - result = strtok( NULL, delims ); - } - return i; +int CTv::Tv_GetHistgram(int *histgram_buf) { + if (histgram_buf == NULL) { + return -1; + } + return mTvin.VDIN_GetHistgram(histgram_buf); } +int CTv::Tv_Set3DMode ( VIDEO_3D_MODE_T mode ) { + if (mode == VIDEO_3D_MODE_AUTO) { + mTvin.VDIN_SetDI3DDetc (1); + } else { + mTvin.VDIN_SetDI3DDetc (0); + } -/*********************** SSM start **********************/ -int CTv::Tv_SSMRestoreDefaultSetting() -{ - SSMRestoreDeviceMarkValues(); - AudioSSMRestoreDefaultSetting(); - mVpp.VPPSSMRestoreDefault(); - MiscSSMRestoreDefault(); - ReservedSSMRestoreDefault(); - SSMSaveCVBSStd ( 0 ); - SSMSaveLastSelectSourceInput ( SOURCE_TV ); - SSMSavePanelType ( 0 ); - //tvconfig default - saveDTVProgramID ( -1 ); - saveATVProgramID ( -1 ); - SSMSaveStandbyMode( 0 ); - return 0; -} - -int CTv::clearDbAllProgramInfoTable() -{ - return CTvDatabase::GetTvDb()->clearDbAllProgramInfoTable(); -} - -int CTv::Tv_SSMFacRestoreDefaultSetting() -{ - mVpp.VPPSSMFacRestoreDefault(); - AudioSSMRestoreDefaultSetting(); - MiscSSMFacRestoreDefault(); - - return 0; -} -/*********************** SSM End **********************/ -//not in CTv, not use lock -void CTv::setSourceSwitchAndPlay() -{ - int progID = 0, ret = -1; - CTvProgram prog; - LOGD ( "%s\n", __FUNCTION__ ); - static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source - static const int POWERON_SOURCE_TYPE_LAST = 1;//play last save source - static const int POWERON_SOURCE_TYPE_SETTING = 2;//play ui set source - int to_play_source = -1; - int powerup_type = SSMReadPowerOnOffChannel(); - LOGD("read power on source type = %d", powerup_type); - if (powerup_type == POWERON_SOURCE_TYPE_NONE) { - return ; - } else if (powerup_type == POWERON_SOURCE_TYPE_LAST) { - to_play_source = SSMReadSourceInput(); - } else if (powerup_type == POWERON_SOURCE_TYPE_SETTING) { - to_play_source = SSMReadLastSelectSourceInput(); - } - SetSourceSwitchInput (( tv_source_input_t ) to_play_source ); - if ( to_play_source == SOURCE_TV ) { - progID = getATVProgramID(); - } else if ( to_play_source == SOURCE_DTV ) { - progID = getDTVProgramID(); - } - playProgramLock(progID); - return; -} - -int CTv::startCC(int country, int src, int channel, int service) -{ - //turn_on_cc = true; - return mSubtitle.sub_start_atsc_cc((enum cc_param_country)country, (enum cc_param_source_type)src, channel, (enum cc_param_caption_type)service); -} - -int CTv::stopCC() -{ - //because cc,vchip data both come from vbi thread , here judge cc, vchip is whether both turn off - /*turn_on_cc = false; - if (config_get_int("TV","tv.vchip.enable", 0)) - { - return 0; //at ATV if vchip is on, turn off CC, just set flag not display CC, but vchip still running - }*/ - return mSubtitle.sub_stop_atsc_cc(); -} - -void CTv::printDebugInfo() -{ - print_version_info(); - LOGD("%s, TvAction = %x", __FUNCTION__, mTvAction); - LOGD("%s, TvRunStatus = %d", __FUNCTION__, mTvStatus); - LOGD("%s, TvCurSourceInput = %d", __FUNCTION__, m_source_input); - LOGD("%s, TvLastSourceInput = %d", __FUNCTION__, m_last_source_input); -} -//==============vchip end================================ -//----------------DVR API============================ -void CTv::SetRecordFileName ( char *name ) -{ - char tmp[256]; - strcpy ( tmp, name ); - mTvRec.SetRecordFileName ( tmp ); -} -void CTv::StartToRecord() -{ - int progID = getDTVProgramID(); - mTvRec.StartRecord ( progID ); -} -void CTv::StopRecording() -{ - mTvRec.StopRecord(); -} -void CTv::SetRecCurTsOrCurProgram ( int sel ) -{ - mTvRec.SetRecCurTsOrCurProgram ( sel ); -} - -int CTv::GetDisplayResolutionConfig() -{ - return mAv.getVideoDisplayResolution(); -} - -int CTv::GetDisplayResolutionInfo() -{ - return Vpp_GetDisplayResolutionInfo(NULL); -} - -void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[]) -{ - int i = 0; - TvEvent::HDMIRxCECEvent ev; - ev.mDataCount = msg_len; - for (i = 0; i < msg_len; i++) { - ev.mDataBuf[i] = msg_buf[i]; - } - sendTvEvent(ev); -} - -int CTv::SendHDMIRxCECCustomMessage(unsigned char data_buf[]) -{ - tv_source_input_t source_input = m_source_input; - - return mHDMIRxCEC.SendCustomMessage(source_input, data_buf); -} - -int CTv::SendHDMIRxCECCustomMessageAndWaitReply(unsigned char data_buf[], unsigned char reply_buf[], int WaitCmd, int timeout) -{ - tv_source_input_t source_input = m_source_input; - - return mHDMIRxCEC.SendCustomMessageAndWaitReply(source_input, data_buf, reply_buf, WaitCmd, timeout); -} - -int CTv::SendHDMIRxCECBoradcastStandbyMessage(void) -{ - tv_source_input_t source_input = m_source_input; - - return mHDMIRxCEC.SendBoradcastStandbyMessage(source_input); -} - -int CTv::SendHDMIRxCECGiveCECVersionMessage(tv_source_input_t source_input, unsigned char data_buf[]) -{ - if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { - return mHDMIRxCEC.SendGiveCECVersionMessage(source_input, data_buf); - } - - return -1; -} - -int CTv::SendHDMIRxCECGiveDeviceVendorIDMessage(tv_source_input_t source_input, unsigned char data_buf[]) -{ - if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { - return mHDMIRxCEC.SendGiveDeviceVendorIDMessage(source_input, data_buf); - } - - return -1; -} - -int CTv::SendHDMIRxCECGiveOSDNameMessage(tv_source_input_t source_input, unsigned char data_buf[]) -{ - if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { - return mHDMIRxCEC.SendGiveOSDNameMessage(source_input, data_buf); - } - - return -1; -} - -int CTv::GetHdmiHdcpKeyKsvInfo(int data_buf[]) -{ - return mTvin.get_hdmi_ksv_info(m_source_input, data_buf); -} - -int CTv::hdmi_out_towhat() -{ - const char *config_value; - config_value = config_get_str("TV", "platform.havefbc", "true"); - if (strcmp(config_value, "true") == 0) { - return 1; - } else { - return 0; - } -} - -void CTv::onUpgradeStatus(int state, int param) -{ - TvEvent::UpgradeFBCEvent ev; - ev.mState = state; - ev.param = param; - sendTvEvent(ev); -} - -int CTv::StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size) -{ - if (mpUpgradeFBC != NULL) { - mpUpgradeFBC->SetUpgradeFileName(file_name); - mpUpgradeFBC->SetUpgradeMode(mode); - mpUpgradeFBC->SetUpgradeBlockSize(upgrade_blk_size); - mpUpgradeFBC->start(); - return 0; - } - - return -1; -} - -void CTv::onSerialCommunication(int dev_id, int rd_len, unsigned char data_buf[]) -{ - int i = 0; - TvEvent::SerialCommunicationEvent ev; - ev.mDevId = dev_id; - ev.mDataCount = rd_len; - for (i = 0; i < rd_len; i++) { - ev.mDataBuf[i] = data_buf[i]; - } - sendTvEvent(ev); -} - -int CTv::StartHeadSetDetect() -{ - mHeadSet.startDetect(); - return 0; -} - -void CTv::onHeadSetDetect(int state,int para) -{ - TvEvent::HeadSetOf2d4GEvent ev; - if (state == 1) - property_set("audio.headset_plug.enable", "1"); - else - property_set("audio.headset_plug.enable", "0"); - ev.state = state; - ev.para = para; - sendTvEvent(ev); -} - -void CTv::onThermalDetect(int state) -{ - const char *value; - const char *value_normal; - const char *value_cold; - int threshold = 0, val = 0; - static int pre_val = -1; - - value = config_get_str ( "TV", "tvin.thermal.threshold.enable", "null" ); - - if ( strcmp ( value, "enable" ) == 0 ) { - - value = config_get_str ( "TV", "tvin.thermal.threshold.value", "null" ); - - threshold = atoi(value); - LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold); - - if (state > threshold) { - value_normal = config_get_str ( "TV", "tvin.thermal.fbc.normal.value", "null" ); - val = atoi(value_normal); - if (val == 0) { - val = 0x4210000; //normal default - } - LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state); - } else { - value_cold = config_get_str ( "TV", "tvin.thermal.fbc.cold.value", "null" ); - val = atoi(value_cold); - if (val == 0) { - val = 0x8210000; //cold default - } - LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state); - } - - if (pre_val == val) { - LOGD ( "%s, pre_val == val : 0x%x,bypass\n", __FUNCTION__, val); - } else { - pre_val = val; - Tv_FactorySet_FBC_Thermal_State(val); - LOGD ( "%s, pre_val :0x%x,bypass\n", __FUNCTION__, pre_val); - } - } else { - LOGD ( "%s, tvin.thermal.threshold.enable == disable\n", __FUNCTION__); - } -} - -int CTv::SetDebugSerialOnOff(int on_off) -{ - if (on_off) { - property_set("ubootenv.var.console", "ttyS0,115200n8"); - } else { - property_set("ubootenv.var.console", "off"); - } - return 0; -} - -int CTv::GetDebugSerialOnOff() -{ - char prop[256]; - memset(prop, '\0', 256); - property_get("ubootenv.var.console", prop, "null" ); - - if (!strcmp(prop, "ttyS0,115200n8")) { - return 1; - } else { - return 0; - } -} -int CTv::SetSerialSwitch(int dev_id, int switch_val) -{ - int tmp_ret = 0; - if (dev_id == SERIAL_A) { - if (switch_val == 0) { - tmp_ret |= mSerialA.stop(); - tmp_ret |= mSerialA.CloseModule(); - - tmp_ret |= system("start console"); - tmp_ret |= system("echo 7 > /proc/sys/kernel/printk"); - } else { - tmp_ret |= system("echo 0 > /proc/sys/kernel/printk"); - tmp_ret |= system("stop console"); - - mSerialA.OpenModule(dev_id); - tmp_ret |= mSerialA.start(); - } - } else if (dev_id == SERIAL_B) { - if (switch_val == 0) { - tmp_ret |= mSerialB.stop(); - tmp_ret |= mSerialB.CloseModule(); - } else { - mSerialB.OpenModule(dev_id); - tmp_ret = mSerialB.start(); - } - } else if (dev_id == SERIAL_C) { - if (switch_val == 0) { - tmp_ret |= mSerialC.stop(); - tmp_ret |= mSerialC.CloseModule(); - } else { - mSerialC.OpenModule(dev_id); - tmp_ret = mSerialC.start(); - } - } - - return tmp_ret; -} - -int CTv::SendSerialData(int dev_id, int data_len, unsigned char data_buf[]) -{ - int tmp_ret = 0; - - if (dev_id == SERIAL_A) { - tmp_ret = mSerialA.sendData(data_len, data_buf); - } else if (dev_id == SERIAL_B) { - tmp_ret = mSerialB.sendData(data_len, data_buf); - } else if (dev_id == SERIAL_C) { - tmp_ret = mSerialC.sendData(data_len, data_buf); - } - - return tmp_ret; -} - -int CTv::ChannelExport(const char *destPath) -{ - //DIR *dirptr = NULL; - //dirptr = opendir("/storage/external_storage/sda1/"); - //if(NULL == dirptr) { - // LOGD("%s, please insert the udisk !",__FUNCTION__); - // return -2; - // } else { - char tmp[256]; - FILE *fp = NULL; - if (destPath == NULL) { - destPath = "/storage/external_storage/sda1/"; - } - - //LOGD("%s, udisk exist !",__FUNCTION__); - sprintf(tmp, "cp /param/dtv.db %s", destPath); - if (system(tmp) >= 0) { - LOGD("%s, copy dtv.db from /param to udisk success !", __FUNCTION__); - system("sync"); - fp = fopen(destPath, "r"); - if (fp == NULL) { - return -1; - } else { - fclose(fp); - fp = NULL; - return 0; - } - } else { - return -1; - } - //} -} - -int CTv::ChannelImport(const char *srcPath) -{ - if (srcPath == NULL) { - srcPath = "/storage/external_storage/sda1/dvb.db"; - } - - if (Tv_Utils_IsFileExist(srcPath) == 0) { - char tmp[256]; - const char *destPath = config_get_str("TV", "tv.channel.db", (char *) "/param/dtv.db"); - - LOGD("%s, file exist !" , srcPath); - CTvDatabase::GetTvDb()->UnInitTvDb(); - sprintf(tmp, "rm %s", destPath); - if (system(tmp) >= 0) { - LOGD("%s, rm %s success !", __FUNCTION__, destPath); - memset(tmp, 0, sizeof(tmp)); - sprintf(tmp, "cp %s %s", srcPath, destPath); - if (system(tmp) >= 0) { - LOGD("%s, copy to %s success !", srcPath, destPath); - memset(tmp, 0, sizeof(tmp)); - sprintf(tmp, "chmod 777 %s", destPath); - if (system(tmp) >= 0) { - LOGD("chmod 777 %s success !", destPath); - system("sync"); - CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); - return 0; - } else { - LOGD("%s, %s chmod failed !", __FUNCTION__, destPath); - return -1; - } - } else { - LOGD("%s, copy dtv.db from udisk to %s failed !", __FUNCTION__, destPath); - return -1; - } - } else { - LOGD("%s, rm %s failed !", __FUNCTION__, destPath); - return -2; - } - } else { - LOGD("%s, dtv.db file does not exist in the udisk!" , srcPath); - return -2; - } - -} - -int CTv::Tv_GetProjectInfo(project_info_t *ptrInfo) -{ - return GetProjectInfo(ptrInfo, fbcIns); -} - -int CTv::Tv_GetPlatformType() -{ - return mB_hdmiout_fbc ? 1 : 0; -} - -int CTv::Tv_HandeHDMIEDIDFilePathConfig() -{ - int i, file_exist_flag = 1; - const char *value = NULL; - char val_buf[256]; - char edid_path[256]; - char edid_path_cfg[256]; - - value = config_get_str("TV", "ssm.handle.hdmi.edid.en", "null"); - - if (strtoul(value, NULL, 10) == 1) { - LOGD( "%s, get config \"%s\" is \"%s\".\n", - __FUNCTION__, "ssm.handle.hdmi.edid.en", value); - //get hdmi edid use mode - - memset(val_buf, '\0', 256); - property_get("ubootenv.var.outputmode", val_buf, "null"); - LOGD( "%s, get property \"%s\" is \"%s\".\n", - __FUNCTION__, "ubootenv.var.outputmode", val_buf); - if (strcmp(val_buf, "null") != 0) { - config_set_str ( "TV", "ssm.handle.hdmi.edid.use", val_buf); - - file_exist_flag = 1; - //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { - memset( edid_path, '\0', 256); - memset( edid_path_cfg, '\0', 256); - sprintf(edid_path, "/system/etc/%s_port%d.bin", val_buf, i); - sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); - if (access(edid_path, 0) < 0) { - file_exist_flag = 0; - break; - } - config_set_str("TV", edid_path_cfg, edid_path); - } - - if (file_exist_flag == 0) { - //set default hdmi edid - config_set_str("TV", "ssm.handle.hdmi.edid.use", "hdmi_edid"); - //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { - memset(edid_path, '\0', 256); - memset(edid_path_cfg, '\0', 256); - sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); - sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); - - value = config_get_str("TV", edid_path_cfg, "null"); - if (strcmp(value, edid_path) != 0) { - config_set_str("TV", edid_path_cfg, edid_path); - } - } - } - } else { - //set default hdmi edid - config_set_str("TV", "ssm.handle.hdmi.edid.use", "hdmi_edid"); - //set file's path for hdmi edid of each port - for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { - memset(edid_path, '\0', 256); - memset(edid_path_cfg, '\0', 256); - sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); - sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); - - value = config_get_str("TV", edid_path_cfg, "null"); - if (strcmp(value, edid_path) != 0) { - config_set_str("TV", edid_path_cfg, edid_path); - } - } - } - m_is_set_hdmi_edid = true; - } - - return 0; -} - -int CTv::Tv_SetDDDRCMode(tv_source_input_t source_input) -{ - if (source_input == SOURCE_DTV) { - if (GetPlatformHaveDDFlag() == 1) { - Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", "drcmode 3"); - } - } else { - if (GetPlatformHaveDDFlag() == 1) { - Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", "drcmode 2"); - } - } - - return 0; + mAv.set3DMode(mode, 0, 0); + m_mode_3d = mode; + SSMSave3DMode ( ( unsigned char ) mode ); + return 0; } -//PQ -int CTv::Tv_SetBrightness ( int brightness, tv_source_input_type_t source_type, int is_save ) -{ - return mVpp.SetBrightness(brightness, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); -} - -int CTv::Tv_GetBrightness ( tv_source_input_type_t source_type ) -{ - return mVpp.GetBrightness((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveBrightness ( int brightness, tv_source_input_type_t source_type ) -{ - return SSMSaveBrightness ( source_type, brightness ); -} - -int CTv::Tv_SetContrast ( int contrast, tv_source_input_type_t source_type, int is_save ) -{ - return mVpp.SetContrast(contrast, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); -} - -int CTv::Tv_GetContrast ( tv_source_input_type_t source_type ) -{ - return mVpp.GetContrast((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveContrast ( int contrast, tv_source_input_type_t source_type ) -{ - return SSMSaveContrast ( source_type, contrast ); -} -int CTv::Tv_SetSaturation ( int satuation, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) -{ - return mVpp.SetSaturation(satuation, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); -} - -int CTv::Tv_GetSaturation ( tv_source_input_type_t source_type ) -{ - return mVpp.GetSaturation((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveSaturation ( int satuation, tv_source_input_type_t source_type ) -{ - return SSMSaveSaturation ( source_type, satuation ); -} -int CTv::Tv_SetHue ( int hue, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) -{ - return mVpp.SetHue(hue, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); -} - -int CTv::Tv_GetHue ( tv_source_input_type_t source_type ) -{ - return mVpp.GetHue((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveHue ( int hue, tv_source_input_type_t source_type ) -{ - return SSMSaveHue ( source_type, hue ); -} -int CTv::Tv_SetPQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type, int is_save ) -{ - return mVpp.SetPQMode((vpp_picture_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); -} - -vpp_picture_mode_t CTv::Tv_GetPQMode ( tv_source_input_type_t source_type ) -{ - return mVpp.GetPQMode((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SavePQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type ) -{ - return mVpp.SavePQMode ( mode, source_type ); -} -int CTv::Tv_SetSharpness ( int value, tv_source_input_type_t source_type, int en, int is_save ) -{ - return mVpp.SetSharpness(value, (tv_source_input_type_t)source_type, en, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, is_save); -} - -int CTv::Tv_GetSharpness ( tv_source_input_type_t source_type ) -{ - return mVpp.GetSharpness((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveSharpness ( int value, tv_source_input_type_t source_type ) -{ - return SSMSaveSharpness ( source_type, value ); -} -int CTv::Tv_SetBacklight ( int value, tv_source_input_type_t source_type, int is_save ) -{ - if (mB_hdmiout_fbc) { - return Tv_FactorySet_FBC_Backlight(value); - } else { - return mVpp.SetBacklight(value, (tv_source_input_type_t)source_type, is_save); - } -} - -int CTv::Tv_GetBacklight ( tv_source_input_type_t source_type ) -{ - if (mB_hdmiout_fbc) { - return Tv_FactoryGet_FBC_Backlight(); - } else { - return mVpp.GetBacklight((tv_source_input_type_t)source_type); - } -} -int CTv::Tv_SaveBacklight ( int value, tv_source_input_type_t source_type ) -{ - return mVpp.SaveBacklight ( value, source_type ); -} -int CTv::Tv_SetBacklight_Switch ( int value ) -{ - if (mB_hdmiout_fbc) { - return Tv_FactorySet_FBC_backlight_onoff(value); - } else { - return mVpp.VPP_SetBackLight_Switch(value); - } -} - -int CTv::Tv_GetBacklight_Switch ( void ) -{ - if (mB_hdmiout_fbc) { - return Tv_FactoryGet_FBC_backlight_onoff(); - } else { - return mVpp.VPP_GetBackLight_Switch(); - } -} - -int CTv::Tv_SetColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type, int is_save ) -{ - if (mB_hdmiout_fbc) { - return Tv_FactorySet_FBC_ColorTemp_Mode(mode); - } else { - return mVpp.SetColorTemperature((vpp_color_temperature_mode_t)mode, (tv_source_input_type_t)source_type, is_save); - } -} - -vpp_color_temperature_mode_t CTv::Tv_GetColorTemperature ( tv_source_input_type_t source_type ) -{ - if (mB_hdmiout_fbc) { - return (vpp_color_temperature_mode_t)Tv_FactoryGet_FBC_ColorTemp_Mode(); - } else { - return mVpp.GetColorTemperature((tv_source_input_type_t)source_type); - } - -} -int CTv::Tv_SaveColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type ) -{ - return mVpp.SaveColorTemp ( mode, source_type ); -} - -int CTv::Tv_SetDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) -{ - int ret = 0; - if (m_mode_3d == VIDEO_3D_MODE_DISABLE) { - ret = SetDisplayMode((vpp_display_mode_t)mode, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); - } else { //3D - ret = SetDisplayMode(VPP_DISPLAY_MODE_PERSON, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); - } - if (ret == 0) { - if (is_save == 1) { - ret = ret | SSMSaveDisplayMode ( source_type, (int)mode ); - } - } - return ret; -} - -int CTv::SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt ) -{ - LOGD("SetDisplayMode, display_mode = %d, source_type = %d fmt = %d tranfmt = %d\n", display_mode, source_type, sig_fmt, mSigDetectThread.getCurSigInfo().trans_fmt); - - tvin_cutwin_t cutwin = mVpp.GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt); - LOGD("SetDisplayMode , get crop %d %d %d %d \n", cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); - int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; - tvin_window_pos_t win_pos; - int display_resolution = Vpp_GetDisplayResolutionInfo(&win_pos); - - switch ( display_mode ) { - case VPP_DISPLAY_MODE_169: - video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; - break; - case VPP_DISPLAY_MODE_MODE43: - video_screen_mode = CAv::VIDEO_WIDEOPTION_4_3; - break; - case VPP_DISPLAY_MODE_NORMAL: - video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL; - break; - case VPP_DISPLAY_MODE_FULL: - video_screen_mode = CAv::VIDEO_WIDEOPTION_NONLINEAR; - mVpp.VPP_SetNonLinearFactor ( 20 ); - //mVpp.VPP_SetNonLinearFactor ( 20 ); - break; - case VPP_DISPLAY_MODE_CROP_FULL: - cutwin.vs = 0; - cutwin.hs = 0; - cutwin.ve = 0; - cutwin.he = 0; - break; - case VPP_DISPLAY_MODE_NOSCALEUP: { - video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL_NOSCALEUP; - break; - } - case VPP_DISPLAY_MODE_FULL_REAL: - video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; //added for N360 by haifeng.liu - break; - case VPP_DISPLAY_MODE_PERSON: - video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; - cutwin.vs = cutwin.vs + 20; - cutwin.ve = cutwin.ve + 20; - break; - case VPP_DISPLAY_MODE_MOVIE: - video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; - cutwin.vs = cutwin.vs + 40; - cutwin.ve = cutwin.ve + 40; - break; - case VPP_DISPLAY_MODE_CAPTION: - video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; - cutwin.vs = cutwin.vs + 55; - cutwin.ve = cutwin.ve + 55; - break; - case VPP_DISPLAY_MODE_ZOOM: - video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; - cutwin.vs = cutwin.vs + 70; - cutwin.ve = cutwin.ve + 70; - break; - default: - break; - } - if (source_type == SOURCE_TYPE_DTV || source_type == SOURCE_TYPE_MPEG) { - cutwin.vs = cutwin.vs + 12; - cutwin.ve = cutwin.ve + 12; - cutwin.hs = cutwin.hs + 12; - cutwin.he = cutwin.he + 12; - } - if (source_type == SOURCE_TYPE_HDMI) { - if ((IsDVISignal()) || (mTvin.GetITContent() == 1)) { - cutwin.vs = 0; - cutwin.hs = 0; - cutwin.ve = 0; - cutwin.he = 0; - } - - if (display_mode == VPP_DISPLAY_MODE_FULL_REAL) { - cutwin.vs = 0; - cutwin.hs = 0; - cutwin.ve = 0; - cutwin.he = 0; - } - } - - //mAv.setVideoAxis ( win_pos.x1, win_pos.y1, win_pos.x2, win_pos.y2 ); - mAv.setVideoScreenMode(video_screen_mode); - mVpp.VPP_SetVideoCrop(cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); - return 0; -} - -vpp_display_mode_t CTv::Tv_GetDisplayMode ( tv_source_input_type_t source_type ) -{ - return mVpp.GetDisplayMode((tv_source_input_type_t)source_type); -} - -int CTv::Tv_SaveDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type ) -{ - return SSMSaveDisplayMode ( source_type, (int)mode ); -} - -int CTv::Tv_SetNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type, int is_save ) -{ - return mVpp.SetNoiseReductionMode((vpp_noise_reduction_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt, is_save); -} - -int CTv::Tv_SaveNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type ) -{ - return mVpp.SaveNoiseReductionMode ( mode, source_type ); -} - -int CTv::Tv_Set2k4k_ScalerUp_Mode ( int value ) -{ - int ret = 0, fmt_hd_sd = 0; - int nodeVal = 0; - char s[8]; - - LOGD("%s, value [%d]\n", __FUNCTION__ , value); - - - if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV - && CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { - int fd = open("/sys/class/video/frame_height", O_RDONLY); - if (fd <= 0) { - LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); - return -1; - } - read(fd, s, sizeof(s)); - close(fd); - nodeVal = atoi(s); - if (nodeVal < 900) { - fmt_hd_sd = 0; - } else { - fmt_hd_sd = 1; - } - - } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { - if (isSDFmtInHdmi()) { - fmt_hd_sd = 0; - } else { - fmt_hd_sd = 1; - } - - } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { - fmt_hd_sd = 0; - } - - switch (value) { - case 1: // on - if (fmt_hd_sd) { - ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", "0"); - //LOGD("%s, enable, set 0.\n", __FUNCTION__); - } else { - ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", "1"); - } - break; - - case 0: // off - default: - if (fmt_hd_sd) { - ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", "1"); - //LOGD("%s, disable, set 1.\n", __FUNCTION__); - } else { - ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", "0"); - //LOGD("%s, disable, set 0.\n", __FUNCTION__); - } - break; - } - - return ret; -} - -int CTv::Tv_Get2k4k_ScalerUp_Mode ( void ) -{ - char attrV[64]; - int ret = 0, fmt_hd_sd = 0; - int nodeVal = 0; - char s[8]; - - memset (attrV, '\0', 64); - - if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV - && CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { - int fd = open("/sys/class/video/frame_height", O_RDONLY); - if (fd <= 0) { - LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); - return -1; - } - read(fd, s, sizeof(s)); - close(fd); - nodeVal = atoi(s); - if (nodeVal < 900) { - fmt_hd_sd = 0; - } else { - fmt_hd_sd = 1; - } - - } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { - if (isSDFmtInHdmi()) { - fmt_hd_sd = 0; - } else { - fmt_hd_sd = 1; - } - - } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { - fmt_hd_sd = 0; - } - - Tv_Utils_GetFileAttrStr("/sys/class/video/video_scaler_path_sel", 64, attrV); - //LOGD("%s, 11111111scaler_path_sel[%s].\n", __FUNCTION__ , attrV); - if (strncasecmp(attrV, "1", strlen ("1")) == 0) { - if (fmt_hd_sd) { - ret = 0; - } else { - ret = 1; - } - } else if (strncasecmp(attrV, "0", strlen ("0")) == 0) { - if (fmt_hd_sd) { - ret = 1; - } else { - ret = 0; - } - } else { - - ret = -1; - } - - return ret; -} - -int CTv::Tv_SetSplitScreenDemoStatus(tv_source_input_type_t source_type, int onoff_status) -{ - int ret = 0; - LOGD("%s, split screen demo status source[%d],onoff_stauts[%d]\n", __FUNCTION__ , source_type, onoff_status); - if (1 == onoff_status) { - ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", "w 0x503c0 v 0x31d6");//sharpness screen left - ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", "w 0x07 v 0x174d");//nr screen left - } else if (0 == onoff_status) { - ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", "w 0x503c0 v 0x31d6");//sharpness screen left - ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", "w 0x07 v 0x174d");//nr screen left - } - - if (fbcIns != NULL && 0 == ret) { - ret |= fbcIns->cfbc_SET_SPLIT_SCREEN_DEMO(COMM_DEV_SERIAL, onoff_status); - } - - return ret; -} - -int CTv::Tv_GetSplitScreenDemoStatus(tv_source_input_type_t source_type) -{ - return 0; -} - -vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_t source_type ) -{ - return mVpp.GetNoiseReductionMode((tv_source_input_type_t)source_type); +VIDEO_3D_MODE_T CTv::Tv_Get3DMode ( void ) { + return m_mode_3d; } -/** - * @parameter mode : 0:sharpness; 1:NR - * - 1.sharpness分屏(可以控制宽度) - 分屏大小 寄存器范围是0x50000 冿x50780,左效果的范围越来越大?0x70780 冿x70000也是一样? - 左右调换控制 bit 17. 开僿控制 bit 16. 0-11bit 是控制宽度的。范围是0-0x780?920像素? - 左做效果处理 echo w 0x503c0 v 0x31d6 > /sys/class/amlogic/debug - 右做效果处理 echo w 0x703c0 v 0x31d6 > /sys/class/amlogic/debug - echo w 0x403c0 v 0x31d6 > /sys/class/amlogic/debug - - 2. NR分屏(不能控制宽度) - 左做效果处理 echo w 0x07 v 0x174d > /sys /class/amlogic/debug - 右做效果处理 echo w 0x70 v 0x174d > /sys /class/amlogic/debug - 僿 echo w 0x77 v 0x174d > /sys/class/amlogic/debug - - */ -int CTv::Tv_SplitScreenEffect(int mode, int width, int reverse) -{ - int ret = -1; - - if (mode == 0) { - if (width == 0) {//close - ret = mVpp.VPP_SplitScreenEffect(0x403c0, 0x31d6); - } else { - int val = 0; - if (reverse == 0) {//left effect - val = width + 0x50000; - } else {//right effect - val = 0x70780 - width; - } - ret = mVpp.VPP_SplitScreenEffect(val, 0x31d6); - } - } else if (mode == 1) { - if (width == 0) {//close - ret = mVpp.VPP_SplitScreenEffect(0x77, 0x174d); - } else { - if (reverse == 0) - ret = mVpp.VPP_SplitScreenEffect(0x07, 0x174d); - else - ret = mVpp.VPP_SplitScreenEffect(0x70, 0x174d); - } - } else if (mode == 2) { - if (mB_hdmiout_fbc) {//hava fbc - - } else {//not have fbc - - } - } - - return ret; +int CTv::Tv_Set3DLRSwith ( int on_off) { + LOGW ( "%s,Set3D LRSwith on_off %d ,status %d !!! ", __FUNCTION__, on_off); + mAv.set3DMode(m_mode_3d, on_off, 0); + SSMSave3DLRSwitch(on_off); + return 0; } -int CTv::Tv_FactorySetPQMode_Brightness ( int source_type, int pq_mode, int brightness ) -{ - return mVpp.FactorySetPQMode_Brightness(source_type, pq_mode, brightness); +int CTv::Tv_Get3DLRSwith ( void ) { + unsigned char val = 0; + SSMRead3DLRSwitch ( &val ); + return ( int ) val; } -int CTv::Tv_FactoryGetPQMode_Brightness ( int source_type, int pq_mode ) -{ - return mVpp.FactoryGetPQMode_Brightness(source_type, pq_mode); +int CTv::Tv_Set3DTo2DMode ( int mode) { + LOGW ( "%s,Set3D to 2D mode %d ,status %d !!! ", __FUNCTION__ , mode); + mAv.set3DMode(m_mode_3d, 0, mode); + SSMSave3DTO2D ( mode ); + return 0; } -int CTv::Tv_FactorySetPQMode_Contrast ( int source_type, int pq_mode, int contrast ) -{ - return mVpp.FactorySetPQMode_Contrast(source_type, pq_mode, contrast); +int CTv::Tv_Get3DTo2DMode ( void ) { + unsigned char val = 0; + SSMRead3DTO2D ( &val ); + return val; } -int CTv::Tv_FactoryGetPQMode_Contrast ( int source_type, int pq_mode ) -{ - return mVpp.FactoryGetPQMode_Contrast(source_type, pq_mode); +int CTv::Tv_Set3DDepth ( int value ) { + mTvin.Tvin_SetDepthOf2Dto3D( value ); + SSMSave3DDepth ( value ); + return 0; } -int CTv::Tv_FactorySetPQMode_Saturation ( int source_type, int pq_mode, int saturation ) -{ - return mVpp.FactorySetPQMode_Saturation(source_type, pq_mode, saturation); +int CTv::GetSave3DDepth ( void ) { + unsigned char val = 0; + SSMRead3DDepth ( &val ); + return val; } -int CTv::Tv_FactoryGetPQMode_Saturation ( int source_type, int pq_mode ) -{ - return mVpp.FactoryGetPQMode_Saturation(source_type, pq_mode); +is_3d_type_t CTv::Check2Dor3D ( VIDEO_3D_MODE_T mode3d, tvin_trans_fmt_t trans_fmt ) { + if ( mode3d == VIDEO_3D_MODE_DISABLE ) { + return INDEX_2D; + } else if ( mode3d == VIDEO_3D_MODE_AUTO ) { + if ( trans_fmt == TVIN_TFMT_2D ) { + return INDEX_2D; + } else { + return INDEX_3D; + } + } else { + return INDEX_3D; + } } -int CTv::Tv_FactorySetPQMode_Hue ( int source_type, int pq_mode, int hue ) -{ - return mVpp.FactorySetPQMode_Hue(source_type, pq_mode, hue); -} +int CTv::Tvin_SetPLLValues (){ + tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); + am_regs_t regs; -int CTv::Tv_FactoryGetPQMode_Hue ( int source_type, int pq_mode ) -{ - return mVpp.FactoryGetPQMode_Hue(source_type, pq_mode); -} + if ( mVpp.getPqData()->PQ_GetPLLParams ( source_port, sig_fmt, ®s ) == 0 ) { + LOGD ("%s,PQ_GetPLLParams(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, source_port, sig_fmt ); -int CTv::Tv_FactorySetPQMode_Sharpness ( int source_type, int pq_mode, int sharpness ) -{ - return mVpp.FactorySetPQMode_Sharpness(source_type, pq_mode, sharpness); -} + if ( mTvin.TvinApi_LoadPLLValues ( regs ) < 0 ) { + LOGE ( "%s, TvinApi_LoadPLLValues failed!\n", __FUNCTION__ ); + return -1; + } + } else { + LOGE ( "%s, PQ_GetPLLParams failed!\n", __FUNCTION__ ); + return -1; + } -int CTv::Tv_FactoryGetPQMode_Sharpness ( int source_type, int pq_mode ) -{ - return mVpp.FactoryGetPQMode_Sharpness(source_type, pq_mode); + return 0; } -int CTv::GetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) -{ - if (mB_hdmiout_fbc) { - int ret = Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)Tempmode, params); - params->r_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->r_gain); - params->g_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->g_gain); - params->b_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->b_gain); - params->r_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->r_post_offset); - params->g_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->g_post_offset); - params->b_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->b_post_offset); - return ret; - } else { - return mVpp.GetColorTemperatureParams(Tempmode, params); - } -} +int CTv::SetCVD2Values () { + tvin_sig_fmt_t sig_fmt = mSigDetectThread.getCurSigInfo().fmt; + tvin_port_t source_port = CTvin::Tvin_GetSourcePortBySourceInput(m_source_input); + am_regs_t regs; -int CTv::Tv_FactorySetTestPattern ( int pattern ) -{ - switch ( pattern ) { - case VPP_TEST_PATTERN_NONE: - mAv.SetVideoScreenColor ( 3, 16, 128, 128 ); - break; + if (mVpp.getPqData()->PQ_GetCVD2Params ( source_port, sig_fmt, ®s ) == 0) { + LOGD ( "%s, PQ_GetCVD2Params(source_port[%d], sig_fmt[%d],®s).\n", __FUNCTION__, + source_port, sig_fmt ); - case VPP_TEST_PATTERN_RED: - mAv.SetVideoScreenColor ( 0, 81, 90, 240 ); - break; + if ( mTvin.TvinApi_LoadCVD2Values ( regs ) < 0 ) { + LOGE ( "%s, TvinApi_LoadCVD2Values failed!\n", __FUNCTION__); + return -1; + } + } else { + LOGE ( "%s, PQ_GetCVD2Params failed!\n", __FUNCTION__); + return -1; + } - case VPP_TEST_PATTERN_GREEN: - mAv.SetVideoScreenColor ( 0, 145, 54, 34 ); - break; + return 0; +} - case VPP_TEST_PATTERN_BLUE: - mAv.SetVideoScreenColor ( 0, 41, 240, 110 ); - break; +int CTv::SetPreviewWindow ( tvin_window_pos_t pos ) { + m_win_pos.x1 = pos.x1; + m_win_pos.y1 = pos.y1; + m_win_pos.x2 = pos.x2; + m_win_pos.y2 = pos.y2; + LOGD ( "%s, SetPreviewWindow x = %d y=%d", __FUNCTION__, pos.x2, pos.y2 ); - case VPP_TEST_PATTERN_WHITE: - mAv.SetVideoScreenColor ( 0, 235, 128, 128 ); - break; + tvin_window_pos_t def_pos; + Vpp_GetDisplayResolutionInfo(&def_pos); - case VPP_TEST_PATTERN_BLACK: - mAv.SetVideoScreenColor ( 0, 16, 128, 128 ); - break; + if (pos.x1 != 0 || pos.y1 != 0 || pos.x2 != def_pos.x2 || pos.y2 != def_pos.y2) { + m_win_mode = PREVIEW_WONDOW; + } else { + m_win_mode = NORMAL_WONDOW; + } - default: - return -1; - } - return SSMSaveTestPattern ( pattern ); + return mAv.setVideoAxis(m_win_pos.x1, m_win_pos.y1, m_win_pos.x2, m_win_pos.y2); } -int CTv::Tv_FactoryGetTestPattern ( void ) -{ - return mVpp.FactoryGetTestPattern(); -} -int CTv::Tv_FactorySetScreenColor ( int vdin_blending_mask, int y, int u, int v ) -{ - return mAv.SetVideoScreenColor ( vdin_blending_mask, y, u, v ); -} -int CTv::Tv_FactoryResetPQMode ( void ) -{ - return mVpp.FactoryResetPQMode(); +/*********************** Audio start **********************/ +int CTv::SetAudioVolDigitLUTTable ( tv_source_input_t source_input ) { + int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; + int lut_table_index = 0; + if (source_input == SOURCE_TV) { + lut_table_index = CC_GET_LUT_TV; + } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { + lut_table_index = CC_GET_LUT_AV; + } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2) { + lut_table_index = CC_GET_LUT_COMP; + } else if (source_input == SOURCE_VGA) { + lut_table_index = CC_GET_LUT_VGA; + } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { + lut_table_index = CC_GET_LUT_HDMI; + } else if ( source_input == SOURCE_MPEG ) { + lut_table_index = CC_GET_LUT_MPEG; + } else if ( source_input == SOURCE_DTV ) { + lut_table_index = CC_GET_LUT_MPEG; + } else if ( source_input == SOURCE_MAX) { + return 0; + } + char MainVolLutTableName[128]; + const char *baseName = GetAudioAmpMainvolTableBaseName(lut_table_index); + strcpy(MainVolLutTableName, baseName); + const char *dName = "."; + strcat(MainVolLutTableName, dName); + strcat(MainVolLutTableName, GetMainVolLutTableExtraName()); + if ( GetAudioAmpMainvolBuf(MainVolLutTableName, tmpDefDigitLutBuf) == 0) { + AudioSetVolumeDigitLUTBuf ( lut_table_index, tmpDefDigitLutBuf); + } + return 0; +} + +void CTv::RefreshAudioMasterVolume ( tv_source_input_t source_input ) { + if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { + if ( GetAudioDVISupportEnable() == 1 ) { + if ( IsDVISignal() ) { + SetAudioVolDigitLUTTable ( SOURCE_MPEG ); + SetAudioMasterVolume ( GetAudioMasterVolume() ); + return; + } + } + } + + SetAudioVolDigitLUTTable ( source_input ); + SetAudioMasterVolume ( GetAudioMasterVolume() ); +} + +int CTv::Tv_SetAudioInSource (tv_source_input_t source_input) { + int vol = 255; + if (source_input == SOURCE_TV) { + if (mTvin.Tvin_GetAudioInSourceType(source_input) == TV_AUDIO_IN_SOURCE_TYPE_ATV) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_ATV); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_ATV); + LOGD("%s, atv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); + } else { + LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); + } + } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); + } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || source_input == SOURCE_HDMI3) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); + } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || + source_input == SOURCE_TYPE_VGA) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_LINEIN); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_LINEIN); + } else if (source_input == SOURCE_MPEG) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); + } else if (source_input == SOURCE_DTV) { + AudioSetAudioInSource(CC_AUDIO_IN_SOURCE_HDMI); + vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(CC_AUDIO_IN_SOURCE_HDMI); + LOGD("%s, dtv DAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); + } + LOGD("%s, we have read SetDAC_Digital_PlayBack_Volume = %d\n", __FUNCTION__, vol); + + return 0; +} + +int CTv::Tv_SetAudioSourceType (tv_source_input_t source_input) { + int audio_source = -1; + + if (source_input == SOURCE_TV) { + audio_source = AUDIO_ATV_SOURCE; + } else if (source_input == SOURCE_AV1 || source_input == SOURCE_AV2) { + audio_source = AUDIO_AV_SOURCE; + } else if (source_input == SOURCE_HDMI1 || source_input == SOURCE_HDMI2 || + source_input == SOURCE_HDMI3) { + audio_source = AUDIO_HDMI_SOURCE; + } else if (source_input == SOURCE_YPBPR1 || source_input == SOURCE_YPBPR2 || + source_input == SOURCE_TYPE_VGA) { + audio_source = AUDIO_AV_SOURCE; + } else if (source_input == SOURCE_DTV) { + audio_source = AUDIO_MPEG_SOURCE; + } else { + audio_source = AUDIO_MPEG_SOURCE; + } + + return AudioSetAudioSourceType(audio_source); +} + +void CTv::Tv_SetAudioOutputSwap_Type (tv_source_input_t source_input) { + int sw_status = GetAudioOutputSwapStatus(source_input); + SetOutput_Swap(sw_status); +} + +void CTv::Tv_ADCDigitalCapture_Volume (void) { + int capture_vol = GetADCDigitalCaptureVol_Cfg(); + LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, capture_vol); + SetADC_Digital_Capture_Volume(capture_vol); +} + +void CTv::Tv_SetPGAIn_Gain (void) { + int gain_val = GetAudioInternalDacPGAInGain_Cfg(); + LOGD("%s, we have read ADCDigitalCaptureVol_Config = %d \n", __FUNCTION__, gain_val); + SetPGA_IN_Value(gain_val); +} + +void CTv::Tv_SetDACDigitalPlayBack_Volume (int audio_src_in_type) { + int vol = GetAudioInternalDACDigitalPlayBackVolume_Cfg(audio_src_in_type); + LOGD("%s, we have read DACDigitalPlayBackVolume config = %d \n", __FUNCTION__, vol); + SetDAC_Digital_PlayBack_Volume(vol); } +/*********************** Audio end **********************/ -int CTv::Tv_FactoryResetColorTemp ( void ) -{ - return mVpp.FactoryResetColorTemp(); +unsigned int CTv::Vpp_GetDisplayResolutionInfo(tvin_window_pos_t *win_pos) { + int display_resolution = mAv.getVideoDisplayResolution(); + int width = 0, height = 0; + switch (display_resolution) { + case VPP_DISPLAY_RESOLUTION_1366X768: + width = CC_RESOLUTION_1366X768_W; + height = CC_RESOLUTION_1366X768_H; + break; + case VPP_DISPLAY_RESOLUTION_1920X1080: + width = CC_RESOLUTION_1920X1080_W; + height = CC_RESOLUTION_1920X1080_H; + break; + case VPP_DISPLAY_RESOLUTION_3840X2160: + width = CC_RESOLUTION_3840X2160_W; + height = CC_RESOLUTION_3840X2160_H; + break; + default: + width = CC_RESOLUTION_3840X2160_W; + height = CC_RESOLUTION_3840X2160_H; + break; + } + + if (win_pos != NULL) { + win_pos->x1 = 0; + win_pos->y1 = 0; + win_pos->x2 = width - 1; + win_pos->y2 = height - 1; + } + return 0; +} + +int CTv::setBlackoutEnable(int enable) { + m_blackout_enable = enable; + return SSMSaveBlackoutEnable(enable); +} + +int CTv::getSaveBlackoutEnable() { + int8_t enable; + SSMReadBlackoutEnable(&enable); + return enable; +} + +void CTv::startAutoBackLight() { + if (mHdmiOutFbc) { + Tv_FactorySet_FBC_Auto_Backlight_OnOff(1); + } else { + mAutoBackLight.startAutoBacklight(CTvin::Tvin_SourceInputToSourceInputType(m_source_input)); + } +} + +void CTv::stopAutoBackLight() { + if (mHdmiOutFbc) { + Tv_FactorySet_FBC_Auto_Backlight_OnOff(0); + } else { + mAutoBackLight.stopAutoBacklight(); + } +} + +int CTv::getAutoBackLight_on_off() { + if (mHdmiOutFbc) { + return Tv_FactoryGet_FBC_Auto_Backlight_OnOff(); + } else { + return mAutoBackLight.isAutoBacklightOn() ? 1 : 0; + } +} + +int CTv::getAverageLuma() { + return mTvin.VDIN_Get_avg_luma(); +} + +int CTv::setAutobacklightData(const char* value) { + const char* KEY ="haier.autobacklight.mp.data"; + + const char * keyValue = config_get_str(CFG_SECTION_TV, KEY, "null"); + if (strcmp(keyValue, value) != 0) { + config_set_str(CFG_SECTION_TV, KEY, value); + LOGD("%s, config string now set as: %s \n", __FUNCTION__, keyValue); + } else { + LOGD("%s, config string has been set as: %s \n", __FUNCTION__, keyValue); + } + return 0; +} + +int CTv::getAutoBacklightData(int* data) { + char datas[512] = {0}; + char delims[] = ","; + char *result = NULL; + const char* KEY ="haier.autobacklight.mp.data"; + int i = 0; + + if (NULL == data) { + LOGD("%s, data is null", __FUNCTION__); + return -1; + } + + const char * keyValue = config_get_str(CFG_SECTION_TV, KEY, (char *) "null"); + if (strcmp(keyValue,"null") == 0) { + LOGD("%s, value is NULL\n",__FUNCTION__); + return -1; + } + + strncpy(datas, keyValue, sizeof(datas)-1); + result = strtok( datas, delims ); + while ( result != NULL ) { + char *pd = strstr(result, ":"); + if (pd != NULL) { + data[i] = strtol(pd+1, NULL, 10 ); + i++; + } + result = strtok( NULL, delims ); + } + return i; } -int CTv::Tv_FactorySetParamsDefault ( void ) -{ - return mVpp.FactorySetParamsDefault(); +/*********************** SSM start **********************/ +int CTv::Tv_SSMRestoreDefaultSetting() { + SSMRestoreDeviceMarkValues(); + AudioSSMRestoreDefaultSetting(); + mVpp.VPPSSMRestoreDefault(); + MiscSSMRestoreDefault(); + ReservedSSMRestoreDefault(); + SSMSaveCVBSStd ( 0 ); + SSMSaveLastSelectSourceInput ( SOURCE_TV ); + SSMSavePanelType ( 0 ); + //tvconfig default + saveDTVProgramID ( -1 ); + saveATVProgramID ( -1 ); + SSMSaveStandbyMode( 0 ); + return 0; } -int CTv::Tv_FactorySetDDRSSC ( int step ) -{ - return mVpp.FactorySetDDRSSC(step); +int CTv::clearDbAllProgramInfoTable() { + return CTvDatabase::GetTvDb()->clearDbAllProgramInfoTable(); } -int CTv::Tv_FactoryGetDDRSSC ( void ) -{ - return mVpp.FactoryGetDDRSSC(); -} +int CTv::Tv_SSMFacRestoreDefaultSetting() { + mVpp.VPPSSMFacRestoreDefault(); + AudioSSMRestoreDefaultSetting(); + MiscSSMFacRestoreDefault(); -int CTv::Tv_FactorySetLVDSSSC ( int step ) -{ - return mVpp.FactorySetLVDSSSC(step); + return 0; } +/*********************** SSM End **********************/ -int CTv::Tv_FactoryGetLVDSSSC ( void ) -{ - return mVpp.FactoryGetLVDSSSC(); -} -void CTv::Tv_Spread_Spectrum() -{ - int value= 0; - value = mVpp.FactoryGetLVDSSSC(); - mVpp.FactorySetLVDSSSC(value); +//not in CTv, not use lock +void CTv::setSourceSwitchAndPlay() { + int progID = 0, ret = -1; + CTvProgram prog; + LOGD ( "%s\n", __FUNCTION__ ); + static const int POWERON_SOURCE_TYPE_NONE = 0;//not play source + static const int POWERON_SOURCE_TYPE_LAST = 1;//play last save source + static const int POWERON_SOURCE_TYPE_SETTING = 2;//play ui set source + int to_play_source = -1; + int powerup_type = SSMReadPowerOnOffChannel(); + LOGD("read power on source type = %d", powerup_type); + if (powerup_type == POWERON_SOURCE_TYPE_NONE) { + return ; + } else if (powerup_type == POWERON_SOURCE_TYPE_LAST) { + to_play_source = SSMReadSourceInput(); + } else if (powerup_type == POWERON_SOURCE_TYPE_SETTING) { + to_play_source = SSMReadLastSelectSourceInput(); + } + SetSourceSwitchInput (( tv_source_input_t ) to_play_source ); + if ( to_play_source == SOURCE_TV ) { + progID = getATVProgramID(); + } else if ( to_play_source == SOURCE_DTV ) { + progID = getDTVProgramID(); + } + playProgramLock(progID); +} + +int CTv::startCC(int country, int src, int channel, int service) { + //turn_on_cc = true; + return mSubtitle.sub_start_atsc_cc((enum cc_param_country)country, (enum cc_param_source_type)src, channel, (enum cc_param_caption_type)service); +} + +int CTv::stopCC() { + //because cc,vchip data both come from vbi thread , here judge cc, vchip is whether both turn off + /*turn_on_cc = false; + if (config_get_int(CFG_SECTION_TV,"tv.vchip.enable", 0)) + { + return 0; //at ATV if vchip is on, turn off CC, just set flag not display CC, but vchip still running + }*/ + return mSubtitle.sub_stop_atsc_cc(); +} + +void CTv::printDebugInfo() { + print_version_info(); + LOGD("%s, TvAction = %x", __FUNCTION__, mTvAction); + LOGD("%s, TvRunStatus = %d", __FUNCTION__, mTvStatus); + LOGD("%s, TvCurSourceInput = %d", __FUNCTION__, m_source_input); + LOGD("%s, TvLastSourceInput = %d", __FUNCTION__, m_last_source_input); } +//==============vchip end================================ -int CTv::Tv_FactorySetNolineParams ( int noline_params_type, int source_type, noline_params_t noline_params ) -{ - return mVpp.FactorySetNolineParams(noline_params_type, source_type, noline_params); +//----------------DVR API============================ +void CTv::SetRecordFileName ( char *name ) { + char tmp[256]; + strcpy ( tmp, name ); + mTvRec.SetRecordFileName ( tmp ); +} + +void CTv::StartToRecord() { + int progID = getDTVProgramID(); + mTvRec.StartRecord ( progID ); +} + +void CTv::StopRecording() { + mTvRec.StopRecord(); +} + +void CTv::SetRecCurTsOrCurProgram ( int sel ) { + mTvRec.SetRecCurTsOrCurProgram ( sel ); +} + +int CTv::GetDisplayResolutionConfig() { + return mAv.getVideoDisplayResolution(); +} + +int CTv::GetDisplayResolutionInfo() { + return Vpp_GetDisplayResolutionInfo(NULL); +} + +void CTv::onHDMIRxCECMessage(int msg_len, unsigned char msg_buf[]) { + int i = 0; + TvEvent::HDMIRxCECEvent ev; + ev.mDataCount = msg_len; + for (i = 0; i < msg_len; i++) { + ev.mDataBuf[i] = msg_buf[i]; + } + sendTvEvent(ev); +} + +int CTv::SendHDMIRxCECCustomMessage(unsigned char data_buf[]) { + tv_source_input_t source_input = m_source_input; + return mHDMIRxCEC.SendCustomMessage(source_input, data_buf); +} + +int CTv::SendHDMIRxCECCustomMessageAndWaitReply(unsigned char data_buf[], unsigned char reply_buf[], int WaitCmd, int timeout) { + tv_source_input_t source_input = m_source_input; + return mHDMIRxCEC.SendCustomMessageAndWaitReply(source_input, data_buf, reply_buf, WaitCmd, timeout); +} + +int CTv::SendHDMIRxCECBoradcastStandbyMessage(void) { + tv_source_input_t source_input = m_source_input; + return mHDMIRxCEC.SendBoradcastStandbyMessage(source_input); +} + +int CTv::SendHDMIRxCECGiveCECVersionMessage(tv_source_input_t source_input, unsigned char data_buf[]) { + if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { + return mHDMIRxCEC.SendGiveCECVersionMessage(source_input, data_buf); + } + + return -1; +} + +int CTv::SendHDMIRxCECGiveDeviceVendorIDMessage(tv_source_input_t source_input, unsigned char data_buf[]) { + if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { + return mHDMIRxCEC.SendGiveDeviceVendorIDMessage(source_input, data_buf); + } + + return -1; +} + +int CTv::SendHDMIRxCECGiveOSDNameMessage(tv_source_input_t source_input, unsigned char data_buf[]) { + if (mHDMIRxCEC.processRefreshSrcDevice(source_input) == 0) { + return mHDMIRxCEC.SendGiveOSDNameMessage(source_input, data_buf); + } + + return -1; +} + +int CTv::GetHdmiHdcpKeyKsvInfo(int data_buf[]) { + return mTvin.get_hdmi_ksv_info(m_source_input, data_buf); +} + +bool CTv::hdmiOutWithFbc() { + const char * value = config_get_str(CFG_SECTION_TV, "platform.havefbc", "true"); + if (strcmp(value, "true") == 0) { + return true; + } + + return false; +} + +void CTv::onUpgradeStatus(int state, int param) { + TvEvent::UpgradeFBCEvent ev; + ev.mState = state; + ev.param = param; + sendTvEvent(ev); +} + +int CTv::StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size) { + if (mpUpgradeFBC != NULL) { + mpUpgradeFBC->SetUpgradeFileName(file_name); + mpUpgradeFBC->SetUpgradeMode(mode); + mpUpgradeFBC->SetUpgradeBlockSize(upgrade_blk_size); + mpUpgradeFBC->start(); + return 0; + } + + return -1; +} + +void CTv::onSerialCommunication(int dev_id, int rd_len, unsigned char data_buf[]) { + int i = 0; + TvEvent::SerialCommunicationEvent ev; + ev.mDevId = dev_id; + ev.mDataCount = rd_len; + for (i = 0; i < rd_len; i++) { + ev.mDataBuf[i] = data_buf[i]; + } + sendTvEvent(ev); +} + +int CTv::StartHeadSetDetect() { + mHeadSet.startDetect(); + return 0; +} + +void CTv::onHeadSetDetect(int state,int para) { + TvEvent::HeadSetOf2d4GEvent ev; + if (state == 1) + property_set("audio.headset_plug.enable", "1"); + else + property_set("audio.headset_plug.enable", "0"); + ev.state = state; + ev.para = para; + sendTvEvent(ev); +} + +void CTv::onThermalDetect(int state) { + const char *value; + const char *value_normal; + const char *value_cold; + int threshold = 0, val = 0; + static int pre_val = -1; + + value = config_get_str ( CFG_SECTION_TV, "tvin.thermal.threshold.enable", "null" ); + if ( strcmp ( value, "enable" ) == 0 ) { + value = config_get_str ( CFG_SECTION_TV, "tvin.thermal.threshold.value", "null" ); + threshold = atoi(value); + LOGD ( "%s, threshold value: %d\n", __FUNCTION__, threshold); + + if (state > threshold) { + value_normal = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.normal.value", "null" ); + val = atoi(value_normal); + if (val == 0) { + val = 0x4210000; //normal default + } + LOGD ( "%s, current temp: %d set 1\n", __FUNCTION__, state); + } else { + value_cold = config_get_str ( CFG_SECTION_TV, "tvin.thermal.fbc.cold.value", "null" ); + val = atoi(value_cold); + if (val == 0) { + val = 0x8210000; //cold default + } + LOGD ( "%s, current temp: 0x%x set 0\n", __FUNCTION__, state); + } + + if (pre_val == val) { + LOGD ( "%s, pre_val == val : 0x%x,bypass\n", __FUNCTION__, val); + } else { + pre_val = val; + Tv_FactorySet_FBC_Thermal_State(val); + LOGD ( "%s, pre_val :0x%x,bypass\n", __FUNCTION__, pre_val); + } + } else { + LOGD ( "%s, tvin.thermal.threshold.enable == disable\n", __FUNCTION__); + } +} + +int CTv::SetDebugSerialOnOff(int on_off) { + if (on_off) { + property_set("ubootenv.var.console", "ttyS0,115200n8"); + } else { + property_set("ubootenv.var.console", "off"); + } + return 0; +} + +int CTv::GetDebugSerialOnOff() { + char prop[256]; + memset(prop, '\0', 256); + property_get("ubootenv.var.console", prop, "null" ); + + if (!strcmp(prop, "ttyS0,115200n8")) { + return 1; + } else { + return 0; + } +} + +int CTv::SetSerialSwitch(int dev_id, int switch_val) { + int tmp_ret = 0; + if (dev_id == SERIAL_A) { + if (switch_val == 0) { + tmp_ret |= mSerialA.stop(); + tmp_ret |= mSerialA.CloseModule(); + + tmp_ret |= system("start console"); + tmp_ret |= system("echo 7 > /proc/sys/kernel/printk"); + } else { + tmp_ret |= system("echo 0 > /proc/sys/kernel/printk"); + tmp_ret |= system("stop console"); + + mSerialA.OpenModule(dev_id); + tmp_ret |= mSerialA.start(); + } + } else if (dev_id == SERIAL_B) { + if (switch_val == 0) { + tmp_ret |= mSerialB.stop(); + tmp_ret |= mSerialB.CloseModule(); + } else { + mSerialB.OpenModule(dev_id); + tmp_ret = mSerialB.start(); + } + } else if (dev_id == SERIAL_C) { + if (switch_val == 0) { + tmp_ret |= mSerialC.stop(); + tmp_ret |= mSerialC.CloseModule(); + } else { + mSerialC.OpenModule(dev_id); + tmp_ret = mSerialC.start(); + } + } + + return tmp_ret; +} + +int CTv::SendSerialData(int dev_id, int data_len, unsigned char data_buf[]) { + int tmp_ret = 0; + + if (dev_id == SERIAL_A) { + tmp_ret = mSerialA.sendData(data_len, data_buf); + } else if (dev_id == SERIAL_B) { + tmp_ret = mSerialB.sendData(data_len, data_buf); + } else if (dev_id == SERIAL_C) { + tmp_ret = mSerialC.sendData(data_len, data_buf); + } + + return tmp_ret; +} + +int CTv::ChannelExport(const char *destPath) { + //DIR *dirptr = NULL; + //dirptr = opendir("/storage/external_storage/sda1/"); + //if(NULL == dirptr) { + // LOGD("%s, please insert the udisk !",__FUNCTION__); + // return -2; + // } else { + char tmp[256]; + FILE *fp = NULL; + if (destPath == NULL) { + destPath = "/storage/external_storage/sda1/"; + } + + //LOGD("%s, udisk exist !",__FUNCTION__); + sprintf(tmp, "cp /param/dtv.db %s", destPath); + if (system(tmp) >= 0) { + LOGD("%s, copy dtv.db from /param to udisk success !", __FUNCTION__); + system("sync"); + fp = fopen(destPath, "r"); + if (fp == NULL) { + return -1; + } else { + fclose(fp); + fp = NULL; + return 0; + } + } else { + return -1; + } + //} +} + +int CTv::ChannelImport(const char *srcPath) { + if (srcPath == NULL) { + srcPath = "/storage/external_storage/sda1/dvb.db"; + } + + if (Tv_Utils_IsFileExist(srcPath)) { + char tmp[256]; + const char *destPath = config_get_str(CFG_SECTION_TV, "tv.channel.db", (char *) "/param/dtv.db"); + + LOGD("%s, file exist !" , srcPath); + CTvDatabase::GetTvDb()->UnInitTvDb(); + sprintf(tmp, "rm %s", destPath); + if (system(tmp) >= 0) { + LOGD("%s, rm %s success !", __FUNCTION__, destPath); + memset(tmp, 0, sizeof(tmp)); + sprintf(tmp, "cp %s %s", srcPath, destPath); + if (system(tmp) >= 0) { + LOGD("%s, copy to %s success !", srcPath, destPath); + memset(tmp, 0, sizeof(tmp)); + sprintf(tmp, "chmod 777 %s", destPath); + if (system(tmp) >= 0) { + LOGD("chmod 777 %s success !", destPath); + system("sync"); + CTvDatabase::GetTvDb()->InitTvDb(TV_DB_PATH); + return 0; + } else { + LOGD("%s, %s chmod failed !", __FUNCTION__, destPath); + return -1; + } + } else { + LOGD("%s, copy dtv.db from udisk to %s failed !", __FUNCTION__, destPath); + return -1; + } + } else { + LOGD("%s, rm %s failed !", __FUNCTION__, destPath); + return -2; + } + } else { + LOGD("%s, dtv.db file does not exist in the udisk!" , srcPath); + return -2; + } +} + +int CTv::Tv_GetProjectInfo(project_info_t *ptrInfo) { + return GetProjectInfo(ptrInfo, fbcIns); +} + +int CTv::Tv_GetPlatformType() { + return mHdmiOutFbc ? 1 : 0; +} + +int CTv::Tv_HandeHDMIEDIDFilePathConfig() { + int i, file_exist_flag = 1; + const char *value = NULL; + char val_buf[256]; + char edid_path[256]; + char edid_path_cfg[256]; + + value = config_get_str(CFG_SECTION_TV, "ssm.handle.hdmi.edid.en", "null"); + + if (strtoul(value, NULL, 10) == 1) { + LOGD( "%s, get config \"%s\" is \"%s\".\n", + __FUNCTION__, "ssm.handle.hdmi.edid.en", value); + //get hdmi edid use mode + + memset(val_buf, '\0', 256); + property_get("ubootenv.var.outputmode", val_buf, "null"); + LOGD( "%s, get property \"%s\" is \"%s\".\n", + __FUNCTION__, "ubootenv.var.outputmode", val_buf); + if (strcmp(val_buf, "null") != 0) { + config_set_str ( CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, val_buf); + + file_exist_flag = 1; + //set file's path for hdmi edid of each port + for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { + memset( edid_path, '\0', 256); + memset( edid_path_cfg, '\0', 256); + sprintf(edid_path, "/system/etc/%s_port%d.bin", val_buf, i); + sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); + if (access(edid_path, 0) < 0) { + file_exist_flag = 0; + break; + } + config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); + } + + if (file_exist_flag == 0) { + //set default hdmi edid + config_set_str(CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid"); + //set file's path for hdmi edid of each port + for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { + memset(edid_path, '\0', 256); + memset(edid_path_cfg, '\0', 256); + sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); + sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); + + value = config_get_str(CFG_SECTION_TV, edid_path_cfg, "null"); + if (strcmp(value, edid_path) != 0) { + config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); + } + } + } + } else { + //set default hdmi edid + config_set_str(CFG_SECTION_TV, CS_HDMI_EDID_USE_CFG, "hdmi_edid"); + //set file's path for hdmi edid of each port + for (i = 1; i <= SSM_HDMI_PORT_MAX; i++) { + memset(edid_path, '\0', 256); + memset(edid_path_cfg, '\0', 256); + sprintf(edid_path, "/system/etc/%s_port%d.bin", "hdmi_edid", i); + sprintf(edid_path_cfg, "ssm.handle.hdmi.port%d.edid.file.path", i); + + value = config_get_str(CFG_SECTION_TV, edid_path_cfg, "null"); + if (strcmp(value, edid_path) != 0) { + config_set_str(CFG_SECTION_TV, edid_path_cfg, edid_path); + } + } + } + m_is_set_hdmi_edid = true; + } + return 0; +} + +int CTv::Tv_SetDDDRCMode(tv_source_input_t source_input) { + if (source_input == SOURCE_DTV) { + if (GetPlatformHaveDDFlag() == 1) { + Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", (char *)"drcmode 3"); + } + } else { + if (GetPlatformHaveDDFlag() == 1) { + Tv_Utils_SetFileAttrStr("/sys/class/audiodsp/ac3_drc_control", (char *)"drcmode 2"); + } + } + return 0; } -noline_params_t CTv::Tv_FactoryGetNolineParams ( int noline_params_type, int source_type ) -{ - return mVpp.FactoryGetNolineParams(noline_params_type, source_type); +//PQ +int CTv::Tv_SetBrightness ( int brightness, tv_source_input_type_t source_type, int is_save ) { + return mVpp.SetBrightness(brightness, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); +} + +int CTv::Tv_GetBrightness ( tv_source_input_type_t source_type ) { + return mVpp.GetBrightness((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveBrightness ( int brightness, tv_source_input_type_t source_type ) { + return SSMSaveBrightness ( source_type, brightness ); +} + +int CTv::Tv_SetContrast ( int contrast, tv_source_input_type_t source_type, int is_save ) { + return mVpp.SetContrast(contrast, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); +} + +int CTv::Tv_GetContrast ( tv_source_input_type_t source_type ) { + return mVpp.GetContrast((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveContrast ( int contrast, tv_source_input_type_t source_type ) { + return SSMSaveContrast ( source_type, contrast ); +} + +int CTv::Tv_SetSaturation ( int satuation, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) { + return mVpp.SetSaturation(satuation, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); +} + +int CTv::Tv_GetSaturation ( tv_source_input_type_t source_type ) { + return mVpp.GetSaturation((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveSaturation ( int satuation, tv_source_input_type_t source_type ) { + return SSMSaveSaturation ( source_type, satuation ); +} + +int CTv::Tv_SetHue ( int hue, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) { + return mVpp.SetHue(hue, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); +} + +int CTv::Tv_GetHue ( tv_source_input_type_t source_type ) { + return mVpp.GetHue((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveHue ( int hue, tv_source_input_type_t source_type ) { + return SSMSaveHue ( source_type, hue ); +} + +int CTv::Tv_SetPQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type, int is_save ) { + return mVpp.SetPQMode((vpp_picture_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), is_save); +} + +vpp_picture_mode_t CTv::Tv_GetPQMode ( tv_source_input_type_t source_type ) { + return mVpp.GetPQMode((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SavePQMode ( vpp_picture_mode_t mode, tv_source_input_type_t source_type ) { + return mVpp.SavePQMode ( mode, source_type ); +} + +int CTv::Tv_SetSharpness ( int value, tv_source_input_type_t source_type, int en, int is_save ) { + return mVpp.SetSharpness(value, (tv_source_input_type_t)source_type, en, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().fmt, mSigDetectThread.getCurSigInfo().trans_fmt, is_save); +} + +int CTv::Tv_GetSharpness ( tv_source_input_type_t source_type ) { + return mVpp.GetSharpness((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveSharpness ( int value, tv_source_input_type_t source_type ) { + return SSMSaveSharpness ( source_type, value ); +} + +int CTv::Tv_SetBacklight ( int value, tv_source_input_type_t source_type, int is_save ) { + if (mHdmiOutFbc) { + return Tv_FactorySet_FBC_Backlight(value); + } else { + return mVpp.SetBacklight(value, (tv_source_input_type_t)source_type, is_save); + } +} + +int CTv::Tv_GetBacklight ( tv_source_input_type_t source_type ) { + if (mHdmiOutFbc) { + return Tv_FactoryGet_FBC_Backlight(); + } else { + return mVpp.GetBacklight((tv_source_input_type_t)source_type); + } +} + +int CTv::Tv_SaveBacklight ( int value, tv_source_input_type_t source_type ) { + return mVpp.SaveBacklight ( value, source_type ); +} + +int CTv::Tv_SetBacklight_Switch ( int value ) { + if (mHdmiOutFbc) { + return Tv_FactorySet_FBC_backlight_onoff(value); + } else { + return mVpp.VPP_SetBackLight_Switch(value); + } +} + +int CTv::Tv_GetBacklight_Switch ( void ) { + if (mHdmiOutFbc) { + return Tv_FactoryGet_FBC_backlight_onoff(); + } else { + return mVpp.VPP_GetBackLight_Switch(); + } +} + +int CTv::Tv_SetColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type, int is_save ) { + if (mHdmiOutFbc) { + return Tv_FactorySet_FBC_ColorTemp_Mode(mode); + } else { + return mVpp.SetColorTemperature((vpp_color_temperature_mode_t)mode, (tv_source_input_type_t)source_type, is_save); + } +} + +vpp_color_temperature_mode_t CTv::Tv_GetColorTemperature ( tv_source_input_type_t source_type ) { + if (mHdmiOutFbc) { + return (vpp_color_temperature_mode_t)Tv_FactoryGet_FBC_ColorTemp_Mode(); + } else { + return mVpp.GetColorTemperature((tv_source_input_type_t)source_type); + } +} + +int CTv::Tv_SaveColorTemperature ( vpp_color_temperature_mode_t mode, tv_source_input_type_t source_type ) { + return mVpp.SaveColorTemp ( mode, source_type ); +} + +int CTv::Tv_SetDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type, tvin_sig_fmt_t fmt, int is_save ) { + int ret = 0; + if (m_mode_3d == VIDEO_3D_MODE_DISABLE) { + ret = SetDisplayMode((vpp_display_mode_t)mode, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); + } else { //3D + ret = SetDisplayMode(VPP_DISPLAY_MODE_PERSON, (tv_source_input_type_t)source_type, (tvin_sig_fmt_t)fmt); + } + if (ret == 0) { + if (is_save == 1) { + ret = ret | SSMSaveDisplayMode ( source_type, (int)mode ); + } + } + return ret; +} + +int CTv::SetDisplayMode ( vpp_display_mode_t display_mode, tv_source_input_type_t source_type, tvin_sig_fmt_t sig_fmt ) { + LOGD("SetDisplayMode, display_mode = %d, source_type = %d fmt = %d tranfmt = %d\n", display_mode, source_type, sig_fmt, mSigDetectThread.getCurSigInfo().trans_fmt); + + tvin_cutwin_t cutwin = mVpp.GetOverscan ( source_type, sig_fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt); + LOGD("SetDisplayMode , get crop %d %d %d %d \n", cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); + int video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; + tvin_window_pos_t win_pos; + int display_resolution = Vpp_GetDisplayResolutionInfo(&win_pos); + + switch ( display_mode ) { + case VPP_DISPLAY_MODE_169: + video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; + break; + case VPP_DISPLAY_MODE_MODE43: + video_screen_mode = CAv::VIDEO_WIDEOPTION_4_3; + break; + case VPP_DISPLAY_MODE_NORMAL: + video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL; + break; + case VPP_DISPLAY_MODE_FULL: + video_screen_mode = CAv::VIDEO_WIDEOPTION_NONLINEAR; + mVpp.VPP_SetNonLinearFactor ( 20 ); + //mVpp.VPP_SetNonLinearFactor ( 20 ); + break; + case VPP_DISPLAY_MODE_CROP_FULL: + cutwin.vs = 0; + cutwin.hs = 0; + cutwin.ve = 0; + cutwin.he = 0; + break; + case VPP_DISPLAY_MODE_NOSCALEUP: + video_screen_mode = CAv::VIDEO_WIDEOPTION_NORMAL_NOSCALEUP; + break; + case VPP_DISPLAY_MODE_FULL_REAL: + video_screen_mode = CAv::VIDEO_WIDEOPTION_16_9; //added for N360 by haifeng.liu + break; + case VPP_DISPLAY_MODE_PERSON: + video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; + cutwin.vs = cutwin.vs + 20; + cutwin.ve = cutwin.ve + 20; + break; + case VPP_DISPLAY_MODE_MOVIE: + video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; + cutwin.vs = cutwin.vs + 40; + cutwin.ve = cutwin.ve + 40; + break; + case VPP_DISPLAY_MODE_CAPTION: + video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; + cutwin.vs = cutwin.vs + 55; + cutwin.ve = cutwin.ve + 55; + break; + case VPP_DISPLAY_MODE_ZOOM: + video_screen_mode = CAv::VIDEO_WIDEOPTION_FULL_STRETCH; + cutwin.vs = cutwin.vs + 70; + cutwin.ve = cutwin.ve + 70; + break; + default: + break; + } + if (source_type == SOURCE_TYPE_DTV || source_type == SOURCE_TYPE_MPEG) { + cutwin.vs = cutwin.vs + 12; + cutwin.ve = cutwin.ve + 12; + cutwin.hs = cutwin.hs + 12; + cutwin.he = cutwin.he + 12; + } + if (source_type == SOURCE_TYPE_HDMI) { + if ((IsDVISignal()) || (mTvin.GetITContent() == 1)) { + cutwin.vs = 0; + cutwin.hs = 0; + cutwin.ve = 0; + cutwin.he = 0; + } + + if (display_mode == VPP_DISPLAY_MODE_FULL_REAL) { + cutwin.vs = 0; + cutwin.hs = 0; + cutwin.ve = 0; + cutwin.he = 0; + } + } + + //mAv.setVideoAxis ( win_pos.x1, win_pos.y1, win_pos.x2, win_pos.y2 ); + mAv.setVideoScreenMode(video_screen_mode); + mVpp.VPP_SetVideoCrop(cutwin.vs, cutwin.hs, cutwin.ve, cutwin.he); + return 0; +} + +vpp_display_mode_t CTv::Tv_GetDisplayMode ( tv_source_input_type_t source_type ) { + return mVpp.GetDisplayMode((tv_source_input_type_t)source_type); +} + +int CTv::Tv_SaveDisplayMode ( vpp_display_mode_t mode, tv_source_input_type_t source_type ) { + return SSMSaveDisplayMode ( source_type, (int)mode ); +} + +int CTv::Tv_SetNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type, int is_save ) { + return mVpp.SetNoiseReductionMode((vpp_noise_reduction_mode_t)mode, (tv_source_input_type_t)source_type, mSigDetectThread.getCurSigInfo().fmt, Check2Dor3D(m_mode_3d, mSigDetectThread.getCurSigInfo().trans_fmt ), mSigDetectThread.getCurSigInfo().trans_fmt, is_save); +} + +int CTv::Tv_SaveNoiseReductionMode ( vpp_noise_reduction_mode_t mode, tv_source_input_type_t source_type ) { + return mVpp.SaveNoiseReductionMode ( mode, source_type ); +} + +int CTv::Tv_Set2k4k_ScalerUp_Mode ( int value ) { + int ret = 0, fmt_hd_sd = 0; + int nodeVal = 0; + char s[8]; + + LOGD("%s, value [%d]\n", __FUNCTION__ , value); + + if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && + CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV && + CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { + int fd = open("/sys/class/video/frame_height", O_RDONLY); + if (fd <= 0) { + LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); + return -1; + } + read(fd, s, sizeof(s)); + close(fd); + nodeVal = atoi(s); + if (nodeVal < 900) { + fmt_hd_sd = 0; + } else { + fmt_hd_sd = 1; + } + } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { + if (isSDFmtInHdmi()) { + fmt_hd_sd = 0; + } else { + fmt_hd_sd = 1; + } + } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || + CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { + fmt_hd_sd = 0; + } + + switch (value) { + case 1: // on + if (fmt_hd_sd) { + ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"0"); + //LOGD("%s, enable, set 0.\n", __FUNCTION__); + } else { + ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"1"); + } + break; + + case 0: // off + default: + if (fmt_hd_sd) { + ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"1"); + //LOGD("%s, disable, set 1.\n", __FUNCTION__); + } else { + ret = Tv_Utils_SetFileAttrStr("/sys/class/video/video_scaler_path_sel", (char *)"0"); + //LOGD("%s, disable, set 0.\n", __FUNCTION__); + } + break; + } + return ret; +} + +int CTv::Tv_Get2k4k_ScalerUp_Mode ( void ) { + char attrV[64]; + int ret = 0, fmt_hd_sd = 0; + int nodeVal = 0; + char s[8]; + + memset (attrV, '\0', 64); + + if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_HDMI && + CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_AV && + CTvin::Tvin_SourceInputToSourceInputType(m_source_input) != SOURCE_TYPE_TV) { + int fd = open("/sys/class/video/frame_height", O_RDONLY); + if (fd <= 0) { + LOGE("open /sys/class/video/frame_height ERROR!!error = -%s- \n", strerror ( errno )); + return -1; + } + read(fd, s, sizeof(s)); + close(fd); + nodeVal = atoi(s); + if (nodeVal < 900) { + fmt_hd_sd = 0; + } else { + fmt_hd_sd = 1; + } + } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_HDMI ) { + if (isSDFmtInHdmi()) { + fmt_hd_sd = 0; + } else { + fmt_hd_sd = 1; + } + } else if ( CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_AV || CTvin::Tvin_SourceInputToSourceInputType(m_source_input) == SOURCE_TYPE_TV) { + fmt_hd_sd = 0; + } + + Tv_Utils_GetFileAttrStr("/sys/class/video/video_scaler_path_sel", 64, attrV); + //LOGD("%s, 11111111scaler_path_sel[%s].\n", __FUNCTION__ , attrV); + if (strncasecmp(attrV, "1", strlen ("1")) == 0) { + if (fmt_hd_sd) { + ret = 0; + } else { + ret = 1; + } + } else if (strncasecmp(attrV, "0", strlen ("0")) == 0) { + if (fmt_hd_sd) { + ret = 1; + } else { + ret = 0; + } + } else { + ret = -1; + } + + return ret; +} + +int CTv::Tv_SetSplitScreenDemoStatus(tv_source_input_type_t source_type, int onoff_status) { + int ret = 0; + LOGD("%s, split screen demo status source[%d],onoff_stauts[%d]\n", __FUNCTION__ , source_type, onoff_status); + if (1 == onoff_status) { + ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x503c0 v 0x31d6");//sharpness screen left + ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x07 v 0x174d");//nr screen left + } else if (0 == onoff_status) { + ret = Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x503c0 v 0x31d6");//sharpness screen left + ret |= Tv_Utils_SetFileAttrStr("/sys/class/amlogic/debug", (char *)"w 0x07 v 0x174d");//nr screen left + } + + if (fbcIns != NULL && 0 == ret) { + ret |= fbcIns->cfbc_SET_SPLIT_SCREEN_DEMO(COMM_DEV_SERIAL, onoff_status); + } + + return ret; +} + +int CTv::Tv_GetSplitScreenDemoStatus(tv_source_input_type_t source_type) { + source_type = source_type; + return 0; +} + +vpp_noise_reduction_mode_t CTv::Tv_GetNoiseReductionMode ( tv_source_input_type_t source_type ) { + return mVpp.GetNoiseReductionMode((tv_source_input_type_t)source_type); } -int CTv::Tv_FactorySetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt, tvin_cutwin_t cutwin_t ) -{ - //tvin_cutwin_t cutwin_t = mVpp.Tv_FactoryGetOverscan(source_type, fmt, status_3d, trans_fmt); - mVpp.FactorySetOverscan(source_type, fmt, status_3d, trans_fmt, cutwin_t); - //} else { -#if 0 - char val_buf[256]; - memset(val_buf, '\0', 256); - LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he); - sprintf(val_buf, "%d,%d,%d,%d", ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); - config_set_str("TV", "vpp.overscan.dtv", val_buf); - //} -#endif - return mVpp.VPP_SetVideoCrop ( ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); -} +/** + * @parameter mode : 0:sharpness; 1:NR + * + 1.sharpness分屏(可以控制宽度) + 分屏大小 寄存器范围是0x50000 冿x50780,左效果的范围越来越大?0x70780 冿x70000也是一样? + 左右调换控制 bit 17. 开僿控制 bit 16. 0-11bit 是控制宽度的。范围是0-0x780?920像素? + 左做效果处理 echo w 0x503c0 v 0x31d6 > /sys/class/amlogic/debug + 右做效果处理 echo w 0x703c0 v 0x31d6 > /sys/class/amlogic/debug + echo w 0x403c0 v 0x31d6 > /sys/class/amlogic/debug + + 2. NR分屏(不能控制宽度) + 左做效果处理 echo w 0x07 v 0x174d > /sys /class/amlogic/debug + 右做效果处理 echo w 0x70 v 0x174d > /sys /class/amlogic/debug + 僿 echo w 0x77 v 0x174d > /sys/class/amlogic/debug + */ +int CTv::Tv_SplitScreenEffect(int mode, int width, int reverse) { + int ret = -1; -tvin_cutwin_t CTv::Tv_FactoryGetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt ) -{ - return mVpp.FactoryGetOverscan(source_type, fmt, Check2Dor3D(m_mode_3d, (tvin_trans_fmt_t)trans_fmt), trans_fmt); -#if 0 - else { - tvin_cutwin_t cutwin; - int ret = 0; - char tmp_buf[16]; - tmp_buf[0] = 0; - - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 0, tmp_buf)) == 0) { - cutwin.vs = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 1, tmp_buf)) == 0) { - cutwin.hs = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 2, tmp_buf)) == 0) { - cutwin.ve = strtol(tmp_buf, NULL, 10); - } - if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 3, tmp_buf)) == 0) { - cutwin.he = strtol(tmp_buf, NULL, 10); - } - LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin.vs, ( int ) cutwin.hs, ( int ) cutwin.ve, ( int ) cutwin.he); - return cutwin; - } -#endif -} + if (mode == 0) { + if (width == 0) {//close + ret = mVpp.VPP_SplitScreenEffect(0x403c0, 0x31d6); + } else { + int val = 0; + if (reverse == 0) {//left effect + val = width + 0x50000; + } else {//right effect + val = 0x70780 - width; + } + ret = mVpp.VPP_SplitScreenEffect(val, 0x31d6); + } + } else if (mode == 1) { + if (width == 0) {//close + ret = mVpp.VPP_SplitScreenEffect(0x77, 0x174d); + } else { + if (reverse == 0) + ret = mVpp.VPP_SplitScreenEffect(0x07, 0x174d); + else + ret = mVpp.VPP_SplitScreenEffect(0x70, 0x174d); + } + } else if (mode == 2) { + } -int CTv::Tv_ReplacePqDb(const char *newFilePath) -{ - return mVpp.getPqData()->replacePqDb(newFilePath); + return ret; } -int CTv::Tv_FactorySet_FBC_Brightness ( int value ) -{ - //int temp_value = (255*value)/100; - int temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Brightness(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetPQMode_Brightness ( int source_type, int pq_mode, int brightness ) { + return mVpp.FactorySetPQMode_Brightness(source_type, pq_mode, brightness); } -int CTv::Tv_FactoryGet_FBC_Brightness ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Brightness(COMM_DEV_SERIAL, &temp_value); - //data = (temp_value*100)/255; - data = temp_value; - - return data; - } - - return 0; +int CTv::Tv_FactoryGetPQMode_Brightness ( int source_type, int pq_mode ) { + return mVpp.FactoryGetPQMode_Brightness(source_type, pq_mode); } -int CTv::Tv_FactorySet_FBC_Contrast ( int value ) -{ - //int temp_value = (255*value)/100; - int temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Contrast(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetPQMode_Contrast ( int source_type, int pq_mode, int contrast ) { + return mVpp.FactorySetPQMode_Contrast(source_type, pq_mode, contrast); } -int CTv::Tv_FactoryGet_FBC_Contrast ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Contrast(COMM_DEV_SERIAL, &temp_value); - //data = (temp_value*100)/255; - data = temp_value; - - return data; - } - - return 0; +int CTv::Tv_FactoryGetPQMode_Contrast ( int source_type, int pq_mode ) { + return mVpp.FactoryGetPQMode_Contrast(source_type, pq_mode); } -int CTv::Tv_FactorySet_FBC_Saturation ( int value ) -{ - //int temp_value = (255*value)/100; - int temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Saturation(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetPQMode_Saturation ( int source_type, int pq_mode, int saturation ) { + return mVpp.FactorySetPQMode_Saturation(source_type, pq_mode, saturation); } -int CTv::Tv_FactoryGet_FBC_Saturation ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Saturation(COMM_DEV_SERIAL, &temp_value); - //data = (temp_value*100)/255; - data = temp_value; - - return data; - } - - return 0; +int CTv::Tv_FactoryGetPQMode_Saturation ( int source_type, int pq_mode ) { + return mVpp.FactoryGetPQMode_Saturation(source_type, pq_mode); } -int CTv::Tv_FactorySet_FBC_HueColorTint ( int value ) -{ - //int temp_value = (255*value)/100; - int temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_HueColorTint(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetPQMode_Hue ( int source_type, int pq_mode, int hue ) { + return mVpp.FactorySetPQMode_Hue(source_type, pq_mode, hue); } -int CTv::Tv_FactoryGet_FBC_HueColorTint ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_HueColorTint(COMM_DEV_SERIAL, &temp_value); - //data = (temp_value*100)/255; - data = temp_value; - - return data; - } - - return 0; +int CTv::Tv_FactoryGetPQMode_Hue ( int source_type, int pq_mode ) { + return mVpp.FactoryGetPQMode_Hue(source_type, pq_mode); } -int CTv::Tv_FactorySet_FBC_Backlight ( int value ) -{ - int temp_value = value; - if (fbcIns != NULL) { - temp_value = temp_value * 255 / 100; - fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetPQMode_Sharpness ( int source_type, int pq_mode, int sharpness ) { + return mVpp.FactorySetPQMode_Sharpness(source_type, pq_mode, sharpness); } -int CTv::Tv_FactoryGet_FBC_Backlight ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Backlight(COMM_DEV_SERIAL, &temp_value); - if (temp_value * 100 % 255 == 0) - temp_value = temp_value * 100 / 255; - else - temp_value = temp_value * 100 / 255 + 1; - data = temp_value; - - return data; - } - - return 0; +int CTv::Tv_FactoryGetPQMode_Sharpness ( int source_type, int pq_mode ) { + return mVpp.FactoryGetPQMode_Sharpness(source_type, pq_mode); } -int CTv::Tv_FactorySet_FBC_Auto_Backlight_OnOff( unsigned char status) -{ - if (fbcIns != NULL) { - return fbcIns->cfbc_Set_Auto_Backlight_OnOff(COMM_DEV_SERIAL, status); - } - - return -1; +int CTv::GetColorTemperatureParams ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) { + if (mHdmiOutFbc) { + int ret = Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)Tempmode, params); + params->r_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->r_gain); + params->g_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->g_gain); + params->b_gain = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(params->b_gain); + params->r_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->r_post_offset); + params->g_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->g_post_offset); + params->b_post_offset = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(params->b_post_offset); + return ret; + } else { + return mVpp.GetColorTemperatureParams(Tempmode, params); + } } -int CTv::Tv_FactoryGet_FBC_Auto_Backlight_OnOff( void ) -{ - int temp_status = 0; +int CTv::Tv_FactorySetTestPattern ( int pattern ) { + switch ( pattern ) { + case VPP_TEST_PATTERN_NONE: + mAv.SetVideoScreenColor ( 3, 16, 128, 128 ); + break; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Auto_Backlight_OnOff(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } - return 0; + case VPP_TEST_PATTERN_RED: + mAv.SetVideoScreenColor ( 0, 81, 90, 240 ); + break; -} + case VPP_TEST_PATTERN_GREEN: + mAv.SetVideoScreenColor ( 0, 145, 54, 34 ); + break; + case VPP_TEST_PATTERN_BLUE: + mAv.SetVideoScreenColor ( 0, 41, 240, 110 ); + break; -int CTv::Tv_FactorySet_FBC_ELEC_MODE( int value ) -{ - int val = 0; + case VPP_TEST_PATTERN_WHITE: + mAv.SetVideoScreenColor ( 0, 235, 128, 128 ); + break; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value); - val = value; - SSMSaveFBCELECmodeVal(val); - return 0; - } + case VPP_TEST_PATTERN_BLACK: + mAv.SetVideoScreenColor ( 0, 16, 128, 128 ); + break; - return -1; + default: + return -1; + } + return SSMSaveTestPattern ( pattern ); } -int CTv::Tv_FactoryGet_FBC_ELEC_MODE( void ) -{ - int val = 0; - - SSMReadFBCELECmodeVal(&val); - - return val; +int CTv::Tv_FactoryGetTestPattern ( void ) { + return mVpp.FactoryGetTestPattern(); } -int CTv::Tv_FactorySet_FBC_BACKLIGHT_N360( int value ) -{ - int val = 0; - - val = value; - SSMSaveFBCELECmodeVal(val); - - return -1; +int CTv::Tv_FactorySetScreenColor ( int vdin_blending_mask, int y, int u, int v ) { + return mAv.SetVideoScreenColor ( vdin_blending_mask, y, u, v ); } -int CTv::Tv_FactoryGet_FBC_BACKLIGHT_N360( void ) -{ - int val = 0; - - SSMReadFBCELECmodeVal(&val); - - return val; +int CTv::Tv_FactoryResetPQMode ( void ) { + return mVpp.FactoryResetPQMode(); } -int CTv::Tv_FactorySet_FBC_Thermal_State( int value ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Thermal_state(COMM_DEV_SERIAL, value); - return 0; - } - - return -1; +int CTv::Tv_FactoryResetColorTemp ( void ) { + return mVpp.FactoryResetColorTemp(); } -int CTv::Tv_FactorySet_FBC_Picture_Mode ( int mode ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Picture_Mode(COMM_DEV_SERIAL, mode); - return 0; - } - - return -1; +int CTv::Tv_FactorySetParamsDefault ( void ) { + return mVpp.FactorySetParamsDefault(); } -int CTv::Tv_FactoryGet_FBC_Picture_Mode ( void ) -{ - int mode = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Picture_Mode(COMM_DEV_SERIAL, &mode); - return mode; - } - - return 0; +int CTv::Tv_FactorySetDDRSSC ( int step ) { + return mVpp.FactorySetDDRSSC(step); } -int CTv::Tv_FactorySet_FBC_Set_Test_Pattern ( int mode ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Test_Pattern(COMM_DEV_SERIAL, mode); - return 0; - } - - return -1; +int CTv::Tv_FactoryGetDDRSSC ( void ) { + return mVpp.FactoryGetDDRSSC(); } -int CTv::Tv_FactoryGet_FBC_Get_Test_Pattern ( void ) -{ - int mode = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Test_Pattern(COMM_DEV_SERIAL, &mode); - return mode; - } - - return 0; +int CTv::Tv_FactorySetLVDSSSC ( int step ) { + return mVpp.FactorySetLVDSSSC(step); } - -int CTv::Tv_FactorySet_FBC_Gain_Red( int value ) -{ - int temp_value = 0; - - //temp_value = (value*255)/2047; - //value 0 ~ 2047 - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Gain_Red(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactoryGetLVDSSSC ( void ) { + return mVpp.FactoryGetLVDSSSC(); } -int CTv::Tv_FactoryGet_FBC_Gain_Red ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Gain_Red(COMM_DEV_SERIAL, &temp_value); - //value 0 ~ 2047 - //value = (temp_value*2047)/255; - value = temp_value; - - return value; - } - - return 0; +void CTv::Tv_Spread_Spectrum() { + int value= 0; + value = mVpp.FactoryGetLVDSSSC(); + mVpp.FactorySetLVDSSSC(value); } -int CTv::Tv_FactorySet_FBC_Gain_Green( int value ) -{ - int temp_value = 0; - - //temp_value = (value*255)/2047; - //value 0 ~ 2047 - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Gain_Green(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactorySetNolineParams ( int noline_params_type, int source_type, noline_params_t noline_params ) { + return mVpp.FactorySetNolineParams(noline_params_type, source_type, noline_params); } -int CTv::Tv_FactoryGet_FBC_Gain_Green ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Gain_Green(COMM_DEV_SERIAL, &temp_value); - //value 0 ~ 2047 - //value = (temp_value*2047)/255; - value = temp_value; - - return value; - } - - return 0; +noline_params_t CTv::Tv_FactoryGetNolineParams ( int noline_params_type, int source_type ) { + return mVpp.FactoryGetNolineParams(noline_params_type, source_type); } -int CTv::Tv_FactoryGet_FBC_VIDEO_MUTE ( void ) -{ - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_VMute(COMM_DEV_SERIAL, 1); - } - - return 0; +int CTv::Tv_FactorySetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt, tvin_cutwin_t cutwin_t ) { + //tvin_cutwin_t cutwin_t = mVpp.Tv_FactoryGetOverscan(source_type, fmt, status_3d, trans_fmt); + mVpp.FactorySetOverscan(source_type, fmt, status_3d, trans_fmt, cutwin_t); + //} else { +#if 0 + char val_buf[256]; + memset(val_buf, '\0', 256); + LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he); + sprintf(val_buf, "%d,%d,%d,%d", ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); + config_set_str(CFG_SECTION_TV, "vpp.overscan.dtv", val_buf); + //} +#endif + return mVpp.VPP_SetVideoCrop ( ( int ) cutwin_t.vs, ( int ) cutwin_t.hs, ( int ) cutwin_t.ve, ( int ) cutwin_t.he ); } -int CTv::Tv_FactorySet_FBC_Gain_Blue( int value ) -{ - int temp_value = 0; - - //temp_value = (value*255)/2047; - //value 0 ~ 2047 - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Gain_Blue(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +tvin_cutwin_t CTv::Tv_FactoryGetOverscan ( int source_type, int fmt, int status_3d, int trans_fmt ) { + status_3d = status_3d; + return mVpp.FactoryGetOverscan(source_type, fmt, Check2Dor3D(m_mode_3d, (tvin_trans_fmt_t)trans_fmt), trans_fmt); +#if 0 + else { + tvin_cutwin_t cutwin; + int ret = 0; + char tmp_buf[16]; + tmp_buf[0] = 0; + + if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 0, tmp_buf)) == 0) { + cutwin.vs = strtol(tmp_buf, NULL, 10); + } + if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 1, tmp_buf)) == 0) { + cutwin.hs = strtol(tmp_buf, NULL, 10); + } + if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 2, tmp_buf)) == 0) { + cutwin.ve = strtol(tmp_buf, NULL, 10); + } + if ((ret |= cfg_get_one_item("vpp.overscan.dtv", ",", 3, tmp_buf)) == 0) { + cutwin.he = strtol(tmp_buf, NULL, 10); + } + LOGD("%s,%d: %d,%d,%d,%d", __FUNCTION__, __LINE__, ( int ) cutwin.vs, ( int ) cutwin.hs, ( int ) cutwin.ve, ( int ) cutwin.he); + return cutwin; + } +#endif } -int CTv::Tv_FactoryGet_FBC_Gain_Blue ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Gain_Blue(COMM_DEV_SERIAL, &temp_value); - //value 0 ~ 2047 - //value = (temp_value*2047)/255; - value = temp_value; - - return value; - } - - return 0; +int CTv::Tv_ReplacePqDb(const char *newFilePath) { + return mVpp.getPqData()->replacePqDb(newFilePath); +} + +int CTv::Tv_FactorySet_FBC_Brightness ( int value ) { + //int temp_value = (255*value)/100; + int temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Brightness(COMM_DEV_SERIAL, temp_value); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Brightness ( void ) { + int temp_value = 0; + int data = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Brightness(COMM_DEV_SERIAL, &temp_value); + //data = (temp_value*100)/255; + data = temp_value; + + return data; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_Contrast ( int value ) { + //int temp_value = (255*value)/100; + int temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Contrast(COMM_DEV_SERIAL, temp_value); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Contrast ( void ) { + int temp_value = 0; + int data = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Contrast(COMM_DEV_SERIAL, &temp_value); + //data = (temp_value*100)/255; + data = temp_value; + return data; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_Saturation ( int value ) { + //int temp_value = (255*value)/100; + int temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Saturation(COMM_DEV_SERIAL, temp_value); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Saturation ( void ) { + int temp_value = 0; + int data = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Saturation(COMM_DEV_SERIAL, &temp_value); + //data = (temp_value*100)/255; + data = temp_value; + return data; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_HueColorTint ( int value ) { + //int temp_value = (255*value)/100; + int temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_HueColorTint(COMM_DEV_SERIAL, temp_value); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_HueColorTint ( void ) { + int temp_value = 0; + int data = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_HueColorTint(COMM_DEV_SERIAL, &temp_value); + //data = (temp_value*100)/255; + data = temp_value; + return data; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_Backlight ( int value ) { + int temp_value = value; + if (fbcIns != NULL) { + temp_value = temp_value * 255 / 100; + fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, temp_value); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Backlight ( void ) { + int temp_value = 0; + int data = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Backlight(COMM_DEV_SERIAL, &temp_value); + if (temp_value * 100 % 255 == 0) + temp_value = temp_value * 100 / 255; + else + temp_value = temp_value * 100 / 255 + 1; + data = temp_value; + return data; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Auto_Backlight_OnOff( unsigned char status) { + if (fbcIns != NULL) { + return fbcIns->cfbc_Set_Auto_Backlight_OnOff(COMM_DEV_SERIAL, status); + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Auto_Backlight_OnOff( void ) { + int temp_status = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Auto_Backlight_OnOff(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_ELEC_MODE( int value ) { + int val = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_AUTO_ELEC_MODE(COMM_DEV_SERIAL, value); + val = value; + SSMSaveFBCELECmodeVal(val); + return 0; + } + return -1; +} + +int CTv::Tv_FactoryGet_FBC_ELEC_MODE( void ) { + int val = 0; + SSMReadFBCELECmodeVal(&val); + return val; +} + +int CTv::Tv_FactorySet_FBC_BACKLIGHT_N360( int value ) { + int val = 0; + + val = value; + SSMSaveFBCELECmodeVal(val); + return -1; +} + +int CTv::Tv_FactoryGet_FBC_BACKLIGHT_N360( void ) { + int val = 0; + SSMReadFBCELECmodeVal(&val); + return val; +} + +int CTv::Tv_FactorySet_FBC_Thermal_State( int value ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Thermal_state(COMM_DEV_SERIAL, value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactorySet_FBC_Picture_Mode ( int mode ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Picture_Mode(COMM_DEV_SERIAL, mode); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Picture_Mode ( void ) { + int mode = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Picture_Mode(COMM_DEV_SERIAL, &mode); + return mode; + } + return 0; +} + +int CTv::Tv_FactorySet_FBC_Set_Test_Pattern ( int mode ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Test_Pattern(COMM_DEV_SERIAL, mode); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Get_Test_Pattern ( void ) { + int mode = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Test_Pattern(COMM_DEV_SERIAL, &mode); + return mode; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Gain_Red( int value ) { + int temp_value = 0; + + //temp_value = (value*255)/2047; + //value 0 ~ 2047 + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Gain_Red(COMM_DEV_SERIAL, temp_value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Gain_Red ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Gain_Red(COMM_DEV_SERIAL, &temp_value); + //value 0 ~ 2047 + //value = (temp_value*2047)/255; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Gain_Green( int value ) { + int temp_value = 0; + + //temp_value = (value*255)/2047; + //value 0 ~ 2047 + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Gain_Green(COMM_DEV_SERIAL, temp_value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Gain_Green ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Gain_Green(COMM_DEV_SERIAL, &temp_value); + //value 0 ~ 2047 + //value = (temp_value*2047)/255; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactoryGet_FBC_VIDEO_MUTE ( void ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_VMute(COMM_DEV_SERIAL, 1); + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Gain_Blue( int value ) { + int temp_value = 0; + + //temp_value = (value*255)/2047; + //value 0 ~ 2047 + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Gain_Blue(COMM_DEV_SERIAL, temp_value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Gain_Blue ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Gain_Blue(COMM_DEV_SERIAL, &temp_value); + //value 0 ~ 2047 + //value = (temp_value*2047)/255; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Offset_Red( int value ) { + //value -1024~+1023 + int temp_value = 0; + + //temp_value = (value+1024)*255/2047; + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Offset_Red(COMM_DEV_SERIAL, temp_value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Offset_Red ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Offset_Red(COMM_DEV_SERIAL, &temp_value); + //value -1024~+1023 + //value = (temp_value*2047)/255 - 1024; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Offset_Green( int value ) { + //value -1024~+1023 + int temp_value = 0; + + //temp_value = (value+1024)*255/2047; + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Offset_Green(COMM_DEV_SERIAL, temp_value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Offset_Green ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Offset_Green(COMM_DEV_SERIAL, &temp_value); + //value -1024~+1023 + //value = (temp_value*2047)/255 - 1024; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactorySet_FBC_Offset_Blue( int value ) { + //value -1024~+1023 + int temp_value = 0; + + //temp_value = (value+1024)*255/2047; + temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Offset_Blue(COMM_DEV_SERIAL, value); + return 0; + } + + return -1; +} + +int CTv::Tv_FactoryGet_FBC_Offset_Blue ( void ) { + int temp_value = 0, value = 0; + + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Offset_Blue(COMM_DEV_SERIAL, &temp_value); + //value -1024~+1023 + //value = (temp_value*2047)/255 - 1024; + value = temp_value; + + return value; + } + + return 0; +} + +int CTv::Tv_FactoryGetWhiteBalanceRedGain(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + LOGD("--------- call none fbc method ---------"); + ret = mVpp.FactoryGetColorTemp_Rgain(source_type, colortemp_mode); + } else { //use fbc store the white balance params + LOGD("--------- call fbc method ---------"); + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 0); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceGreenGain(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactoryGetColorTemp_Ggain(source_type, colortemp_mode); + } else { //use fbc store the white balance params + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 1); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceBlueGain(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactoryGetColorTemp_Bgain(source_type, colortemp_mode); + } else { //use fbc store the white balance params + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 2); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceRedOffset(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactoryGetColorTemp_Roffset(source_type, colortemp_mode); + } else { //use fbc store the white balance params + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 3); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceGreenOffset(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactoryGetColorTemp_Goffset(source_type, colortemp_mode); + } else { //use fbc store the white balance params + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 4); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceBlueOffset(int source_type, int colortemp_mode) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactoryGetColorTemp_Boffset(source_type, colortemp_mode); + } else { //use fbc store the white balance params + ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 5); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceRedGain(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < 0) { + value = 0; + } else if (value > 2047) { + value = 2047; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Rgain(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the red gain to flash") + ret = mVpp.FactorySaveColorTemp_Rgain(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); + ret = Tv_FactorySet_FBC_Gain_Red(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceGreenGain(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < 0) { + value = 0; + } else if (value > 2047) { + value = 2047; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Ggain(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the green gain to flash") + ret = mVpp.FactorySaveColorTemp_Ggain(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); + ret = Tv_FactorySet_FBC_Gain_Green(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceBlueGain(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < 0) { + value = 0; + } else if (value > 2047) { + value = 2047; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Bgain(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the blue gain to flash") + ret = mVpp.FactorySaveColorTemp_Bgain(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); + ret = Tv_FactorySet_FBC_Gain_Blue(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceRedOffset(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < -1024) { + value = -1024; + } else if (value > 1023) { + value = 1023; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Roffset(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the red offset to flash") + ret = mVpp.FactorySaveColorTemp_Roffset(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); + ret = Tv_FactorySet_FBC_Offset_Red(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceGreenOffset(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < -1024) { + value = -1024; + } else if (value > 1023) { + value = 1023; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Goffset(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the green offset to flash") + ret = mVpp.FactorySaveColorTemp_Goffset(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); + ret = Tv_FactorySet_FBC_Offset_Green(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceBlueOffset(int source_type, int colortemp_mode, int value) { + int ret = -1; + if (value < -1024) { + value = -1024; + } else if (value > 1023) { + value = 1023; + } + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.FactorySetColorTemp_Boffset(source_type, colortemp_mode, value); + if (ret != -1) { + LOGD("save the blue offset to flash") + ret = mVpp.FactorySaveColorTemp_Boffset(source_type, colortemp_mode, value); + } + } else { //use fbc store the white balance params + value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); + ret = Tv_FactorySet_FBC_Offset_Blue(value); + } + return ret; +} + +int CTv::Tv_FactorySetWhiteBalanceColorTempMode(int source_type, int colortemp_mode, int is_save) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.SetColorTemperature((vpp_color_temperature_mode_t)colortemp_mode, (tv_source_input_type_t)source_type, is_save); + } else { //use fbc store the white balance params + ret = Tv_FactorySet_FBC_ColorTemp_Mode(colortemp_mode); + } + return ret; +} + +int CTv::Tv_FactoryGetWhiteBalanceColorTempMode(int source_type ) { + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.GetColorTemperature((tv_source_input_type_t)source_type); + } else { //use fbc store the white balance params + ret = Tv_FactoryGet_FBC_ColorTemp_Mode(); + } + return ret; +} + +int CTv::Tv_FactoryWhiteBalanceFormatInputFbcGainParams(int value) { + int ret = 1024; + if (value < 0) { + ret = 0; + } else if (value > 2047) { + ret = 2047; + } else { + ret = value; + } + ret = ret >> 3; + return ret; +} + +int CTv::Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(int value) { + int ret = 0; + if (value < -1024) { + ret = -1024; + } else if (value > 1023) { + ret = 1023; + } else { + ret = value; + } + ret += 1024; + ret = ret >> 3; + return ret; +} + +int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(int value) { + if (value == 255) { + value = 1023; + } else { + value = value << 3; + value -= 1024; + } + return value; +} + +int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(int value) { + value = value << 3; + if (value < 0) { + value = 0; + } else if (value > 2047) { + value = 2047; + } + return value; +} + +int CTv::Tv_FactorySaveWhiteBalancePramas(int source_type, int tempmode, int r_gain, int g_gain, int b_gain, int r_offset, int g_offset, int b_offset) { + int ret = 0; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + mVpp.SaveColorTemp((vpp_color_temperature_mode_t) tempmode, (tv_source_input_type_t) source_type); + mVpp.FactorySaveColorTemp_Rgain(source_type, tempmode, r_gain); + mVpp.FactorySaveColorTemp_Ggain(source_type, tempmode, g_gain); + mVpp.FactorySaveColorTemp_Bgain(source_type, tempmode, b_gain); + mVpp.FactorySaveColorTemp_Roffset(source_type, tempmode, r_offset); + mVpp.FactorySaveColorTemp_Goffset(source_type, tempmode, g_offset); + mVpp.FactorySaveColorTemp_Boffset(source_type, tempmode, b_offset); + } else { //use fbc store the white balance params + tcon_rgb_ogo_t params; + + params.r_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(r_gain); + params.g_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(g_gain); + params.b_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(b_gain); + params.r_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(r_offset); + params.g_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(g_offset); + params.b_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(b_offset); + ret = Tv_FactorySet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)tempmode, params); + } + return ret; } -int CTv::Tv_FactorySet_FBC_Offset_Red( int value ) -{ - //value -1024~+1023 - int temp_value = 0; - - //temp_value = (value+1024)*255/2047; - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Offset_Red(COMM_DEV_SERIAL, temp_value); - return 0; - } - - return -1; +/** +* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping +**/ +int CTv::Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(int Tempmode) { + int ret = Tempmode; + switch (Tempmode) { + case 0: //standard + ret = 1; + break; + case 1: //warm + ret = 2; + break; + case 2: //cold + ret = 0; + break; + default: + break; + } + return ret; } -int CTv::Tv_FactoryGet_FBC_Offset_Red ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Offset_Red(COMM_DEV_SERIAL, &temp_value); - //value -1024~+1023 - //value = (temp_value*2047)/255 - 1024; - value = temp_value; - - return value; - } - - return 0; +/** +* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping +**/ +int CTv::Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(int Tempmode) { + int ret = Tempmode; + switch (Tempmode) { + case 0: //cold + ret = 2; + break; + case 1: //standard + ret = 0; + break; + case 2: //warm + ret = 1; + break; + default: + break; + } + return ret; } -int CTv::Tv_FactorySet_FBC_Offset_Green( int value ) -{ - //value -1024~+1023 - int temp_value = 0; - - //temp_value = (value+1024)*255/2047; - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Offset_Green(COMM_DEV_SERIAL, temp_value); - return 0; - } +int CTv::Tv_SetTestPattern(int value) { + int ret = -1; + if (fbcIns != NULL) { + LOGD("%s, value is %d\n", __FUNCTION__, value); + ret = fbcIns->cfbc_TestPattern_Select(COMM_DEV_SERIAL, value); + } - return -1; + return ret; } -int CTv::Tv_FactoryGet_FBC_Offset_Green ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Offset_Green(COMM_DEV_SERIAL, &temp_value); - //value -1024~+1023 - //value = (temp_value*2047)/255 - 1024; - value = temp_value; - - return value; - } - - return 0; +int CTv::Tv_FactoryCloseWhiteBalanceGrayPattern() { + int useFbc = 0; + int ret = -1; + if (!mHdmiOutFbc) { // not use fbc store the white balance params + ret = mVpp.VPP_SetGrayPattern(0); + } else { //use fbc store the white balance params + ret = Tv_FactoryClose_FBC_GrayPattern(); + } + return ret; } -int CTv::Tv_FactorySet_FBC_Offset_Blue( int value ) -{ - //value -1024~+1023 - int temp_value = 0; - - //temp_value = (value+1024)*255/2047; - temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Offset_Blue(COMM_DEV_SERIAL, value); - return 0; - } - - return -1; +int CTv::Tv_FactoryOpenWhiteBalanceGrayPattern() { + int ret = 0; + if (mHdmiOutFbc) { //use fbc store the white balance params + ret = Tv_FactoryOpen_FBC_GrayPattern(); + } + return ret; } -int CTv::Tv_FactoryGet_FBC_Offset_Blue ( void ) -{ - int temp_value = 0, value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Offset_Blue(COMM_DEV_SERIAL, &temp_value); - //value -1024~+1023 - //value = (temp_value*2047)/255 - 1024; - value = temp_value; - - return value; - } - - return 0; +int CTv::Tv_FactorySetWhiteBalanceGrayPattern(int value) { + int ret = -1; + if (!mHdmiOutFbc) { + ret = mVpp.VPP_SetGrayPattern(value); + } else { + ret = Tv_FactorySet_FBC_GrayPattern(value); + } + return ret; } -int CTv::Tv_FactoryGetWhiteBalanceRedGain(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - LOGD("--------- call none fbc method ---------"); - ret = mVpp.FactoryGetColorTemp_Rgain(source_type, colortemp_mode); - } else { //use fbc store the white balance params - LOGD("--------- call fbc method ---------"); - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 0); - } - return ret; +int CTv:: Tv_FactoryGetWhiteBalanceGrayPattern() { + int ret = -1; + if (!mHdmiOutFbc) { + ret = mVpp.VPP_GetGrayPattern(); + } + return ret; } -int CTv::Tv_FactoryGetWhiteBalanceGreenGain(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactoryGetColorTemp_Ggain(source_type, colortemp_mode); - } else { //use fbc store the white balance params - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 1); - } - return ret; +int CTv::Tv_FactorySet_FBC_GrayPattern(int value) { + int ret = -1; + unsigned char grayValue = 0; + if (value > 255) { + grayValue = 255; + } else if (value < 0) { + grayValue = 0; + } else { + grayValue = (unsigned char)(0xFF & value); + } + if (fbcIns != NULL) { + ret = fbcIns->cfbc_WhiteBalance_SetGrayPattern(COMM_DEV_SERIAL, grayValue); + } + return ret; } -int CTv::Tv_FactoryGetWhiteBalanceBlueGain(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactoryGetColorTemp_Bgain(source_type, colortemp_mode); - } else { //use fbc store the white balance params - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 2); - } - return ret; +int CTv::Tv_FactoryOpen_FBC_GrayPattern() { + int ret = -1; + if (fbcIns != NULL) { + ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 0); + } + return ret; } -int CTv::Tv_FactoryGetWhiteBalanceRedOffset(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactoryGetColorTemp_Roffset(source_type, colortemp_mode); - } else { //use fbc store the white balance params - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 3); - } - return ret; +int CTv::Tv_FactoryClose_FBC_GrayPattern() { + int ret = -1; + if (fbcIns != NULL) { + ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 1); + } + return ret; } -int CTv::Tv_FactoryGetWhiteBalanceGreenOffset(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactoryGetColorTemp_Goffset(source_type, colortemp_mode); - } else { //use fbc store the white balance params - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 4); - } - return ret; -} +int CTv::Tv_FactorySet_FBC_ColorTemp_Mode( int mode ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); + return 0; + } -int CTv::Tv_FactoryGetWhiteBalanceBlueOffset(int source_type, int colortemp_mode) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactoryGetColorTemp_Boffset(source_type, colortemp_mode); - } else { //use fbc store the white balance params - ret = Tv_FactoryGetItemFromBatch((vpp_color_temperature_mode_t)colortemp_mode, 5); - } - return ret; + return -1; } -int CTv::Tv_FactorySetWhiteBalanceRedGain(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < 0) { - value = 0; - } else if (value > 2047) { - value = 2047; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Rgain(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the red gain to flash") - ret = mVpp.FactorySaveColorTemp_Rgain(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); - ret = Tv_FactorySet_FBC_Gain_Red(value); - } - return ret; -} +int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode ( void ) { + int temp_mode = 0; -int CTv::Tv_FactorySetWhiteBalanceGreenGain(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < 0) { - value = 0; - } else if (value > 2047) { - value = 2047; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Ggain(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the green gain to flash") - ret = mVpp.FactorySaveColorTemp_Ggain(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); - ret = Tv_FactorySet_FBC_Gain_Green(value); - } - return ret; -} + if (fbcIns != NULL) { + fbcIns->cfbc_Get_ColorTemp_Mode(COMM_DEV_SERIAL, &temp_mode); + return temp_mode; + } -int CTv::Tv_FactorySetWhiteBalanceBlueGain(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < 0) { - value = 0; - } else if (value > 2047) { - value = 2047; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Bgain(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the blue gain to flash") - ret = mVpp.FactorySaveColorTemp_Bgain(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(value); - ret = Tv_FactorySet_FBC_Gain_Blue(value); - } - return ret; + return -1; } -int CTv::Tv_FactorySetWhiteBalanceRedOffset(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < -1024) { - value = -1024; - } else if (value > 1023) { - value = 1023; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Roffset(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the red offset to flash") - ret = mVpp.FactorySaveColorTemp_Roffset(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); - ret = Tv_FactorySet_FBC_Offset_Red(value); - } - return ret; -} +int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N360( int mode ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); + SSMSaveFBCN360ColorTempVal(mode); + return 0; + } -int CTv::Tv_FactorySetWhiteBalanceGreenOffset(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < -1024) { - value = -1024; - } else if (value > 1023) { - value = 1023; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Goffset(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the green offset to flash") - ret = mVpp.FactorySaveColorTemp_Goffset(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); - ret = Tv_FactorySet_FBC_Offset_Green(value); - } - return ret; + return -1; } -int CTv::Tv_FactorySetWhiteBalanceBlueOffset(int source_type, int colortemp_mode, int value) -{ - int ret = -1; - if (value < -1024) { - value = -1024; - } else if (value > 1023) { - value = 1023; - } - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.FactorySetColorTemp_Boffset(source_type, colortemp_mode, value); - if (ret != -1) { - LOGD("save the blue offset to flash") - ret = mVpp.FactorySaveColorTemp_Boffset(source_type, colortemp_mode, value); - } - } else { //use fbc store the white balance params - value = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(value); - ret = Tv_FactorySet_FBC_Offset_Blue(value); - } - return ret; +int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N360 ( void ) { + int temp_mode = 0; + SSMReadFBCN360ColorTempVal(&temp_mode); + return temp_mode; } - -int CTv::Tv_FactorySetWhiteBalanceColorTempMode(int source_type, int colortemp_mode, int is_save) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.SetColorTemperature((vpp_color_temperature_mode_t)colortemp_mode, (tv_source_input_type_t)source_type, is_save); - } else { //use fbc store the white balance params - ret = Tv_FactorySet_FBC_ColorTemp_Mode(colortemp_mode); - } - return ret; +int CTv::Tv_FactorySet_FBC_LockN_state(int value) { + LOGE ("Tv_FactorySet_FBC_LockN_state %d!!!\n", value); + if (fbcIns != NULL) { + fbcIns->cfbc_Set_LockN_state(COMM_DEV_SERIAL, value); + return 0; + } + return -1; } -int CTv::Tv_FactoryGetWhiteBalanceColorTempMode(int source_type ) -{ - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.GetColorTemperature((tv_source_input_type_t)source_type); - } else { //use fbc store the white balance params - ret = Tv_FactoryGet_FBC_ColorTemp_Mode(); - } - return ret; -} +int CTv::Tv_FactorySet_FBC_WB_Initial( int status ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_WB_Initial(COMM_DEV_SERIAL, status); + return 0; + } -int CTv::Tv_FactoryWhiteBalanceFormatInputFbcGainParams(int value) -{ - int ret = 1024; - if (value < 0) { - ret = 0; - } else if (value > 2047) { - ret = 2047; - } else { - ret = value; - } - ret = ret >> 3; - return ret; + return -1; } -int CTv::Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(int value) -{ - int ret = 0; - if (value < -1024) { - ret = -1024; - } else if (value > 1023) { - ret = 1023; - } else { - ret = value; - } - ret += 1024; - ret = ret >> 3; - return ret; -} +int CTv::Tv_FactoryGet_FBC_WB_Initial ( void ) { + int temp_status = 0; -int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(int value) -{ - if (value == 255) { - value = 1023; - } else { - value = value << 3; - value -= 1024; - } - return value; -} + if (fbcIns != NULL) { + fbcIns->cfbc_Get_WB_Initial(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } -int CTv::Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(int value) -{ - value = value << 3; - if (value < 0) { - value = 0; - } else if (value > 2047) { - value = 2047; - } - return value; + return 0; } +int CTv::Tv_FactorySet_FBC_ColorTemp_Batch(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) { + unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; + switch (Tempmode) { + case VPP_COLOR_TEMPERATURE_MODE_STANDARD: + mode = 1; //COLOR_TEMP_STD + break; + case VPP_COLOR_TEMPERATURE_MODE_WARM: + mode = 2; //COLOR_TEMP_WARM + break; + case VPP_COLOR_TEMPERATURE_MODE_COLD: + mode = 0; //COLOR_TEMP_COLD + break; + case VPP_COLOR_TEMPERATURE_MODE_USER: + mode = 3; //COLOR_TEMP_USER + break; + default: + break; + } + r_gain = (params.r_gain * 255) / 2047; // u1.10, range 0~2047, default is 1024 (1.0x) + g_gain = (params.g_gain * 255) / 2047; + b_gain = (params.b_gain * 255) / 2047; + r_offset = (params.r_post_offset + 1024) * 255 / 2047; // s11.0, range -1024~+1023, default is 0 + g_offset = (params.g_post_offset + 1024) * 255 / 2047; + b_offset = (params.b_post_offset + 1024) * 255 / 2047; + LOGD ( "~Tv_FactorySet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); -int CTv::Tv_FactorySaveWhiteBalancePramas(int source_type, int tempmode, int r_gain, int g_gain, int b_gain, int r_offset, int g_offset, int b_offset) -{ - int ret = 0; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - mVpp.SaveColorTemp((vpp_color_temperature_mode_t) tempmode, (tv_source_input_type_t) source_type); - mVpp.FactorySaveColorTemp_Rgain(source_type, tempmode, r_gain); - mVpp.FactorySaveColorTemp_Ggain(source_type, tempmode, g_gain); - mVpp.FactorySaveColorTemp_Bgain(source_type, tempmode, b_gain); - mVpp.FactorySaveColorTemp_Roffset(source_type, tempmode, r_offset); - mVpp.FactorySaveColorTemp_Goffset(source_type, tempmode, g_offset); - mVpp.FactorySaveColorTemp_Boffset(source_type, tempmode, b_offset); - } else { //use fbc store the white balance params - tcon_rgb_ogo_t params; + if (fbcIns != NULL) { + fbcIns->cfbc_Set_WB_Batch(COMM_DEV_SERIAL, mode, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset); + return 0; + } - params.r_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(r_gain); - params.g_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(g_gain); - params.b_gain = Tv_FactoryWhiteBalanceFormatInputFbcGainParams(b_gain); - params.r_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(r_offset); - params.g_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(g_offset); - params.b_post_offset = Tv_FactoryWhiteBalanceFormatInputFbcOffsetParams(b_offset); - ret = Tv_FactorySet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)tempmode, params); - } - return ret; + return -1; } +int CTv::Tv_FactoryGet_FBC_ColorTemp_Batch ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) { + unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; + switch (Tempmode) { + case VPP_COLOR_TEMPERATURE_MODE_STANDARD: + mode = 1; //COLOR_TEMP_STD + break; + case VPP_COLOR_TEMPERATURE_MODE_WARM: + mode = 2; //COLOR_TEMP_WARM + break; + case VPP_COLOR_TEMPERATURE_MODE_COLD: + mode = 0; //COLOR_TEMP_COLD + break; + case VPP_COLOR_TEMPERATURE_MODE_USER: + mode = 3; //COLOR_TEMP_USER + break; + default: + break; + } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_WB_Batch(COMM_DEV_SERIAL, mode, &r_gain, &g_gain, &b_gain, &r_offset, &g_offset, &b_offset); + LOGD ( "~Tv_FactoryGet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); + params->r_gain = (r_gain * 2047) / 255; + params->g_gain = (g_gain * 2047) / 255; + params->b_gain = (b_gain * 2047) / 255; + params->r_post_offset = (r_offset * 2047) / 255 - 1024; + params->g_post_offset = (g_offset * 2047) / 255 - 1024; + params->b_post_offset = (b_offset * 2047) / 255 - 1024; + return 0; + } - -/** -* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping -**/ -int CTv::Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(int Tempmode) -{ - int ret = Tempmode; - switch (Tempmode) { - case 0: //standard - ret = 1; - break; - case 1: //warm - ret = 2; - break; - case 2: //cold - ret = 0; - break; - default: - break; - } - return ret; -} - -/** -* The color temperature enum order is diffrent bettewn G9 and Fbc, so we have to make a mapping -**/ -int CTv::Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(int Tempmode) -{ - int ret = Tempmode; - switch (Tempmode) { - case 0: //cold - ret = 2; - break; - case 1: //standard - ret = 0; - break; - case 2: //warm - ret = 1; - break; - default: - break; - } - return ret; + return -1; } -int CTv::Tv_SetTestPattern(int value) -{ - int ret = -1; - if (fbcIns != NULL) { - LOGD("%s, value is %d\n", __FUNCTION__, value); - ret = fbcIns->cfbc_TestPattern_Select(COMM_DEV_SERIAL, value); - } - - return ret; +int CTv::Tv_FactorySet_WB_G9_To_FBC( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params ) { + Tv_FactorySet_FBC_ColorTemp_Batch(Tempmode, params); + return 0; } -int CTv::Tv_FactoryCloseWhiteBalanceGrayPattern() -{ - int useFbc = 0; - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = mVpp.VPP_SetGrayPattern(0); - } else { //use fbc store the white balance params - ret = Tv_FactoryClose_FBC_GrayPattern(); - } - return ret; +int CTv::Tv_FactoryGet_WB_G9_To_FBC ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) { + int temp_status = 0; + Tv_FactoryGet_FBC_ColorTemp_Batch(Tempmode, params); + return temp_status; } -int CTv::Tv_FactoryOpenWhiteBalanceGrayPattern() -{ - int useFbc = 0; - int ret = -1; - if (!mB_hdmiout_fbc) { // not use fbc store the white balance params - ret = 0; - } else { //use fbc store the white balance params - ret = Tv_FactoryOpen_FBC_GrayPattern(); - } - return ret; -} +int CTv::Tv_FactoryGetItemFromBatch(vpp_color_temperature_mode_t colortemp_mode, int item) { + tcon_rgb_ogo_t params; + int ret = 0; -int CTv::Tv_FactorySetWhiteBalanceGrayPattern(int value) -{ - int useFbc = 0; - int ret = -1; - if (!mB_hdmiout_fbc) { - ret = mVpp.VPP_SetGrayPattern(value); - } else { - ret = Tv_FactorySet_FBC_GrayPattern(value); - } - return ret; + Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)colortemp_mode, ¶ms); + switch (item) { + case 0: + ret = params.r_gain; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + break; + case 1: + ret = params.g_gain; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + break; + case 2: + ret = params.b_gain; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); + break; + case 3: + ret = params.r_post_offset; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + break; + case 4: + ret = params.g_post_offset; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + break; + case 5: + ret = params.b_post_offset; + ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); + break; + default: + ret = 0; + } + return ret; } -int CTv:: Tv_FactoryGetWhiteBalanceGrayPattern() -{ - int useFbc = 0; - int ret = -1; - if (!mB_hdmiout_fbc) { - ret = mVpp.VPP_GetGrayPattern(); - } else { +int CTv::Tv_FactorySet_FBC_CM_OnOff( unsigned char status ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_CM(COMM_DEV_SERIAL, status); + return 0; + } - } - return ret; + return -1; } -int CTv::Tv_FactorySet_FBC_GrayPattern(int value) -{ - int ret = -1; - unsigned char grayValue = 0; - if (value > 255) { - grayValue = 255; - } else if (value < 0) { - grayValue = 0; - } else { - grayValue = (unsigned char)(0xFF & value); - } - if (fbcIns != NULL) { - ret = fbcIns->cfbc_WhiteBalance_SetGrayPattern(COMM_DEV_SERIAL, grayValue); - } - return ret; -} +int CTv::Tv_FactoryGet_FBC_CM_OnOff (void) { + int temp_status = 0; -int CTv::Tv_FactoryOpen_FBC_GrayPattern() -{ - int ret = -1; - if (fbcIns != NULL) { - ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 0); - } - return ret; -} + if (fbcIns != NULL) { + fbcIns->cfbc_Get_CM(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } -int CTv::Tv_FactoryClose_FBC_GrayPattern() -{ - int ret = -1; - if (fbcIns != NULL) { - ret = fbcIns->cfbc_WhiteBalance_GrayPattern_OnOff(COMM_DEV_SERIAL, 1); - } - return ret; + return 0; } -int CTv::Tv_FactorySet_FBC_ColorTemp_Mode( int mode ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); - return 0; - } +int CTv::Tv_FactorySet_FBC_DNLP_OnOff( unsigned char status ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_DNLP(COMM_DEV_SERIAL, status); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode ( void ) -{ - int temp_mode = 0; +int CTv::Tv_FactoryGet_FBC_DNLP_OnOff (void) { + int temp_status = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_ColorTemp_Mode(COMM_DEV_SERIAL, &temp_mode); - return temp_mode; - } - - return -1; -} -int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N360( int mode ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); - SSMSaveFBCN360ColorTempVal(mode); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_DNLP(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } - return -1; + return 0; } -int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N360 ( void ) -{ - int temp_mode = 0; +int CTv::Tv_FactorySet_FBC_Gamma_OnOff( unsigned char status ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Gamma(COMM_DEV_SERIAL, status); + return 0; + } - SSMReadFBCN360ColorTempVal(&temp_mode); - - return temp_mode; + return -1; } -int CTv::Tv_FactorySet_FBC_LockN_state(int value) -{ - int val = 0; - LOGE ( "%s, Tv_FactorySet_FBC_LockN_state %d!!!\n", "TV" , value); - if (fbcIns != NULL) { - fbcIns->cfbc_Set_LockN_state(COMM_DEV_SERIAL, value); - return 0; - }; - return -1; -} +int CTv::Tv_FactoryGet_FBC_Gamma_OnOff (void) { + int temp_status = 0; -int CTv::Tv_FactorySet_FBC_WB_Initial( int status ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_WB_Initial(COMM_DEV_SERIAL, status); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Gamma(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } - return -1; + return 0; } -int CTv::Tv_FactoryGet_FBC_WB_Initial ( void ) -{ - int temp_status = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_WB_Initial(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } +int CTv::Tv_FactorySet_FBC_WhiteBalance_OnOff( unsigned char status ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_WhiteBalance_OnOff(COMM_DEV_SERIAL, status); + return 0; + } - return 0; + return -1; } -int CTv::Tv_FactorySet_FBC_ColorTemp_Batch(vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params) -{ - unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; - switch (Tempmode) { - case VPP_COLOR_TEMPERATURE_MODE_STANDARD: - mode = 1; //COLOR_TEMP_STD - break; - case VPP_COLOR_TEMPERATURE_MODE_WARM: - mode = 2; //COLOR_TEMP_WARM - break; - case VPP_COLOR_TEMPERATURE_MODE_COLD: - mode = 0; //COLOR_TEMP_COLD - break; - case VPP_COLOR_TEMPERATURE_MODE_USER: - mode = 3; //COLOR_TEMP_USER - break; - } - r_gain = (params.r_gain * 255) / 2047; // u1.10, range 0~2047, default is 1024 (1.0x) - g_gain = (params.g_gain * 255) / 2047; - b_gain = (params.b_gain * 255) / 2047; - r_offset = (params.r_post_offset + 1024) * 255 / 2047; // s11.0, range -1024~+1023, default is 0 - g_offset = (params.g_post_offset + 1024) * 255 / 2047; - b_offset = (params.b_post_offset + 1024) * 255 / 2047; - LOGD ( "~Tv_FactorySet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); +int CTv::Tv_FactoryGet_FBC_WhiteBalance_OnOff (void) { + int temp_status = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_WB_Batch(COMM_DEV_SERIAL, mode, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_WhiteBalance_OnOff(COMM_DEV_SERIAL, &temp_status); + return temp_status; + } - return -1; + return 0; } -int CTv::Tv_FactoryGet_FBC_ColorTemp_Batch ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) -{ - unsigned char mode = 0, r_gain, g_gain, b_gain, r_offset, g_offset, b_offset; - switch (Tempmode) { - case VPP_COLOR_TEMPERATURE_MODE_STANDARD: - mode = 1; //COLOR_TEMP_STD - break; - case VPP_COLOR_TEMPERATURE_MODE_WARM: - mode = 2; //COLOR_TEMP_WARM - break; - case VPP_COLOR_TEMPERATURE_MODE_COLD: - mode = 0; //COLOR_TEMP_COLD - break; - case VPP_COLOR_TEMPERATURE_MODE_USER: - mode = 3; //COLOR_TEMP_USER - break; - } +int CTv::Tv_FactorySet_FBC_backlight_onoff ( int value ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_backlight_onoff(COMM_DEV_SERIAL, value); + return 0; + } - if (fbcIns != NULL) { - fbcIns->cfbc_Get_WB_Batch(COMM_DEV_SERIAL, mode, &r_gain, &g_gain, &b_gain, &r_offset, &g_offset, &b_offset); - LOGD ( "~Tv_FactoryGet_FBC_ColorTemp_Batch##%d,%d,%d,%d,%d,%d,##", r_gain, g_gain, b_gain, r_offset, g_offset, b_offset ); + return -1; +} - params->r_gain = (r_gain * 2047) / 255; - params->g_gain = (g_gain * 2047) / 255; - params->b_gain = (b_gain * 2047) / 255; - params->r_post_offset = (r_offset * 2047) / 255 - 1024; - params->g_post_offset = (g_offset * 2047) / 255 - 1024; - params->b_post_offset = (b_offset * 2047) / 255 - 1024; +int CTv::Tv_FactoryGet_FBC_backlight_onoff ( void ) { + int temp_value = 0; - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_backlight_onoff(COMM_DEV_SERIAL, &temp_value); + return temp_value; + } - return -1; + return 0; } -int CTv::Tv_FactorySet_WB_G9_To_FBC( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t params ) -{ - Tv_FactorySet_FBC_ColorTemp_Batch(Tempmode, params); +int CTv::Tv_FactorySet_FBC_LVDS_SSG_Set( int value ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_LVDS_SSG_Set(COMM_DEV_SERIAL, value); + return 0; + } - return 0; + return -1; } -int CTv::Tv_FactoryGet_WB_G9_To_FBC ( vpp_color_temperature_mode_t Tempmode, tcon_rgb_ogo_t *params ) -{ - int temp_status = 0; +int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value ) { + int temp_value = value; - Tv_FactoryGet_FBC_ColorTemp_Batch(Tempmode, params); + if (fbcIns != NULL) { + fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, temp_value); + SSMSaveFBCN310LightsensorVal(temp_value); + return 0; + } - return temp_status; + return -1; } -int CTv::Tv_FactoryGetItemFromBatch(vpp_color_temperature_mode_t colortemp_mode, int item) -{ - tcon_rgb_ogo_t params; - int ret = 0; +int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void ) { + int temp_value = 0; + int data = 0; - Tv_FactoryGet_FBC_ColorTemp_Batch((vpp_color_temperature_mode_t)colortemp_mode, ¶ms); - switch (item) { - case 0: - ret = params.r_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); - break; - case 1: - ret = params.g_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); - break; - case 2: - ret = params.b_gain; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcGainParams(ret); - break; - case 3: - ret = params.r_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); - break; - case 4: - ret = params.g_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); - break; - case 5: - ret = params.b_post_offset; - ret = Tv_FactoryWhiteBalanceFormatOutputFbcOffsetParams(ret); - break; - default: - ret = 0; - } - return ret; + if (fbcIns != NULL) { + SSMReadFBCN310LightsensorVal(&temp_value); + data = temp_value; + return data; + } + return 0; } +int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value ) { + int temp_value = value; -int CTv::Tv_FactorySet_FBC_CM_OnOff( unsigned char status ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_CM(COMM_DEV_SERIAL, status); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, temp_value); + SSMSaveFBCN310Dream_PanelVal(temp_value); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_CM_OnOff (void) -{ - int temp_status = 0; +int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void ) { + int temp_value = 0; + int data = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_CM(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } + if (fbcIns != NULL) { + SSMReadFBCN310Dream_PanelVal(&temp_value); + data = temp_value; + return data; + } - return 0; + return 0; } -int CTv::Tv_FactorySet_FBC_DNLP_OnOff( unsigned char status ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_DNLP(COMM_DEV_SERIAL, status); - return 0; - } +int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value ) { + int temp_value = value; + + if (fbcIns != NULL) { + fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, temp_value); + SSMSaveFBCN310MULT_PQVal(temp_value); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_DNLP_OnOff (void) -{ - int temp_status = 0; +int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void ) { + int temp_value = 0; + int data = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_DNLP(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } + if (fbcIns != NULL) { + SSMReadFBCN310MULT_PQVal(&temp_value); + data = temp_value; + return data; + } - return 0; + return 0; } -int CTv::Tv_FactorySet_FBC_Gamma_OnOff( unsigned char status ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Gamma(COMM_DEV_SERIAL, status); - return 0; - } +int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value ) { + int temp_value = value; - return -1; + if (fbcIns != NULL) { + fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, temp_value); + SSMSaveFBCN310MEMCVal(temp_value); + return 0; + } + + return -1; } -int CTv::Tv_FactoryGet_FBC_Gamma_OnOff (void) -{ - int temp_status = 0; +int CTv::Tv_FactoryGet_FBC_MEMC_Status_N310 ( void ) { + int temp_value = 0; + int data = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Gamma(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } + if (fbcIns != NULL) { + SSMReadFBCN310MEMCVal(&temp_value); + data = temp_value; + return data; + } - return 0; + return -1; } -int CTv::Tv_FactorySet_FBC_WhiteBalance_OnOff( unsigned char status ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_WhiteBalance_OnOff(COMM_DEV_SERIAL, status); - return 0; - } +int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N310( int mode ) { + //int colorTemp = 0; + if (fbcIns != NULL) { + //colorTemp = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(mode); + fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); + SSMSaveFBCN310ColorTempVal(mode); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_WhiteBalance_OnOff (void) -{ - int temp_status = 0; +int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N310 ( void ) { + int mode = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_WhiteBalance_OnOff(COMM_DEV_SERIAL, &temp_status); - return temp_status; - } + if (fbcIns != NULL) { + SSMReadFBCN310ColorTempVal(&mode); + //mode = Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(temp_mode); - return 0; + return mode; + } + return -1; } +int CTv::Tv_FactorySet_FBC_Backlight_N310 ( int value ) { + int val = 0; -int CTv::Tv_FactorySet_FBC_backlight_onoff ( int value ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_backlight_onoff(COMM_DEV_SERIAL, value); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, value); + val = value; + SSMSaveFBCN310BackLightVal(val); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_backlight_onoff ( void ) -{ - int temp_value = 0; +int CTv::Tv_FactoryGet_FBC_Backlight_N310 ( void ) { + int val = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Get_backlight_onoff(COMM_DEV_SERIAL, &temp_value); - return temp_value; - } + if (fbcIns != NULL) { + SSMReadFBCN310BackLightVal(&val); + return val; + } - return 0; + return -1; } -int CTv::Tv_FactorySet_FBC_LVDS_SSG_Set( int value ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_LVDS_SSG_Set(COMM_DEV_SERIAL, value); - return 0; - } +int CTv::Tv_FactorySet_FBC_Bluetooth_IIS_N310 ( int value ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, value); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactorySet_FBC_LightSensor_Status_N310 ( int value ) -{ - int temp_value = value; +int CTv::Tv_FactoryGet_FBC_Bluetooth_IIS_N310 ( void ) { + int temp_value = 0; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_LightSensor_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310LightsensorVal(temp_value); - return 0; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, &temp_value); + return temp_value; + } - return -1; + return 0; } -int CTv::Tv_FactoryGet_FBC_LightSensor_Status_N310 ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { +int CTv::Tv_FactorySet_FBC_Led_N310 ( int val_1, int val_2, int val_3 ) { + int val = 0; - SSMReadFBCN310LightsensorVal(&temp_value); - data = temp_value; + if (fbcIns != NULL) { + val = fbcIns->cfbc_Set_Led_onoff(COMM_DEV_SERIAL, val_1, val_2, val_3); + return val; + } - return data; - } - - return 0; + return -1; } -int CTv::Tv_FactorySet_FBC_Dream_Panel_Status_N310 ( int value ) -{ - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Dream_Panel_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310Dream_PanelVal(temp_value); - return 0; - } +int CTv::Tv_FactorySet_VbyOne_Spread_Spectrum_N311 ( int value ) { + if (fbcIns != NULL) { + return -1; + } else { + LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); + SSMSaveN311_VbyOne_Spread_Spectrum_Val(value); - return -1; -} + switch (value) { + case 0: + //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x135c5091 c 0x10ca"); + //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x801da72c c 0x10cb"); + break; + case 1: + SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x1ba05091 c 0x10ca"); + SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x80bda72c c 0x10cb"); + break; + default: + LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); + break; + } -int CTv::Tv_FactoryGet_FBC_Dream_Panel_Status_N310 ( void ) -{ - int temp_value = 0; - int data = 0; - - if (fbcIns != NULL) { - - SSMReadFBCN310Dream_PanelVal(&temp_value); - data = temp_value; - - return data; - } - - return 0; + return 0; + } } -int CTv::Tv_FactorySet_FBC_MULT_PQ_Status_N310 ( int value ) -{ - int temp_value = value; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_MULT_PQ_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310MULT_PQVal(temp_value); - return 0; - } - - return -1; +int CTv::Tv_FactoryGet_VbyOne_Spread_Spectrum_N311 ( void ) { + int val = 0; + if (fbcIns != NULL) { + return -1; + } else { + SSMReadN311_VbyOne_Spread_Spectrum_Val(&val); + return val; + } } -int CTv::Tv_FactoryGet_FBC_MULT_PQ_Status_N310 ( void ) -{ - int temp_value = 0; - int data = 0; +int CTv::Tv_FactorySet_FBC_AP_STANDBY_N310 ( int value ) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_AP_STANDBY_N310(COMM_DEV_SERIAL, value); + return 0; + } - if (fbcIns != NULL) { + return -1; +} - SSMReadFBCN310MULT_PQVal(&temp_value); - data = temp_value; +int CTv::Tv_FactoryGet_FBC_AP_STANDBY_N310( void ) { + int temp_value = 0; - return data; - } + if (fbcIns != NULL) { + fbcIns->cfbc_Get_AP_STANDBY_N310(COMM_DEV_SERIAL, &temp_value); + return temp_value; + } - return 0; + return 0; } -int CTv::Tv_FactorySet_FBC_MEMC_Status_N310 ( int value ) -{ - int temp_value = value; - if (fbcIns != NULL) { - fbcIns->cfbc_Set_MEMC_N310(COMM_DEV_SERIAL, temp_value); - SSMSaveFBCN310MEMCVal(temp_value); - return 0; - } +int CTv::Tv_FactorySet_Uboot_Stage(int value) { + if (fbcIns != NULL) { + fbcIns->cfbc_Set_Fbc_Uboot_Stage(COMM_DEV_SERIAL, value); + return 0; + } - return -1; + return -1; } -int CTv::Tv_FactoryGet_FBC_MEMC_Status_N310 ( void ) -{ - int temp_value = 0; - int data = 0; +//audio +void CTv::TvAudioOpen() { + SetAudioAVOutMute(CC_AUDIO_UNMUTE); + SetAudioSPDIFMute(CC_AUDIO_UNMUTE); + project_info_t tmp_info; + if (GetProjectInfo(&tmp_info) == 0) { + strncpy(mMainVolLutTableExtraName, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1); + } + openTvAudio(); +} - if (fbcIns != NULL) { +void CTv::AudioCtlUninit() { + int oldMuteStatus; - SSMReadFBCN310MEMCVal(&temp_value); - data = temp_value; + oldMuteStatus = GetAudioMuteForTv(); + SetAudioMuteForTv(CC_AUDIO_MUTE); - return data; - } + //AudioCtlUninit(); + AudioSetAudioInSource (CC_AUDIO_IN_SOURCE_HDMI); + SetDAC_Digital_PlayBack_Volume(255); + AudioSetAudioSourceType (AUDIO_MPEG_SOURCE); + UnInitTvAudio(); + SetAudioVolumeCompensationVal(0); + SetAudioMasterVolume(GetAudioMasterVolume()); + UnInitSetTvAudioCard(); - return -1; + SetAudioMuteForTv(oldMuteStatus); } -int CTv::Tv_FactorySet_FBC_ColorTemp_Mode_N310( int mode ) -{ - //int colorTemp = 0; - if (fbcIns != NULL) { - //colorTemp = Tv_FactoryWhiteBalanceColorTempMappingG92Fbc(mode); - fbcIns->cfbc_Set_ColorTemp_Mode(COMM_DEV_SERIAL, mode); - SSMSaveFBCN310ColorTempVal(mode); - return 0; - } - return -1; +char *CTv::GetMainVolLutTableExtraName() { + return mMainVolLutTableExtraName; } -int CTv::Tv_FactoryGet_FBC_ColorTemp_Mode_N310 ( void ) -{ - - int mode = 0; - - if (fbcIns != NULL) { - SSMReadFBCN310ColorTempVal(&mode); - //mode = Tv_FactoryWhiteBalanceColorTempMappingFbc2G9(temp_mode); - - return mode; - } - return -1; +//audio +int CTv::SetAudioMuteForSystem(int muteOrUnmute) { + int ret = 0; + LOGD("SetAudioMuteForSystem sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); + mAudioMuteStatusForSystem = muteOrUnmute; + ret |= SetDacMute(mAudioMuteStatusForSystem, CC_DAC_MUTE_TYPE_EXTERNAL); + ret |= SetAudioI2sMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv); + return ret; } -int CTv::Tv_FactorySet_FBC_Backlight_N310 ( int value ) -{ - int val = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Backlight(COMM_DEV_SERIAL, value); - val = value; - SSMSaveFBCN310BackLightVal(val); - return 0; - } - - return -1; +int CTv::GetAudioMuteForSystem() { + return mAudioMuteStatusForSystem; } -int CTv::Tv_FactoryGet_FBC_Backlight_N310 ( void ) -{ - int val = 0; - - if (fbcIns != NULL) { - SSMReadFBCN310BackLightVal(&val); - - return val; - } - - return -1; - +int CTv::SetAudioMuteForTv(int muteOrUnmute) { + int ret = 0; + mAudioMuteStatusForTv = muteOrUnmute; + LOGD("SetAudioMuteForTv sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); + ret |= SetDacMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv, CC_DAC_MUTE_TYPE_EXTERNAL | CC_DAC_MUTE_TYPE_INTERNAL); + ret |= SetAudioI2sMute(mAudioMuteStatusForTv); + return ret; } -int CTv::Tv_FactorySet_FBC_Bluetooth_IIS_N310 ( int value ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, value); - return 0; - } - - return -1; +int CTv::GetAudioMuteForTv() { + return mAudioMuteStatusForTv; } -int CTv::Tv_FactoryGet_FBC_Bluetooth_IIS_N310 ( void ) -{ - int temp_value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_Bluetooth_IIS_onoff(COMM_DEV_SERIAL, &temp_value); - return temp_value; - } - - return 0; +int CTv::GetDbxTvMode(int *mode, int *son_value, int *vol_value, int *sur_value) { + *mode = 0; + return SSMReadAudioDbxTvValue(son_value, vol_value, sur_value); } -int CTv::Tv_FactorySet_FBC_Led_N310 ( int val_1, int val_2, int val_3 ) -{ - int val = 0; - - if (fbcIns != NULL) { - val = fbcIns->cfbc_Set_Led_onoff(COMM_DEV_SERIAL, val_1, val_2, val_3); - return val; - } - return -1; -} -int CTv::Tv_FactorySet_VbyOne_Spread_Spectrum_N311 ( int value ) -{ - if (fbcIns != NULL) { - return -1; - } else { - LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); - SSMSaveN311_VbyOne_Spread_Spectrum_Val(value); +int CTv::SetAudioSPDIFSwitch(int tmp_val) { + int muteStatus = CC_AUDIO_UNMUTE; - switch (value) { - case 0: - //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x135c5091 c 0x10ca"); - //SetFileAttrValue ( "/sys/class/amlogic/debug" ,"w 0x801da72c c 0x10cb"); - break; - case 1: - SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x1ba05091 c 0x10ca"); - SetFileAttrValue ( "/sys/class/amlogic/debug" , "w 0x80bda72c c 0x10cb"); - break; - default: - LOGD("%s, Set spectrum for T868 V-by-one....%d....\n", __FUNCTION__ , value); - break; - } + SaveCurAudioSPDIFSwitch(tmp_val); - return 0; - } + if (tmp_val == CC_SWITCH_OFF /*|| mAudioMuteStatusForSystem == CC_AUDIO_MUTE || mAudioMuteStatusForTv == CC_AUDIO_MUTE*/) { + muteStatus = CC_AUDIO_MUTE; + } else { + muteStatus = CC_AUDIO_UNMUTE; + } + SetAudioSPDIFMute(muteStatus); + return 0; } -int CTv::Tv_FactoryGet_VbyOne_Spread_Spectrum_N311 ( void ) -{ - int val = 0; - if (fbcIns != NULL) { - return -1; - } else { - SSMReadN311_VbyOne_Spread_Spectrum_Val(&val); - - return val; - } - +int CTv::AudioHandleHeadsetPlugIn() { + return 0; } -int CTv::Tv_FactorySet_FBC_AP_STANDBY_N310 ( int value ) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_AP_STANDBY_N310(COMM_DEV_SERIAL, value); - return 0; - } - return -1; +int CTv::AudioHandleHeadsetPullOut() { + return 0; } -int CTv::Tv_FactoryGet_FBC_AP_STANDBY_N310( void ) -{ - int temp_value = 0; - - if (fbcIns != NULL) { - fbcIns->cfbc_Get_AP_STANDBY_N310(COMM_DEV_SERIAL, &temp_value); - return temp_value; - } - - return 0; +int CTv::Tv_SetDRC_OnOff(int on_off) { + on_off = on_off; + return 0; } -int CTv::Tv_FactorySet_Uboot_Stage(int value) -{ - if (fbcIns != NULL) { - fbcIns->cfbc_Set_Fbc_Uboot_Stage(COMM_DEV_SERIAL, value); - return 0; - } - - return -1; +int CTv::Tv_GetDRC_OnOff(void) { + return 0; } -//audio -void CTv::TvAudioOpen() -{ - SetAudioAVOutMute(CC_AUDIO_UNMUTE); - SetAudioSPDIFMute(CC_AUDIO_UNMUTE); - project_info_t tmp_info; - if (GetProjectInfo(&tmp_info) == 0) { - strncpy(mMainVolLutTableExtraName, tmp_info.amp_curve_name, CC_PROJECT_INFO_ITEM_MAX_LEN - 1); - } - openTvAudio(); +void CTv::updateSubtitle(int pic_width, int pic_height) { + TvEvent::SubtitleEvent ev; + ev.pic_width = pic_width; + ev.pic_height = pic_height; + sendTvEvent(ev); } -void CTv::AudioCtlUninit() -{ - int oldMuteStatus; - - oldMuteStatus = GetAudioMuteForTv(); - SetAudioMuteForTv(CC_AUDIO_MUTE); - - //AudioCtlUninit(); - AudioSetAudioInSource (CC_AUDIO_IN_SOURCE_HDMI); - SetDAC_Digital_PlayBack_Volume(255); - AudioSetAudioSourceType (AUDIO_MPEG_SOURCE); - UnInitTvAudio(); - SetAudioVolumeCompensationVal(0); - SetAudioMasterVolume(GetAudioMasterVolume()); - UnInitSetTvAudioCard(); - - SetAudioMuteForTv(oldMuteStatus); +int CTv::setSubtitleBuffer(char *share_mem) { + mSubtitle.setBuffer(share_mem); + return 0; } -char *CTv::GetMainVolLutTableExtraName() -{ - return mMainVolLutTableExtraName; -} -//audio -int CTv::SetAudioMuteForSystem(int muteOrUnmute) -{ - int ret = 0; - LOGD("SetAudioMuteForSystem sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); - mAudioMuteStatusForSystem = muteOrUnmute; - ret |= SetDacMute(mAudioMuteStatusForSystem, CC_DAC_MUTE_TYPE_EXTERNAL); - ret |= SetAudioI2sMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv); - return ret; +int CTv::initSubtitle(int bitmapWidth, int bitmapHeight) { + return mSubtitle.sub_init(bitmapWidth, bitmapHeight); } -int CTv::GetAudioMuteForSystem() -{ - return mAudioMuteStatusForSystem; +int CTv::lockSubtitle() { + return mSubtitle.sub_lock(); } -int CTv::SetAudioMuteForTv(int muteOrUnmute) -{ - int ret = 0; - mAudioMuteStatusForTv = muteOrUnmute; - LOGD("SetAudioMuteForTv sysMuteStats=%d, tvMuteStatus=%d, toMute=%d", mAudioMuteStatusForSystem, mAudioMuteStatusForTv, muteOrUnmute); - ret |= SetDacMute(mAudioMuteStatusForSystem | mAudioMuteStatusForTv, CC_DAC_MUTE_TYPE_EXTERNAL | CC_DAC_MUTE_TYPE_INTERNAL); - ret |= SetAudioI2sMute(mAudioMuteStatusForTv); - return ret; +int CTv::unlockSubtitle() { + return mSubtitle.sub_unlock(); } -int CTv::GetAudioMuteForTv() -{ - return mAudioMuteStatusForTv; +int CTv::getSubSwitchStatus() { + return mSubtitle.sub_switch_status(); } -int CTv::GetDbxTvMode(int *mode, int *son_value, int *vol_value, int *sur_value) -{ - *mode = 0; - return SSMReadAudioDbxTvValue(son_value, vol_value, sur_value); +int CTv::startSubtitle(int dmx_id, int pid, int page_id, int anc_page_id) { + return mSubtitle.sub_start_dvb_sub(dmx_id, pid, page_id, anc_page_id); } -int CTv::SetAudioSPDIFSwitch(int tmp_val) -{ - int muteStatus = CC_AUDIO_UNMUTE; +int CTv::stopSubtitle() { + return mSubtitle.sub_stop_dvb_sub(); +} - SaveCurAudioSPDIFSwitch(tmp_val); +//-------------------------------------------------- - if (tmp_val == CC_SWITCH_OFF /*|| mAudioMuteStatusForSystem == CC_AUDIO_MUTE || mAudioMuteStatusForTv == CC_AUDIO_MUTE*/) { - muteStatus = CC_AUDIO_MUTE; - } else { - muteStatus = CC_AUDIO_UNMUTE; - } - SetAudioSPDIFMute(muteStatus); - return 0; +//Audio Mute +int CTv::SetAudioI2sMute(int muteStatus) { + int vol = 256; + if (muteStatus == CC_AUDIO_MUTE) { + vol = 0; + } else { + vol = 256; + } + CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_right_gain", vol); + CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_left_gain", vol); + return 0; } -int CTv::AudioHandleHeadsetPlugIn() -{ - return 0; -} +int CTv::SetDacMute(int muteStatus, int mute_type) { + int tmp_ret = 0; + if (mute_type & CC_DAC_MUTE_TYPE_INTERNAL) { + tmp_ret |= mAudioAlsa.SetInternalDacMute(muteStatus); + } -int CTv::AudioHandleHeadsetPullOut() -{ - return 0; -} + if (mute_type & CC_DAC_MUTE_TYPE_EXTERNAL) { + int tmp_ret = 0, set_val = 0; + int aud_arch_type = GetAudioArchitectureTypeCFG(); -int CTv::Tv_SetDRC_OnOff(int on_off) -{ - return 0; -} -int CTv::Tv_GetDRC_OnOff(void) -{ - return 0; -} + if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { + if (muteStatus == CC_AUDIO_MUTE) { + set_val = CC_MUTE_ON; + } else if (muteStatus == CC_AUDIO_UNMUTE) { + set_val = CC_MUTE_OFF; + } else { + return -1; + } -void CTv::updateSubtitle(int pic_width, int pic_height) -{ - TvEvent::SubtitleEvent ev; - ev.pic_width = pic_width; - ev.pic_height = pic_height; - sendTvEvent(ev); + mAudioAlsa.SetExternalDacChannelSwitch(1, set_val); + mAudioAlsa.SetExternalDacChannelSwitch(2, set_val); + //showboz: can disable it + mAudioAlsa.SetExternalDacChannelSwitch(3, set_val); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_MUTE, muteStatus); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { + mCustomerCtrl.SetMute((muteStatus == CC_AUDIO_MUTE) ? CAudioCustomerCtrl::MUTE : CAudioCustomerCtrl::UNMUTE); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { + mAudioAlsa.SetDigitalMute(muteStatus); + } + mAudioAlsa.setAudioPcmPlaybackMute(muteStatus); + } + return tmp_ret; } -int CTv::setSubtitleBuffer(char *share_mem) -{ - mSubtitle.setBuffer(share_mem); - return 0; +int CTv::SetAudioAVOutMute(int muteStatus) { + SSMSaveAudioAVOutMuteVal(muteStatus); + return mAudioAlsa.SetInternalDacMute(muteStatus); } -int CTv::initSubtitle(int bitmapWidth, int bitmapHeight) -{ - return mSubtitle.sub_init(bitmapWidth, bitmapHeight); +int CTv::GetAudioAVOutMute() { + int8_t tmp_ch = 0; + SSMReadAudioAVOutMuteVal(&tmp_ch); + return tmp_ch; } -int CTv::lockSubtitle() -{ - return mSubtitle.sub_lock(); -} +int CTv::SetAudioSPDIFMute(int muteStatus) { + if (GetCurAudioSPDIFSwitch() == CC_SWITCH_OFF) { + muteStatus = CC_AUDIO_MUTE; + } -int CTv::unlockSubtitle() -{ - return mSubtitle.sub_unlock(); + SSMSaveAudioSPIDFMuteVal(muteStatus); + return mAudioAlsa.SetSPDIFMute(muteStatus); } -int CTv::getSubSwitchStatus() -{ - return mSubtitle.sub_switch_status(); +int CTv::GetAudioSPDIFMute() { + int8_t tmp_ch = 0; + SSMReadAudioSPIDFMuteVal(&tmp_ch); + return tmp_ch; } -int CTv::startSubtitle(int dmx_id, int pid, int page_id, int anc_page_id) -{ - return mSubtitle.sub_start_dvb_sub(dmx_id, pid, page_id, anc_page_id); +int CTv::GetCurAudioSPDIFSwitch() { + return mCurAudioSPDIFSwitch; } -int CTv::stopSubtitle() -{ - return mSubtitle.sub_stop_dvb_sub(); -} +int CTv::SaveCurAudioSPDIFSwitch(int tmp_val) { + int8_t tmp_ch = 0; -//-------------------------------------------------- + mCurAudioSPDIFSwitch = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSPDIFSwitchVal(tmp_ch); + return mCurAudioSPDIFSwitch; +} -//Audio Mute -int CTv::SetAudioI2sMute(int muteStatus) -{ - int vol = 256; - if (muteStatus == CC_AUDIO_MUTE) { - vol = 0; - } else { - vol = 256; - } - CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_right_gain", vol); - CFile::setFileAttrValue("/sys/class/amaudio2/aml_direct_left_gain", vol); - return 0; -} - -int CTv::SetDacMute(int muteStatus, int mute_type) -{ - int tmp_ret = 0; - if (mute_type & CC_DAC_MUTE_TYPE_INTERNAL) { - tmp_ret |= mAudioAlsa.SetInternalDacMute(muteStatus); - } - - if (mute_type & CC_DAC_MUTE_TYPE_EXTERNAL) { - int tmp_ret = 0, set_val = 0; - int aud_arch_type = GetAudioArchitectureTypeCFG(); - - if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { - if (muteStatus == CC_AUDIO_MUTE) { - set_val = CC_MUTE_ON; - } else if (muteStatus == CC_AUDIO_UNMUTE) { - set_val = CC_MUTE_OFF; - } else { - return -1; - } - - mAudioAlsa.SetExternalDacChannelSwitch(1, set_val); - mAudioAlsa.SetExternalDacChannelSwitch(2, set_val); - //showboz: can disable it - mAudioAlsa.SetExternalDacChannelSwitch(3, set_val); - - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_MUTE, muteStatus); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { - mCustomerCtrl.SetMute((muteStatus == CC_AUDIO_MUTE) ? CAudioCustomerCtrl::MUTE : CAudioCustomerCtrl::UNMUTE); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { - mAudioAlsa.SetDigitalMute(muteStatus); - } - mAudioAlsa.setAudioPcmPlaybackMute(muteStatus); - } - return tmp_ret; -} - -int CTv::SetAudioAVOutMute(int muteStatus) -{ - SSMSaveAudioAVOutMuteVal(muteStatus); - return mAudioAlsa.SetInternalDacMute(muteStatus); -} - -int CTv::GetAudioAVOutMute() -{ - int8_t tmp_ch = 0; - SSMReadAudioAVOutMuteVal(&tmp_ch); - return tmp_ch; -} - -int CTv::SetAudioSPDIFMute(int muteStatus) -{ - if (GetCurAudioSPDIFSwitch() == CC_SWITCH_OFF) { - muteStatus = CC_AUDIO_MUTE; - } - - SSMSaveAudioSPIDFMuteVal(muteStatus); - return mAudioAlsa.SetSPDIFMute(muteStatus); -} - -int CTv::GetAudioSPDIFMute() -{ - int8_t tmp_ch = 0; - SSMReadAudioSPIDFMuteVal(&tmp_ch); - return tmp_ch; -} -int CTv::GetCurAudioSPDIFSwitch() -{ - return mCurAudioSPDIFSwitch; -} - -int CTv::SaveCurAudioSPDIFSwitch(int tmp_val) -{ - int8_t tmp_ch = 0; - - mCurAudioSPDIFSwitch = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSPDIFSwitchVal(tmp_ch); - - return mCurAudioSPDIFSwitch; -} - -int CTv::LoadCurAudioSPDIFSwitch() -{ - int8_t tmp_ch = 0; - SSMReadAudioSPDIFSwitchVal(&tmp_ch); - mCurAudioSPDIFSwitch = tmp_ch; - if (mCurAudioSPDIFSwitch != CC_SWITCH_ON - && mCurAudioSPDIFSwitch != CC_SWITCH_OFF) { - SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); - } - return mCurAudioSPDIFSwitch; +int CTv::LoadCurAudioSPDIFSwitch() { + int8_t tmp_ch = 0; + SSMReadAudioSPDIFSwitchVal(&tmp_ch); + mCurAudioSPDIFSwitch = tmp_ch; + if (mCurAudioSPDIFSwitch != CC_SWITCH_ON + && mCurAudioSPDIFSwitch != CC_SWITCH_OFF) { + SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); + } + return mCurAudioSPDIFSwitch; } //Audio SPDIF Mode -int CTv::SetAudioSPDIFMode(int tmp_val) -{ - LOGD("%s : tmp_val = %d\n", __FUNCTION__, tmp_val); - mCurAudioSPDIFMode = tmp_val; +int CTv::SetAudioSPDIFMode(int tmp_val) { + LOGD("%s : tmp_val = %d\n", __FUNCTION__, tmp_val); + mCurAudioSPDIFMode = tmp_val; - SetSPDIFMode(mCurAudioSPDIFMode); - - return 0; + SetSPDIFMode(mCurAudioSPDIFMode); + return 0; } -int CTv::GetCurAudioSPDIFMode() -{ - return mCurAudioSPDIFMode; +int CTv::GetCurAudioSPDIFMode() { + return mCurAudioSPDIFMode; } -int CTv::SaveCurAudioSPDIFMode(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSPDIFMode(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioSPDIFMode = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSPDIFModeVal(tmp_ch); + mCurAudioSPDIFMode = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSPDIFModeVal(tmp_ch); - return mCurAudioSPDIFMode; + return mCurAudioSPDIFMode; } -int CTv::LoadCurAudioSPDIFMode() -{ - int8_t tmp_ch = 0; - SSMReadAudioSPDIFModeVal(&tmp_ch); - mCurAudioSPDIFMode = tmp_ch; - if (mCurAudioSPDIFMode != CC_SPDIF_MODE_PCM - && mCurAudioSPDIFMode != CC_SPDIF_MODE_RAW) { - SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); - } - return mCurAudioSPDIFMode; +int CTv::LoadCurAudioSPDIFMode() { + int8_t tmp_ch = 0; + SSMReadAudioSPDIFModeVal(&tmp_ch); + mCurAudioSPDIFMode = tmp_ch; + if (mCurAudioSPDIFMode != CC_SPDIF_MODE_PCM + && mCurAudioSPDIFMode != CC_SPDIF_MODE_RAW) { + SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); + } + return mCurAudioSPDIFMode; } -int CTv::SetAudioMasterVolume(int tmp_vol) -{ - mCustomAudioMasterVolume = tmp_vol; - //Volume Compensation - tmp_vol += mVolumeCompensationVal; +int CTv::SetAudioMasterVolume(int tmp_vol) { + mCustomAudioMasterVolume = tmp_vol; + + //Volume Compensation + tmp_vol += mVolumeCompensationVal; - if (tmp_vol > CC_MAX_SOUND_VOL) { - tmp_vol = CC_MAX_SOUND_VOL; - } + if (tmp_vol > CC_MAX_SOUND_VOL) { + tmp_vol = CC_MAX_SOUND_VOL; + } - if (tmp_vol < CC_MIN_SOUND_VOL) { - tmp_vol = CC_MIN_SOUND_VOL; - } + if (tmp_vol < CC_MIN_SOUND_VOL) { + tmp_vol = CC_MIN_SOUND_VOL; + } - int tmp_ret = 0; - int aud_arch_type = GetAudioArchitectureTypeCFG(); + int tmp_ret = 0; + int aud_arch_type = GetAudioArchitectureTypeCFG(); - if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { - tmp_ret = mAudioAlsa.SetInternalDacMainVolume(tmp_vol); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { - int digit_vol = 0; - int vol_gain_val = 0; - int vol_buf[2] = {0, 0}; + if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { + tmp_ret = mAudioAlsa.SetInternalDacMainVolume(tmp_vol); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { + int digit_vol = 0; + int vol_gain_val = 0; + int vol_buf[2] = {0, 0}; - //handle l&r channel volume for balance - mAudioAlsa.CalculateBalanceVol(255, mMainVolumeBalanceVal, vol_buf); + //handle l&r channel volume for balance + mAudioAlsa.CalculateBalanceVol(255, mMainVolumeBalanceVal, vol_buf); - tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(1, vol_buf[0]); - tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(2, vol_buf[1]); + tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(1, vol_buf[0]); + tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(2, vol_buf[1]); - //handle master channel volume - digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); + //handle master channel volume + digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); - vol_gain_val = mAudioAlsa.GetMainVolumeGain(); - digit_vol += vol_gain_val; - tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(0, digit_vol); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_VOLUME_BAR, tmp_vol); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { - tmp_ret = mCustomerCtrl.SetVolumeBar(tmp_vol); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { - int vol_buf[2] = {0, 0}; - mAudioAlsa.CalculateBalanceVol(tmp_vol, mMainVolumeBalanceVal, vol_buf); - tmp_ret = mAudioAlsa.SetDigitalMainVolume(vol_buf[0], vol_buf[1]); - } - if ( Get2d4gHeadsetEnable() == 1 ) { - setAudioPcmPlaybackVolume(tmp_vol); - } - return 0; + vol_gain_val = mAudioAlsa.GetMainVolumeGain(); + digit_vol += vol_gain_val; + tmp_ret |= mAudioAlsa.SetExternalDacChannelVolume(0, digit_vol); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_VOLUME_BAR, tmp_vol); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { + tmp_ret = mCustomerCtrl.SetVolumeBar(tmp_vol); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { + int vol_buf[2] = {0, 0}; + mAudioAlsa.CalculateBalanceVol(tmp_vol, mMainVolumeBalanceVal, vol_buf); + tmp_ret = mAudioAlsa.SetDigitalMainVolume(vol_buf[0], vol_buf[1]); + } + if ( Get2d4gHeadsetEnable() == 1 ) { + setAudioPcmPlaybackVolume(tmp_vol); + } + return 0; } -int CTv::GetAudioMasterVolume() -{ - return mCustomAudioMasterVolume; +int CTv::GetAudioMasterVolume() { + return mCustomAudioMasterVolume; } -int CTv::GetCurAudioMasterVolume() -{ - return mCurAudioMasterVolume; +int CTv::GetCurAudioMasterVolume() { + return mCurAudioMasterVolume; } -int CTv::SaveCurAudioMasterVolume(int tmp_vol) -{ - mCurAudioMasterVolume = tmp_vol; - SSMSaveAudioMasterVolume(tmp_vol); - return mCurAudioMasterVolume; +int CTv::SaveCurAudioMasterVolume(int tmp_vol) { + mCurAudioMasterVolume = tmp_vol; + SSMSaveAudioMasterVolume(tmp_vol); + return mCurAudioMasterVolume; } -int CTv::LoadCurAudioMasterVolume() -{ - int8_t tmp_ch = 0; - SSMReadAudioMasterVolume(&tmp_ch); - mCurAudioMasterVolume = tmp_ch; - if (mCurAudioMasterVolume < CC_MIN_SOUND_VOL - || mCurAudioMasterVolume > CC_MAX_SOUND_VOL) { - SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); - } - mCustomAudioMasterVolume = mCurAudioMasterVolume; +int CTv::LoadCurAudioMasterVolume() { + int8_t tmp_ch = 0; + SSMReadAudioMasterVolume(&tmp_ch); + mCurAudioMasterVolume = tmp_ch; + if (mCurAudioMasterVolume < CC_MIN_SOUND_VOL + || mCurAudioMasterVolume > CC_MAX_SOUND_VOL) { + SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); + } + mCustomAudioMasterVolume = mCurAudioMasterVolume; - return mCurAudioMasterVolume; + return mCurAudioMasterVolume; } -int CTv::SetAudioBalance(int tmp_val) -{ - mCustomAudioBalance = tmp_val; +int CTv::SetAudioBalance(int tmp_val) { + mCustomAudioBalance = tmp_val; - int aud_arch_type = GetAudioArchitectureTypeCFG(); + int aud_arch_type = GetAudioArchitectureTypeCFG(); - mMainVolumeBalanceVal = tmp_val; + mMainVolumeBalanceVal = tmp_val; - if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_BALANCE, mMainVolumeBalanceVal); - return 0; - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { - mCustomerCtrl.SetBlance(mMainVolumeBalanceVal); - return 0; - } else { - SetAudioMasterVolume(GetAudioMasterVolume()); - } - return 0; + if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_BALANCE, mMainVolumeBalanceVal); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { + mCustomerCtrl.SetBlance(mMainVolumeBalanceVal); + } else { + SetAudioMasterVolume(GetAudioMasterVolume()); + } + return 0; } -int CTv::GetAudioBalance() -{ - return mCustomAudioBalance; +int CTv::GetAudioBalance() { + return mCustomAudioBalance; } -int CTv::GetCurAudioBalance() -{ - return mCurAudioBalance; +int CTv::GetCurAudioBalance() { + return mCurAudioBalance; } -int CTv::SaveCurAudioBalance(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioBalance(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioBalance = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioBalanceVal(tmp_ch); + mCurAudioBalance = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioBalanceVal(tmp_ch); - return mCurAudioBalance; + return mCurAudioBalance; } -int CTv::LoadCurAudioBalance() -{ - int8_t tmp_ch = 0; - SSMReadAudioBalanceVal(&tmp_ch); - mCurAudioBalance = tmp_ch; - if (mCurAudioBalance < CC_MIN_SOUND_BALANCE_VAL - || mCurAudioBalance > CC_MAX_SOUND_BALANCE_VAL) { - SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); - } +int CTv::LoadCurAudioBalance() { + int8_t tmp_ch = 0; + SSMReadAudioBalanceVal(&tmp_ch); + mCurAudioBalance = tmp_ch; + if (mCurAudioBalance < CC_MIN_SOUND_BALANCE_VAL + || mCurAudioBalance > CC_MAX_SOUND_BALANCE_VAL) { + SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); + } - mCustomAudioBalance = mCurAudioBalance; + mCustomAudioBalance = mCurAudioBalance; - return mCurAudioBalance; + return mCurAudioBalance; } -int CTv::SetAudioVolumeCompensationVal(int tmp_vol_comp_val) -{ - mVolumeCompensationVal = tmp_vol_comp_val; - LOGD("%s, new vol comp value = %d.\n", - __FUNCTION__, tmp_vol_comp_val); - return mVolumeCompensationVal; +int CTv::SetAudioVolumeCompensationVal(int tmp_vol_comp_val) { + mVolumeCompensationVal = tmp_vol_comp_val; + LOGD("%s, new vol comp value = %d.\n", __FUNCTION__, tmp_vol_comp_val); + return mVolumeCompensationVal; } +int CTv::SetAudioSupperBassVolume(int tmp_vol) { + mCustomAudioSupperBassVolume = tmp_vol; -int CTv::SetAudioSupperBassVolume(int tmp_vol) -{ - mCustomAudioSupperBassVolume = tmp_vol; + int aud_arch_type = GetAudioArchitectureTypeCFG(); + int tmp_ret = 0; - int aud_arch_type = GetAudioArchitectureTypeCFG(); - int tmp_ret = 0; + if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { + return 0; + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { + int digit_vol = 0; + int vol_gain_val = 0; - if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { - return 0; - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { - int digit_vol = 0; - int vol_gain_val = 0; + digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); - digit_vol = mAudioAlsa.TransVolumeBarVolToDigitalVol(mAudioAlsa.GetMainVolDigitLutBuf(), tmp_vol); + vol_gain_val = mAudioAlsa.GetSupperBassVolumeGain(); + digit_vol += vol_gain_val; + if (digit_vol < CC_MIN_DAC_SUB_WOOFER_VOLUME) { + digit_vol = CC_MIN_DAC_SUB_WOOFER_VOLUME; + } else if (digit_vol > CC_MAX_DAC_SUB_WOOFER_VOLUME) { + digit_vol = CC_MAX_DAC_SUB_WOOFER_VOLUME; + } - vol_gain_val = mAudioAlsa.GetSupperBassVolumeGain(); - digit_vol += vol_gain_val; - if (digit_vol < CC_MIN_DAC_SUB_WOOFER_VOLUME) { - digit_vol = CC_MIN_DAC_SUB_WOOFER_VOLUME; - } else if (digit_vol > CC_MAX_DAC_SUB_WOOFER_VOLUME) { - digit_vol = CC_MAX_DAC_SUB_WOOFER_VOLUME; - } + tmp_ret = mAudioAlsa.SetExternalDacChannelVolume(3, digit_vol); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SUBCHANNEL_VOLUME, tmp_vol); + } - tmp_ret = mAudioAlsa.SetExternalDacChannelVolume(3, digit_vol); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - tmp_ret = SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SUBCHANNEL_VOLUME, tmp_vol); - } - - return tmp_ret; + return tmp_ret; } -int CTv::GetAudioSupperBassVolume() -{ - return mCustomAudioSupperBassVolume; +int CTv::GetAudioSupperBassVolume() { + return mCustomAudioSupperBassVolume; } -int CTv::GetCurAudioSupperBassVolume() -{ - return mCurAudioSupperBassVolume; +int CTv::GetCurAudioSupperBassVolume() { + return mCurAudioSupperBassVolume; } -int CTv::SaveCurAudioSupperBassVolume(int tmp_vol) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSupperBassVolume(int tmp_vol) { + int8_t tmp_ch = 0; - mCurAudioSupperBassVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioSupperBassVolume(tmp_ch); + mCurAudioSupperBassVolume = tmp_vol; + tmp_ch = tmp_vol; + SSMSaveAudioSupperBassVolume(tmp_ch); - return mCurAudioSupperBassVolume; + return mCurAudioSupperBassVolume; } -int CTv::LoadCurAudioSupperBassVolume() -{ - int8_t tmp_ch = 0; - SSMReadAudioSupperBassVolume(&tmp_ch); - mCurAudioSupperBassVolume = tmp_ch; - if (mCurAudioSupperBassVolume < CC_MIN_SUPPERBASS_VOL - || mCurAudioSupperBassVolume > CC_MAX_SUPPERBASS_VOL) { - SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); - } - mCustomAudioSupperBassVolume = mCurAudioSupperBassVolume; +int CTv::LoadCurAudioSupperBassVolume() { + int8_t tmp_ch = 0; + SSMReadAudioSupperBassVolume(&tmp_ch); + mCurAudioSupperBassVolume = tmp_ch; + if (mCurAudioSupperBassVolume < CC_MIN_SUPPERBASS_VOL + || mCurAudioSupperBassVolume > CC_MAX_SUPPERBASS_VOL) { + SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); + } + mCustomAudioSupperBassVolume = mCurAudioSupperBassVolume; - return mCurAudioSupperBassVolume; + return mCurAudioSupperBassVolume; } -int CTv::SetAudioSupperBassSwitch(int tmp_val) -{ - mCustomAudioSupperBassSwitch = tmp_val; - if (GetAudioSupperBassSwitch() == CC_SWITCH_OFF) { - return SetAudioSupperBassVolume(CC_MIN_SUPPERBASS_VOL); - } +int CTv::SetAudioSupperBassSwitch(int tmp_val) { + mCustomAudioSupperBassSwitch = tmp_val; + + if (GetAudioSupperBassSwitch() == CC_SWITCH_OFF) { + return SetAudioSupperBassVolume(CC_MIN_SUPPERBASS_VOL); + } - return SetAudioSupperBassVolume(GetAudioSupperBassVolume()); + return SetAudioSupperBassVolume(GetAudioSupperBassVolume()); } -int CTv::GetAudioSupperBassSwitch() -{ - if (GetAudioSupperBassSwitchDisableCFG() != 0) { - return CC_SWITCH_ON; - } +int CTv::GetAudioSupperBassSwitch() { + if (GetAudioSupperBassSwitchDisableCFG() != 0) { + return CC_SWITCH_ON; + } - return mCustomAudioSupperBassSwitch; + return mCustomAudioSupperBassSwitch; } -int CTv::GetCurAudioSupperBassSwitch() -{ - if (GetAudioSupperBassSwitchDisableCFG() != 0) { - return CC_SWITCH_ON; - } +int CTv::GetCurAudioSupperBassSwitch() { + if (GetAudioSupperBassSwitchDisableCFG() != 0) { + return CC_SWITCH_ON; + } - return mCurAudioSupperBassSwitch; + return mCurAudioSupperBassSwitch; } -int CTv::SaveCurAudioSupperBassSwitch(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSupperBassSwitch(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioSupperBassSwitch = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSupperBassSwitch(tmp_ch); + mCurAudioSupperBassSwitch = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSupperBassSwitch(tmp_ch); - SetSupperBassSRSSpeakerSize(); + SetSupperBassSRSSpeakerSize(); - return mCurAudioSupperBassSwitch; + return mCurAudioSupperBassSwitch; } -int CTv::LoadCurAudioSupperBassSwitch() -{ - int8_t tmp_ch = 0; - SSMReadAudioSupperBassSwitch(&tmp_ch); - mCurAudioSupperBassSwitch = tmp_ch; - if (mCurAudioSupperBassSwitch != CC_SWITCH_ON - && mCurAudioSupperBassSwitch != CC_SWITCH_OFF) { - SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); - } - mCustomAudioSupperBassSwitch = mCurAudioSupperBassSwitch; +int CTv::LoadCurAudioSupperBassSwitch() { + int8_t tmp_ch = 0; + SSMReadAudioSupperBassSwitch(&tmp_ch); + mCurAudioSupperBassSwitch = tmp_ch; + if (mCurAudioSupperBassSwitch != CC_SWITCH_ON + && mCurAudioSupperBassSwitch != CC_SWITCH_OFF) { + SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); + } + mCustomAudioSupperBassSwitch = mCurAudioSupperBassSwitch; - return mCurAudioSupperBassSwitch; + return mCurAudioSupperBassSwitch; } -void CTv::SetSupperBassSRSSpeakerSize() -{ - int tmp_speakersize = -1; +void CTv::SetSupperBassSRSSpeakerSize() { + int tmp_speakersize = -1; - if (GetAudioSrsTruBass() == CC_SWITCH_ON) { - tmp_speakersize = GetAudioSRSSupperBassTrubassSpeakerSizeCfg(); - if (tmp_speakersize >= 0) { - mAudioEffect.SetSrsTrubassSpeakerSize(tmp_speakersize); - } - } + if (GetAudioSrsTruBass() == CC_SWITCH_ON) { + tmp_speakersize = GetAudioSRSSupperBassTrubassSpeakerSizeCfg(); + if (tmp_speakersize >= 0) { + mAudioEffect.SetSrsTrubassSpeakerSize(tmp_speakersize); + } + } } -int CTv::SetAudioSRSSurround(int tmp_val) -{ - mCustomAudioSRSSurround = tmp_val; +int CTv::SetAudioSRSSurround(int tmp_val) { + mCustomAudioSRSSurround = tmp_val; - RefreshSrsEffectAndDacGain(); - return 0; + RefreshSrsEffectAndDacGain(); + return 0; } -int CTv::GetAudioSRSSurround() -{ - return mCustomAudioSRSSurround; +int CTv::GetAudioSRSSurround() { + return mCustomAudioSRSSurround; } -int CTv::GetCurAudioSRSSurround() -{ - return mCurAudioSRSSurround; +int CTv::GetCurAudioSRSSurround() { + return mCurAudioSRSSurround; } -int CTv::SaveCurAudioSrsSurround(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSrsSurround(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioSRSSurround = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSSurroundSwitch(tmp_ch); + mCurAudioSRSSurround = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSRSSurroundSwitch(tmp_ch); - return mCurAudioSRSSurround; + return mCurAudioSRSSurround; } -int CTv::LoadCurAudioSrsSurround() -{ - int8_t tmp_ch = 0; +int CTv::LoadCurAudioSrsSurround() { + int8_t tmp_ch = 0; - SSMReadAudioSRSSurroundSwitch(&tmp_ch); - mCurAudioSRSSurround = tmp_ch; - if (mCurAudioSRSSurround != CC_SWITCH_ON - && mCurAudioSRSSurround != CC_SWITCH_OFF) { - SaveCurAudioSrsSurround (CC_SWITCH_OFF); - } - mCustomAudioSRSSurround = mCurAudioSRSSurround; + SSMReadAudioSRSSurroundSwitch(&tmp_ch); + mCurAudioSRSSurround = tmp_ch; + if (mCurAudioSRSSurround != CC_SWITCH_ON + && mCurAudioSRSSurround != CC_SWITCH_OFF) { + SaveCurAudioSrsSurround (CC_SWITCH_OFF); + } + mCustomAudioSRSSurround = mCurAudioSRSSurround; - return mCurAudioSRSSurround; + return mCurAudioSRSSurround; } -int CTv::SetAudioSrsDialogClarity(int tmp_val) -{ - mCustomAudioSrsDialogClarity = tmp_val; - RefreshSrsEffectAndDacGain(); - - return 0; +int CTv::SetAudioSrsDialogClarity(int tmp_val) { + mCustomAudioSrsDialogClarity = tmp_val; + RefreshSrsEffectAndDacGain(); + return 0; } -int CTv::GetAudioSrsDialogClarity() -{ - return mCustomAudioSrsDialogClarity; +int CTv::GetAudioSrsDialogClarity() { + return mCustomAudioSrsDialogClarity; } -int CTv::GetCurAudioSrsDialogClarity() -{ - - return mCurAudioSrsDialogClarity; +int CTv::GetCurAudioSrsDialogClarity() { + return mCurAudioSrsDialogClarity; } -int CTv::SaveCurAudioSrsDialogClarity(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSrsDialogClarity(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioSrsDialogClarity = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSDialogClaritySwitch(tmp_ch); + mCurAudioSrsDialogClarity = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSRSDialogClaritySwitch(tmp_ch); - return mCurAudioSrsDialogClarity; + return mCurAudioSrsDialogClarity; } -int CTv::LoadCurAudioSrsDialogClarity() -{ - int8_t tmp_ch = 0; +int CTv::LoadCurAudioSrsDialogClarity() { + int8_t tmp_ch = 0; - SSMReadAudioSRSDialogClaritySwitch(&tmp_ch); - mCurAudioSrsDialogClarity = tmp_ch; - if (mCurAudioSrsDialogClarity != CC_SWITCH_ON - && mCurAudioSrsDialogClarity != CC_SWITCH_OFF) { - SaveCurAudioSrsDialogClarity (CC_SWITCH_OFF); - } - mCustomAudioSrsDialogClarity = mCurAudioSrsDialogClarity; + SSMReadAudioSRSDialogClaritySwitch(&tmp_ch); + mCurAudioSrsDialogClarity = tmp_ch; + if (mCurAudioSrsDialogClarity != CC_SWITCH_ON + && mCurAudioSrsDialogClarity != CC_SWITCH_OFF) { + SaveCurAudioSrsDialogClarity (CC_SWITCH_OFF); + } + mCustomAudioSrsDialogClarity = mCurAudioSrsDialogClarity; - return mCurAudioSrsDialogClarity; + return mCurAudioSrsDialogClarity; } -int CTv::SetAudioSrsTruBass(int tmp_val) -{ - mCustomAudioSrsTruBass = tmp_val; - RefreshSrsEffectAndDacGain(); - - return 0; +int CTv::SetAudioSrsTruBass(int tmp_val) { + mCustomAudioSrsTruBass = tmp_val; + RefreshSrsEffectAndDacGain(); + return 0; } -int CTv::GetAudioSrsTruBass() -{ - return mCustomAudioSrsTruBass; +int CTv::GetAudioSrsTruBass() { + return mCustomAudioSrsTruBass; } -int CTv::GetCurAudioSrsTruBass() -{ - - return mCurAudioSrsTruBass; +int CTv::GetCurAudioSrsTruBass() { + return mCurAudioSrsTruBass; } -int CTv::SaveCurAudioSrsTruBass(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioSrsTruBass(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioSrsTruBass = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSRSTruBassSwitch(tmp_ch); + mCurAudioSrsTruBass = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioSRSTruBassSwitch(tmp_ch); - return mCurAudioSrsTruBass; + return mCurAudioSrsTruBass; } -int CTv::LoadCurAudioSrsTruBass() -{ - int8_t tmp_ch = 0; +int CTv::LoadCurAudioSrsTruBass() { + int8_t tmp_ch = 0; - SSMReadAudioSRSTruBassSwitch(&tmp_ch); - mCurAudioSrsTruBass = tmp_ch; - if (mCurAudioSrsTruBass != CC_SWITCH_ON - && mCurAudioSrsTruBass != CC_SWITCH_OFF) { - SaveCurAudioSrsTruBass (CC_SWITCH_OFF); - } - mCustomAudioSrsTruBass = mCurAudioSrsTruBass; + SSMReadAudioSRSTruBassSwitch(&tmp_ch); + mCurAudioSrsTruBass = tmp_ch; + if (mCurAudioSrsTruBass != CC_SWITCH_ON + && mCurAudioSrsTruBass != CC_SWITCH_OFF) { + SaveCurAudioSrsTruBass (CC_SWITCH_OFF); + } + mCustomAudioSrsTruBass = mCurAudioSrsTruBass; - return mCurAudioSrsTruBass; + return mCurAudioSrsTruBass; } -void CTv::RefreshSrsEffectAndDacGain() -{ - int tmp_gain_val = 0; - int surround_switch = CC_SWITCH_OFF; - int trubass_switch = CC_SWITCH_OFF; - int dialogclarity_switch = CC_SWITCH_OFF; - trubass_switch = GetAudioSrsTruBass(); - dialogclarity_switch = GetAudioSrsDialogClarity(); - surround_switch = GetAudioSRSSurround(); +void CTv::RefreshSrsEffectAndDacGain() { + int tmp_gain_val = 0; + int surround_switch = CC_SWITCH_OFF; + int trubass_switch = CC_SWITCH_OFF; + int dialogclarity_switch = CC_SWITCH_OFF; + trubass_switch = GetAudioSrsTruBass(); + dialogclarity_switch = GetAudioSrsDialogClarity(); + surround_switch = GetAudioSRSSurround(); - if (GetAudioSRSSourroundEnableCFG() == 0) { - return; - } + if (GetAudioSRSSourroundEnableCFG() == 0) { + return; + } - if (surround_switch == CC_SWITCH_ON) { - mAudioEffect.SetSrsSurroundSwitch(CC_SWITCH_ON); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.sourround.gain", 50); - mAudioEffect.SetSrsSurroundGain(tmp_gain_val); + if (surround_switch == CC_SWITCH_ON) { + mAudioEffect.SetSrsSurroundSwitch(CC_SWITCH_ON); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.sourround.gain", 50); + mAudioEffect.SetSrsSurroundGain(tmp_gain_val); - int input_gain_val = GetAudioSRSGainCfg("audio.srs.input.gain", 50); - int out_gain_val = GetAudioSRSGainCfg("audio.srs.output.gain", 50); - mAudioEffect.SetSrsInputOutputGain(input_gain_val, out_gain_val); + int input_gain_val = GetAudioSRSGainCfg("audio.srs.input.gain", 50); + int out_gain_val = GetAudioSRSGainCfg("audio.srs.output.gain", 50); + mAudioEffect.SetSrsInputOutputGain(input_gain_val, out_gain_val); - if (trubass_switch == CC_SWITCH_ON - && dialogclarity_switch == CC_SWITCH_OFF) { + if (trubass_switch == CC_SWITCH_ON + && dialogclarity_switch == CC_SWITCH_OFF) { - mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); - mAudioEffect.SetSrsTruBassGain(tmp_gain_val); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); - mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); + mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); + mAudioEffect.SetSrsTruBassGain(tmp_gain_val); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); + mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); - mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_OFF); + mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_OFF); - } else if (trubass_switch == CC_SWITCH_OFF - && dialogclarity_switch == CC_SWITCH_ON) { + } else if (trubass_switch == CC_SWITCH_OFF + && dialogclarity_switch == CC_SWITCH_ON) { - mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_ON); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); - mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); - mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); + mAudioEffect.SetSrsDialogClaritySwitch (CC_SWITCH_ON); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); + mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); + mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); - mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); + mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); - } else if (trubass_switch == CC_SWITCH_ON - && dialogclarity_switch == CC_SWITCH_ON) { + } else if (trubass_switch == CC_SWITCH_ON + && dialogclarity_switch == CC_SWITCH_ON) { - mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); - mAudioEffect.SetSrsTruBassGain(tmp_gain_val); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); - mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); + mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_ON); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.gain", 50); + mAudioEffect.SetSrsTruBassGain(tmp_gain_val); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.trubass.speakersize", 2); + mAudioEffect.SetSrsTrubassSpeakerSize(tmp_gain_val); - mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_ON); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); - mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); - tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); - mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); + mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_ON); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.dialogclarity.gain", 30); + mAudioEffect.SetSrsDialogClarityGain(tmp_gain_val); + tmp_gain_val = GetAudioSRSGainCfg("audio.srs.definition.gain", 20); + mAudioEffect.SetSrsDefinitionGain(tmp_gain_val); - } else if (trubass_switch == CC_SWITCH_OFF - && dialogclarity_switch == CC_SWITCH_OFF) { - mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); - mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); - } - SetSupperBassSRSSpeakerSize(); - } else { - mAudioEffect.SetSrsSurroundSwitch (CC_SWITCH_OFF); - mAudioEffect.SetSrsTruBassSwitch(CC_SWITCH_OFF); - mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); - } - //Refesh DAC gain - int main_gain_val = 0; - if (surround_switch == CC_SWITCH_ON) { - main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.sourround.ampmaster.gain", 6, 24); - if (dialogclarity_switch == CC_SWITCH_ON - && trubass_switch == CC_SWITCH_OFF) { - main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.dialogclarity.ampmaster.gain", 6, 24); - } else if (dialogclarity_switch == CC_SWITCH_OFF - && trubass_switch == CC_SWITCH_ON) { - main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.ampmaster.gain", 6, 24); - } else if (dialogclarity_switch == CC_SWITCH_ON - && trubass_switch == CC_SWITCH_ON) { - main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.dialogclarity.ampmaster.gain", 6, 24); - } - } - mAudioAlsa.SetMainVolumeGain(main_gain_val); + } else if (trubass_switch == CC_SWITCH_OFF + && dialogclarity_switch == CC_SWITCH_OFF) { + mAudioEffect.SetSrsTruBassSwitch (CC_SWITCH_OFF); + mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); + } + SetSupperBassSRSSpeakerSize(); + } else { + mAudioEffect.SetSrsSurroundSwitch (CC_SWITCH_OFF); + mAudioEffect.SetSrsTruBassSwitch(CC_SWITCH_OFF); + mAudioEffect.SetSrsDialogClaritySwitch(CC_SWITCH_OFF); + } + //Refesh DAC gain + int main_gain_val = 0; + if (surround_switch == CC_SWITCH_ON) { + main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.sourround.ampmaster.gain", 6, 24); + if (dialogclarity_switch == CC_SWITCH_ON + && trubass_switch == CC_SWITCH_OFF) { + main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.dialogclarity.ampmaster.gain", 6, 24); + } else if (dialogclarity_switch == CC_SWITCH_OFF + && trubass_switch == CC_SWITCH_ON) { + main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.ampmaster.gain", 6, 24); + } else if (dialogclarity_switch == CC_SWITCH_ON + && trubass_switch == CC_SWITCH_ON) { + main_gain_val = GetAudioEffectAmplifierGainCfg("audio.srs.trubass.dialogclarity.ampmaster.gain", 6, 24); + } + } + mAudioAlsa.SetMainVolumeGain(main_gain_val); } -int CTv::SetAudioBassVolume(int tmp_vol) -{ - int nMinBassVol = 0, nMaxBassVol = 0; - - nMinBassVol = GetBassUIMinGainVal(); - nMaxBassVol = GetBassUIMaxGainVal(); +int CTv::SetAudioBassVolume(int tmp_vol) { + int nMinBassVol = 0, nMaxBassVol = 0; - if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { - tmp_vol = (nMaxBassVol + nMinBassVol) / 2; - } + nMinBassVol = GetBassUIMinGainVal(); + nMaxBassVol = GetBassUIMaxGainVal(); - mCustomAudioBassVolume = tmp_vol; + if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { + tmp_vol = (nMaxBassVol + nMinBassVol) / 2; + } - tmp_vol = MappingTrebleBassAndEqualizer(GetAudioBassVolume(), 0, - nMinBassVol, nMaxBassVol); - - return SetSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); + mCustomAudioBassVolume = tmp_vol; + tmp_vol = MappingTrebleBassAndEqualizer(GetAudioBassVolume(), 0, + nMinBassVol, nMaxBassVol); + return SetSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); } -int CTv::GetAudioBassVolume() -{ - return mCustomAudioBassVolume; +int CTv::GetAudioBassVolume() { + return mCustomAudioBassVolume; } -int CTv::GetCurAudioBassVolume() -{ - return mCurAudioBassVolume; +int CTv::GetCurAudioBassVolume() { + return mCurAudioBassVolume; } -int CTv::SaveCurAudioBassVolume(int tmp_vol) -{ - int nMinBassVol = 0, nMaxBassVol = 0; - - nMinBassVol = GetBassUIMinGainVal(); - nMaxBassVol = GetBassUIMaxGainVal(); +int CTv::SaveCurAudioBassVolume(int tmp_vol) { + int nMinBassVol = 0, nMaxBassVol = 0; - if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { - tmp_vol = (nMaxBassVol + nMinBassVol) / 2; - } + nMinBassVol = GetBassUIMinGainVal(); + nMaxBassVol = GetBassUIMaxGainVal(); - RealSaveCurAudioBassVolume(tmp_vol, 1); + if (tmp_vol < nMinBassVol || tmp_vol > nMaxBassVol) { + tmp_vol = (nMaxBassVol + nMinBassVol) / 2; + } - tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioBassVolume(), 0, - nMinBassVol, nMaxBassVol); + RealSaveCurAudioBassVolume(tmp_vol, 1); - return SaveSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); + tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioBassVolume(), 0, + nMinBassVol, nMaxBassVol); + return SaveSpecialIndexEQGain(CC_EQ_BASS_IND, tmp_vol); } -int CTv::RealSaveCurAudioBassVolume(int tmp_vol, int sound_mode_judge) -{ - int8_t tmp_ch = 0; - mCurAudioBassVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioBassVolume(tmp_ch); +int CTv::RealSaveCurAudioBassVolume(int tmp_vol, int sound_mode_judge) { + int8_t tmp_ch = 0; + mCurAudioBassVolume = tmp_vol; + tmp_ch = tmp_vol; + SSMSaveAudioBassVolume(tmp_ch); - if (sound_mode_judge == 1) { - if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { - SaveCurAudioSoundMode (CC_SOUND_MODE_USER); - mCustomAudioSoundMode = mCurAudioSoundMode; - } - } - - return mCurAudioBassVolume; + if (sound_mode_judge == 1) { + if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { + SaveCurAudioSoundMode (CC_SOUND_MODE_USER); + mCustomAudioSoundMode = mCurAudioSoundMode; + } + } + return mCurAudioBassVolume; } -int CTv::LoadCurAudioBassVolume() -{ - int nMinBassVol = 0, nMaxBassVol = 0; - int8_t tmp_ch = 0; - - nMinBassVol = GetBassUIMinGainVal(); - nMaxBassVol = GetBassUIMaxGainVal(); +int CTv::LoadCurAudioBassVolume() { + int nMinBassVol = 0, nMaxBassVol = 0; + int8_t tmp_ch = 0; - SSMReadAudioBassVolume(&tmp_ch); - mCurAudioBassVolume = tmp_ch; - if (mCurAudioBassVolume < nMinBassVol - || mCurAudioBassVolume > nMaxBassVol) { - RealSaveCurAudioBassVolume((nMaxBassVol + nMinBassVol) / 2, 0); - } + nMinBassVol = GetBassUIMinGainVal(); + nMaxBassVol = GetBassUIMaxGainVal(); - mCustomAudioBassVolume = mCurAudioBassVolume; + SSMReadAudioBassVolume(&tmp_ch); + mCurAudioBassVolume = tmp_ch; + if (mCurAudioBassVolume < nMinBassVol + || mCurAudioBassVolume > nMaxBassVol) { + RealSaveCurAudioBassVolume((nMaxBassVol + nMinBassVol) / 2, 0); + } - return mCurAudioBassVolume; + mCustomAudioBassVolume = mCurAudioBassVolume; + return mCurAudioBassVolume; } -int CTv::SetAudioTrebleVolume(int tmp_vol) -{ - int nMinTrebleVol = 0, nMaxTrebleVol = 0; +int CTv::SetAudioTrebleVolume(int tmp_vol) { + int nMinTrebleVol = 0, nMaxTrebleVol = 0; - nMinTrebleVol = GetTrebleUIMinGainVal(); - nMaxTrebleVol = GetTrebleUIMaxGainVal(); + nMinTrebleVol = GetTrebleUIMinGainVal(); + nMaxTrebleVol = GetTrebleUIMaxGainVal(); - if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { - tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; - } + if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { + tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; + } - mCustomAudioTrebleVolume = tmp_vol; + mCustomAudioTrebleVolume = tmp_vol; - tmp_vol = MappingTrebleBassAndEqualizer(GetAudioTrebleVolume(), 0, - nMinTrebleVol, nMaxTrebleVol); - - return SetSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); + tmp_vol = MappingTrebleBassAndEqualizer(GetAudioTrebleVolume(), 0, + nMinTrebleVol, nMaxTrebleVol); + return SetSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); } -int CTv::GetAudioTrebleVolume() -{ - return mCustomAudioTrebleVolume; +int CTv::GetAudioTrebleVolume() { + return mCustomAudioTrebleVolume; } -int CTv::GetCurAudioTrebleVolume() -{ - return mCurAudioTrebleVolume; +int CTv::GetCurAudioTrebleVolume() { + return mCurAudioTrebleVolume; } -int CTv::SaveCurAudioTrebleVolume(int tmp_vol) -{ - int nMinTrebleVol = 0, nMaxTrebleVol = 0; - - nMinTrebleVol = GetTrebleUIMinGainVal(); - nMaxTrebleVol = GetTrebleUIMaxGainVal(); +int CTv::SaveCurAudioTrebleVolume(int tmp_vol) { + int nMinTrebleVol = 0, nMaxTrebleVol = 0; - if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { - tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; - } + nMinTrebleVol = GetTrebleUIMinGainVal(); + nMaxTrebleVol = GetTrebleUIMaxGainVal(); - RealSaveCurAudioTrebleVolume(tmp_vol, 1); + if (tmp_vol < nMinTrebleVol || tmp_vol > nMaxTrebleVol) { + tmp_vol = (nMaxTrebleVol + nMinTrebleVol) / 2; + } - tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioTrebleVolume(), 0, - nMinTrebleVol, nMaxTrebleVol); + RealSaveCurAudioTrebleVolume(tmp_vol, 1); - return SaveSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); + tmp_vol = MappingTrebleBassAndEqualizer(GetCurAudioTrebleVolume(), 0, + nMinTrebleVol, nMaxTrebleVol); + return SaveSpecialIndexEQGain(CC_EQ_TREBLE_IND, tmp_vol); } -int CTv::RealSaveCurAudioTrebleVolume(int tmp_vol, int sound_mode_judge) -{ - int8_t tmp_ch = 0; - mCurAudioTrebleVolume = tmp_vol; - tmp_ch = tmp_vol; - SSMSaveAudioTrebleVolume(tmp_ch); +int CTv::RealSaveCurAudioTrebleVolume(int tmp_vol, int sound_mode_judge) { + int8_t tmp_ch = 0; + mCurAudioTrebleVolume = tmp_vol; + tmp_ch = tmp_vol; + SSMSaveAudioTrebleVolume(tmp_ch); - if (sound_mode_judge == 1) { - if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { - SaveCurAudioSoundMode (CC_SOUND_MODE_USER); - mCustomAudioSoundMode = mCurAudioSoundMode; - } - } + if (sound_mode_judge == 1) { + if (GetAudioSoundMode() != CC_SOUND_MODE_USER) { + SaveCurAudioSoundMode (CC_SOUND_MODE_USER); + mCustomAudioSoundMode = mCurAudioSoundMode; + } + } - return mCurAudioTrebleVolume; + return mCurAudioTrebleVolume; } -int CTv::LoadCurAudioTrebleVolume() -{ - int nMinTrebleVol = 0, nMaxTrebleVol = 0; - int8_t tmp_ch = 0; - - nMinTrebleVol = GetTrebleUIMinGainVal(); - nMaxTrebleVol = GetTrebleUIMaxGainVal(); +int CTv::LoadCurAudioTrebleVolume() { + int nMinTrebleVol = 0, nMaxTrebleVol = 0; + int8_t tmp_ch = 0; - SSMReadAudioTrebleVolume(&tmp_ch); - mCurAudioTrebleVolume = tmp_ch; - if (mCurAudioTrebleVolume < nMinTrebleVol - || mCurAudioTrebleVolume > nMaxTrebleVol) { - RealSaveCurAudioTrebleVolume((nMaxTrebleVol + nMinTrebleVol) / 2, 0); - } + nMinTrebleVol = GetTrebleUIMinGainVal(); + nMaxTrebleVol = GetTrebleUIMaxGainVal(); - mCustomAudioTrebleVolume = mCurAudioTrebleVolume; + SSMReadAudioTrebleVolume(&tmp_ch); + mCurAudioTrebleVolume = tmp_ch; + if (mCurAudioTrebleVolume < nMinTrebleVol + || mCurAudioTrebleVolume > nMaxTrebleVol) { + RealSaveCurAudioTrebleVolume((nMaxTrebleVol + nMinTrebleVol) / 2, 0); + } - return mCurAudioTrebleVolume; + mCustomAudioTrebleVolume = mCurAudioTrebleVolume; + return mCurAudioTrebleVolume; } -int CTv::SetAudioSoundMode(int tmp_val) -{ - mCustomAudioSoundMode = tmp_val; - SetSpecialModeEQGain(mCustomAudioSoundMode); +int CTv::SetAudioSoundMode(int tmp_val) { + mCustomAudioSoundMode = tmp_val; + SetSpecialModeEQGain(mCustomAudioSoundMode); - HandleTrebleBassVolume(); - - return 0; + HandleTrebleBassVolume(); + return 0; } -int CTv::GetAudioSoundMode() -{ - return mCustomAudioSoundMode; +int CTv::GetAudioSoundMode() { + return mCustomAudioSoundMode; } -int CTv::GetCurAudioSoundMode() -{ - return mCurAudioSoundMode; +int CTv::GetCurAudioSoundMode() { + return mCurAudioSoundMode; } -int CTv::SaveCurAudioSoundMode(int tmp_val) -{ - int8_t tmp_ch = 0; - - mCurAudioSoundMode = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioSoundModeVal(tmp_ch); - - return mCurAudioSoundMode; +int CTv::SaveCurAudioSoundMode(int tmp_val) { + mCurAudioSoundMode = tmp_val; + SSMSaveAudioSoundModeVal(tmp_val); + return tmp_val; } -int CTv::LoadCurAudioSoundMode() -{ - int8_t tmp_ch = 0; - SSMReadAudioSoundModeVal(&tmp_ch); - mCurAudioSoundMode = tmp_ch; - if (mCurAudioSoundMode < CC_SOUND_MODE_START - || mCurAudioSoundMode > CC_SOUND_MODE_END) { - SaveCurAudioSoundMode (CC_SOUND_MODE_STD); - } - mCustomAudioSoundMode = mCurAudioSoundMode; - - return mCurAudioSoundMode; +int CTv::LoadCurAudioSoundMode() { + int8_t tmp_ch = 0; + SSMReadAudioSoundModeVal(&tmp_ch); + mCurAudioSoundMode = tmp_ch; + if (mCurAudioSoundMode < CC_SOUND_MODE_START + || mCurAudioSoundMode > CC_SOUND_MODE_END) { + SaveCurAudioSoundMode (CC_SOUND_MODE_STD); + } + mCustomAudioSoundMode = mCurAudioSoundMode; + return mCurAudioSoundMode; } -int CTv::HandleTrebleBassVolume() -{ - int tmp_vol = 0; - int tmpEQGainBuf[128] = { 0 }; - int8_t tmp_ch = 0; +int CTv::HandleTrebleBassVolume() { + int tmp_vol = 0; + int tmpEQGainBuf[128] = { 0 }; + int8_t tmp_ch = 0; - GetCustomEQGain(tmpEQGainBuf); + GetCustomEQGain(tmpEQGainBuf); - tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_TREBLE_IND], 1, - GetTrebleUIMinGainVal(), GetTrebleUIMaxGainVal()); - mCustomAudioTrebleVolume = tmp_vol; - mCurAudioTrebleVolume = mCustomAudioTrebleVolume; - tmp_ch = mCustomAudioTrebleVolume; - SSMSaveAudioTrebleVolume(tmp_ch); + tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_TREBLE_IND], 1, + GetTrebleUIMinGainVal(), GetTrebleUIMaxGainVal()); + mCustomAudioTrebleVolume = tmp_vol; + mCurAudioTrebleVolume = mCustomAudioTrebleVolume; + tmp_ch = mCustomAudioTrebleVolume; + SSMSaveAudioTrebleVolume(tmp_ch); - tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_BASS_IND], 1, - GetBassUIMinGainVal(), GetBassUIMaxGainVal()); - mCustomAudioBassVolume = tmp_vol; - mCurAudioBassVolume = mCustomAudioBassVolume; - tmp_ch = mCustomAudioBassVolume; - SSMSaveAudioBassVolume(tmp_ch); - - return 0; + tmp_vol = MappingTrebleBassAndEqualizer(tmpEQGainBuf[CC_EQ_BASS_IND], 1, + GetBassUIMinGainVal(), GetBassUIMaxGainVal()); + mCustomAudioBassVolume = tmp_vol; + mCurAudioBassVolume = mCustomAudioBassVolume; + tmp_ch = mCustomAudioBassVolume; + SSMSaveAudioBassVolume(tmp_ch); + return 0; } -int CTv::SetAudioWallEffect(int tmp_val) -{ - int tmp_treble_val; - int tmp_type = 0; +int CTv::SetAudioWallEffect(int tmp_val) { + int tmp_treble_val; + int tmp_type = 0; - mCustomAudioWallEffect = tmp_val; + mCustomAudioWallEffect = tmp_val; - tmp_type = GetAudioWallEffectTypeCfg(); - if (tmp_type == 0) { - SetCustomEQGain(); - } else if (tmp_type == 1) { - int aud_arch_type = GetAudioArchitectureTypeCFG(); - if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { - return 0; - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { - mAudioAlsa.SetExternalDacEQMode(tmp_val); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_EQ_MODE, tmp_val); - } - } - return 0; + tmp_type = GetAudioWallEffectTypeCfg(); + if (tmp_type == 0) { + SetCustomEQGain(); + } else if (tmp_type == 1) { + int aud_arch_type = GetAudioArchitectureTypeCFG(); + if (aud_arch_type == CC_DAC_G9TV_INTERNAL_DAC) { + return 0; + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { + mAudioAlsa.SetExternalDacEQMode(tmp_val); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_EQ_MODE, tmp_val); + } + } + return 0; } -int CTv::GetAudioWallEffect() -{ - return mCustomAudioWallEffect; +int CTv::GetAudioWallEffect() { + return mCustomAudioWallEffect; } -int CTv::GetCurAudioWallEffect() -{ - return mCurAudioWallEffect; +int CTv::GetCurAudioWallEffect() { + return mCurAudioWallEffect; } -int CTv::SaveCurAudioWallEffect(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioWallEffect(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioWallEffect = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioWallEffectSwitch(tmp_ch); + mCurAudioWallEffect = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioWallEffectSwitch(tmp_ch); - return mCurAudioWallEffect; + return mCurAudioWallEffect; } -int CTv::LoadCurAudioWallEffect() -{ - int8_t tmp_ch = 0; - SSMReadAudioWallEffectSwitch(&tmp_ch); - mCurAudioWallEffect = tmp_ch; - if (mCurAudioWallEffect != CC_SWITCH_ON - && mCurAudioWallEffect != CC_SWITCH_OFF) { - SaveCurAudioWallEffect (CC_SWITCH_OFF); - } - - mCustomAudioWallEffect = mCurAudioWallEffect; +int CTv::LoadCurAudioWallEffect() { + int8_t tmp_ch = 0; + SSMReadAudioWallEffectSwitch(&tmp_ch); + mCurAudioWallEffect = tmp_ch; + if (mCurAudioWallEffect != CC_SWITCH_ON + && mCurAudioWallEffect != CC_SWITCH_OFF) { + SaveCurAudioWallEffect (CC_SWITCH_OFF); + } - return mCurAudioWallEffect; + mCustomAudioWallEffect = mCurAudioWallEffect; + return mCurAudioWallEffect; } - -int CTv::SetAudioEQMode(int tmp_val) -{ - mCustomAudioEQMode = tmp_val; - - return 0; +int CTv::SetAudioEQMode(int tmp_val) { + mCustomAudioEQMode = tmp_val; + return 0; } -int CTv::GetAudioEQMode() -{ - return mCustomAudioEQMode; +int CTv::GetAudioEQMode() { + return mCustomAudioEQMode; } -int CTv::GetCurAudioEQMode() -{ - return mCurAudioEQMode; +int CTv::GetCurAudioEQMode() { + return mCurAudioEQMode; } -int CTv::SaveCurAudioEQMode(int tmp_val) -{ - int8_t tmp_ch = 0; +int CTv::SaveCurAudioEQMode(int tmp_val) { + int8_t tmp_ch = 0; - mCurAudioEQMode = tmp_val; - tmp_ch = tmp_val; - SSMSaveAudioEQModeVal(tmp_ch); + mCurAudioEQMode = tmp_val; + tmp_ch = tmp_val; + SSMSaveAudioEQModeVal(tmp_ch); - return tmp_val; + return tmp_val; } -int CTv::LoadCurAudioEQMode() -{ - int8_t tmp_ch = 0; - SSMReadAudioEQModeVal(&tmp_ch); - mCurAudioEQMode = tmp_ch; - if (mCurAudioEQMode < CC_EQ_MODE_START - || mCurAudioEQMode > CC_EQ_MODE_END) { - SaveCurAudioEQMode (CC_EQ_MODE_START); - } - mCustomAudioEQMode = mCurAudioEQMode; +int CTv::LoadCurAudioEQMode() { + int8_t tmp_ch = 0; + SSMReadAudioEQModeVal(&tmp_ch); + mCurAudioEQMode = tmp_ch; + if (mCurAudioEQMode < CC_EQ_MODE_START + || mCurAudioEQMode > CC_EQ_MODE_END) { + SaveCurAudioEQMode (CC_EQ_MODE_START); + } + mCustomAudioEQMode = mCurAudioEQMode; - return mCurAudioEQMode; + return mCurAudioEQMode; } -int CTv::GetAudioEQRange(int range_buf[]) -{ - range_buf[0] = CC_MIN_EQ_GAIN_VAL; - range_buf[1] = CC_MAX_EQ_GAIN_VAL; - return 0; +int CTv::GetAudioEQRange(int range_buf[]) { + range_buf[0] = CC_MIN_EQ_GAIN_VAL; + range_buf[1] = CC_MAX_EQ_GAIN_VAL; + return 0; } -int CTv::GetAudioEQBandCount() -{ - return mAudioEffect.GetEQBandCount(); +int CTv::GetAudioEQBandCount() { + return mAudioEffect.GetEQBandCount(); } -int CTv::SetAudioEQGain(int gain_buf[]) -{ - return AudioSetEQGain(gain_buf); +int CTv::SetAudioEQGain(int gain_buf[]) { + return AudioSetEQGain(gain_buf); } -int CTv::GetAudioEQGain(int gain_buf[]) -{ - return GetCustomEQGain(gain_buf); +int CTv::GetAudioEQGain(int gain_buf[]) { + return GetCustomEQGain(gain_buf); } -int CTv::GetCurAudioEQGain(int gain_buf[]) -{ - RealReadCurAudioEQGain(gain_buf); - return 0; +int CTv::GetCurAudioEQGain(int gain_buf[]) { + RealReadCurAudioEQGain(gain_buf); + return 0; } -int CTv::SaveCurAudioEQGain(int gain_buf[]) -{ - return RealSaveCurAudioEQGain(gain_buf, 1); +int CTv::SaveCurAudioEQGain(int gain_buf[]) { + return RealSaveCurAudioEQGain(gain_buf, 1); } -int CTv::RealReadCurAudioEQGain(int gain_buf[]) -{ - ArrayCopy(gain_buf, mCurEQGainBuf, GetAudioEQBandCount()); - return 0; +int CTv::RealReadCurAudioEQGain(int gain_buf[]) { + ArrayCopy(gain_buf, mCurEQGainBuf, GetAudioEQBandCount()); + return 0; } -int CTv::RealSaveCurAudioEQGain(int gain_buf[], int sound_mode_judge) -{ - ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); - ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); - SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); +int CTv::RealSaveCurAudioEQGain(int gain_buf[], int sound_mode_judge) { + ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); + ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); + SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); - if (sound_mode_judge == 1) { - HandleTrebleBassVolume(); - SaveCurAudioSoundMode (CC_SOUND_MODE_USER); - mCustomAudioSoundMode = mCurAudioSoundMode; - } + if (sound_mode_judge == 1) { + HandleTrebleBassVolume(); + SaveCurAudioSoundMode (CC_SOUND_MODE_USER); + mCustomAudioSoundMode = mCurAudioSoundMode; + } - return 0; + return 0; } -int CTv::LoadCurAudioEQGain() -{ - int i = 0; +int CTv::LoadCurAudioEQGain() { + int i = 0; - SSMReadAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); - ArrayCopy(mCurEQGainBuf, mCurEQGainChBuf, GetAudioEQBandCount()); + SSMReadAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); + ArrayCopy(mCurEQGainBuf, mCurEQGainChBuf, GetAudioEQBandCount()); - for (i = 0; i < GetAudioEQBandCount(); i++) { - if (mCurEQGainBuf[i] & 0x80) { - mCurEQGainBuf[i] = mCurEQGainBuf[i] - 256; - } - } - - return 0; + for (i = 0; i < GetAudioEQBandCount(); i++) { + if (mCurEQGainBuf[i] & 0x80) { + mCurEQGainBuf[i] = mCurEQGainBuf[i] - 256; + } + } + return 0; } -int CTv::SetAudioEQSwitch(int switch_val) -{ - return mAudioEffect.SetEQSwitch(switch_val); +int CTv::SetAudioEQSwitch(int switch_val) { + return mAudioEffect.SetEQSwitch(switch_val); } -int CTv::SetDbxTvMode(int mode, int son_value, int vol_value, int sur_value) -{ - return mAudioEffect.DbxTv_SetMode(mode, son_value, vol_value, sur_value); +int CTv::SetDbxTvMode(int mode, int son_value, int vol_value, int sur_value) { + return mAudioEffect.DbxTv_SetMode(mode, son_value, vol_value, sur_value); } -int CTv::GetBassUIMinGainVal() -{ - return 0; +int CTv::GetBassUIMinGainVal() { + return 0; } -int CTv::GetBassUIMaxGainVal() -{ - return 100; +int CTv::GetBassUIMaxGainVal() { + return 100; } -int CTv::GetTrebleUIMinGainVal() -{ - return 0; + +int CTv::GetTrebleUIMinGainVal() { + return 0; } -int CTv::GetTrebleUIMaxGainVal() -{ - return 100; +int CTv::GetTrebleUIMaxGainVal() { + return 100; } -int CTv::MappingLine(int map_val, int src_min, int src_max, int dst_min, - int dst_max) -{ - if (dst_min < 0) { - return (map_val - (src_max + src_min) / 2) * (dst_max - dst_min) - / (src_max - src_min); - } else { - return (map_val - src_min) * (dst_max - dst_min) / (src_max - src_min); - } +int CTv::MappingLine(int map_val, int src_min, int src_max, int dst_min, int dst_max) { + if (dst_min < 0) { + return (map_val - (src_max + src_min) / 2) * (dst_max - dst_min) + / (src_max - src_min); + } else { + return (map_val - src_min) * (dst_max - dst_min) / (src_max - src_min); + } } -int CTv::MappingTrebleBassAndEqualizer(int tmp_vol, int direct, int tb_min, - int tb_max) -{ - int tmp_ret = 0; +int CTv::MappingTrebleBassAndEqualizer(int tmp_vol, int direct, int tb_min, int tb_max) { + int tmp_ret = 0; - if (direct == 0) { - tmp_ret = MappingLine(tmp_vol, tb_min, tb_max, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN); - } else { - tmp_ret = MappingLine(tmp_vol, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN, tb_min, tb_max); - } + if (direct == 0) { + tmp_ret = MappingLine(tmp_vol, tb_min, tb_max, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN); + } else { + tmp_ret = MappingLine(tmp_vol, CC_EQ_DEF_UI_MIN_GAIN, CC_EQ_DEF_UI_MAX_GAIN, tb_min, tb_max); + } - LOGD("%s, tmp_vol = %d, direct = %d, tmp_ret = %d\n", __FUNCTION__, tmp_vol, - direct, tmp_ret); + LOGD("%s, tmp_vol = %d, direct = %d, tmp_ret = %d\n", __FUNCTION__, tmp_vol, + direct, tmp_ret); - return tmp_ret; + return tmp_ret; } -int CTv::MappingEQGain(int src_gain_buf[], int dst_gain_buf[], int direct) -{ - int i = 0; - int nMinUIVal = 0, nMaxUIVal = 0, nMinVal = 0, nMaxVal = 0; +int CTv::MappingEQGain(int src_gain_buf[], int dst_gain_buf[], int direct) { + int i = 0; + int nMinUIVal = 0, nMaxUIVal = 0, nMinVal = 0, nMaxVal = 0; - nMinUIVal = CC_EQ_DEF_UI_MIN_GAIN; - nMaxUIVal = CC_EQ_DEF_UI_MAX_GAIN; - nMinVal = CC_MIN_EQ_GAIN_VAL; - nMaxVal = CC_MAX_EQ_GAIN_VAL; + nMinUIVal = CC_EQ_DEF_UI_MIN_GAIN; + nMaxUIVal = CC_EQ_DEF_UI_MAX_GAIN; + nMinVal = CC_MIN_EQ_GAIN_VAL; + nMaxVal = CC_MAX_EQ_GAIN_VAL; - if (nMinUIVal >= nMinVal && nMaxUIVal <= nMaxVal) { - for (i = 0; i < GetAudioEQBandCount(); i++) { - dst_gain_buf[i] = src_gain_buf[i]; - } - } else { - for (i = 0; i < GetAudioEQBandCount(); i++) { - if (direct == 0) { - dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinUIVal, - nMaxUIVal, nMinVal, nMaxVal); - } else { - dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinVal, nMaxVal, - nMinUIVal, nMaxUIVal); - } - } - } - - return 0; + if (nMinUIVal >= nMinVal && nMaxUIVal <= nMaxVal) { + for (i = 0; i < GetAudioEQBandCount(); i++) { + dst_gain_buf[i] = src_gain_buf[i]; + } + } else { + for (i = 0; i < GetAudioEQBandCount(); i++) { + if (direct == 0) { + dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinUIVal, + nMaxUIVal, nMinVal, nMaxVal); + } else { + dst_gain_buf[i] = MappingLine(src_gain_buf[i], nMinVal, nMaxVal, + nMinUIVal, nMaxUIVal); + } + } + } + return 0; } -int CTv::RestoreToAudioDefEQGain(int gain_buf[]) -{ - int i = 0; - - for (i = 0; i < GetAudioEQBandCount(); i++) { - gain_buf[i] = (CC_EQ_DEF_UI_MAX_GAIN + CC_EQ_DEF_UI_MIN_GAIN) / 2; - } +int CTv::RestoreToAudioDefEQGain(int gain_buf[]) { + int i = 0; - ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); - ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); - SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); + for (i = 0; i < GetAudioEQBandCount(); i++) { + gain_buf[i] = (CC_EQ_DEF_UI_MAX_GAIN + CC_EQ_DEF_UI_MIN_GAIN) / 2; + } - HandleTrebleBassVolume(); - SaveCurAudioSoundMode (CC_SOUND_MODE_STD); - mCustomAudioSoundMode = mCurAudioSoundMode; + ArrayCopy(mCurEQGainBuf, gain_buf, GetAudioEQBandCount()); + ArrayCopy(mCurEQGainChBuf, gain_buf, GetAudioEQBandCount()); + SSMSaveAudioEQGain(0, GetAudioEQBandCount(), mCurEQGainChBuf); - return 0; + HandleTrebleBassVolume(); + SaveCurAudioSoundMode (CC_SOUND_MODE_STD); + mCustomAudioSoundMode = mCurAudioSoundMode; + return 0; } -int CTv::GetCustomEQGain(int gain_buf[]) -{ - ArrayCopy(gain_buf, mCustomEQGainBuf, GetAudioEQBandCount()); - return 0; +int CTv::GetCustomEQGain(int gain_buf[]) { + ArrayCopy(gain_buf, mCustomEQGainBuf, GetAudioEQBandCount()); + return 0; } -int CTv::SetCustomEQGain() -{ - int tmpEQGainBuf[128] = { 0 }; +int CTv::SetCustomEQGain() { + int tmpEQGainBuf[128] = { 0 }; - if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { - return -1; - } + if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { + return -1; + } - return RealSetEQGain(tmpEQGainBuf); + return RealSetEQGain(tmpEQGainBuf); } -int CTv::AudioSetEQGain(int gain_buf[]) -{ - int tmpEQGainBuf[128] = { 0 }; +int CTv::AudioSetEQGain(int gain_buf[]) { + int tmpEQGainBuf[128] = { 0 }; - ArrayCopy(mCustomEQGainBuf, gain_buf, GetAudioEQBandCount()); + ArrayCopy(mCustomEQGainBuf, gain_buf, GetAudioEQBandCount()); - if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { - return -1; - } + if (MappingEQGain(mCustomEQGainBuf, tmpEQGainBuf, 0) < 0) { + return -1; + } - return RealSetEQGain(tmpEQGainBuf); + return RealSetEQGain(tmpEQGainBuf); } -int CTv::handleEQGainBeforeSet(int src_buf[], int dst_buf[]) -{ - int i = 0, nMinGain, nMaxGain; +int CTv::handleEQGainBeforeSet(int src_buf[], int dst_buf[]) { + int i = 0, nMinGain, nMaxGain; - nMinGain = CC_MIN_EQ_GAIN_VAL; - nMaxGain = CC_MAX_EQ_GAIN_VAL; + nMinGain = CC_MIN_EQ_GAIN_VAL; + nMaxGain = CC_MAX_EQ_GAIN_VAL; - if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { - for (i = 0; i < GetAudioEQBandCount(); i++) { - dst_buf[i] = mWallEffectValueBuf[i] + src_buf[i]; + if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { + for (i = 0; i < GetAudioEQBandCount(); i++) { + dst_buf[i] = mWallEffectValueBuf[i] + src_buf[i]; - if (dst_buf[i] < nMinGain) { - dst_buf[i] = nMinGain; - } + if (dst_buf[i] < nMinGain) { + dst_buf[i] = nMinGain; + } - if (dst_buf[i] > nMaxGain) { - dst_buf[i] = nMaxGain; - } - } - } else { - for (i = 0; i < GetAudioEQBandCount(); i++) { - dst_buf[i] = src_buf[i]; - } - } + if (dst_buf[i] > nMaxGain) { + dst_buf[i] = nMaxGain; + } + } + } else { + for (i = 0; i < GetAudioEQBandCount(); i++) { + dst_buf[i] = src_buf[i]; + } + } - return 0; + return 0; } -int CTv::RealSetEQGain(int gain_buf[]) -{ - - if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { - for (int i = 0; i < GetAudioEQBandCount(); i++) { - gain_buf[i] = mWallEffectValueBuf[i] + gain_buf[i]; - - if (gain_buf[i] < CC_MIN_EQ_GAIN_VAL) { - gain_buf[i] = CC_MIN_EQ_GAIN_VAL; - } +int CTv::RealSetEQGain(int gain_buf[]) { + if (GetAudioWallEffect() == CC_SWITCH_ON && GetAudioWallEffectTypeCfg() == 0) { + for (int i = 0; i < GetAudioEQBandCount(); i++) { + gain_buf[i] = mWallEffectValueBuf[i] + gain_buf[i]; - if (gain_buf[i] > CC_MAX_EQ_GAIN_VAL) { - gain_buf[i] = CC_MAX_EQ_GAIN_VAL; - } - } - } + if (gain_buf[i] < CC_MIN_EQ_GAIN_VAL) { + gain_buf[i] = CC_MIN_EQ_GAIN_VAL; + } - mAudioEffect.SetEQValue(gain_buf); + if (gain_buf[i] > CC_MAX_EQ_GAIN_VAL) { + gain_buf[i] = CC_MAX_EQ_GAIN_VAL; + } + } + } - return 0; + mAudioEffect.SetEQValue(gain_buf); + return 0; } -int CTv::SetAtvInGain(int gain_val) -{ - int ret = -1; +int CTv::SetAtvInGain(int gain_val) { + char set_str[32] = {0}; - char set_str[32]; - memset ( set_str, 0, 32 ); - - sprintf ( set_str, "audio_gain_set %x", gain_val ); - - return SetFileAttrValue ( "/sys/class/amlatvdemod/atvdemod_debug", set_str ); + sprintf ( set_str, "audio_gain_set %x", gain_val ); + return SetFileAttrValue ( "/sys/class/amlatvdemod/atvdemod_debug", set_str ); } +int CTv::SetSpecialModeEQGain(int tmp_val) { + int i = 0; + int tmpEQPresetBufPtr[24]; + if (GetAudioEQPresetBufferPtr(tmpEQPresetBufPtr) != 0) { + GetDefault_EQGain_Table(tmpEQPresetBufPtr); + } + int tmpEQGainBuf[128] = { 0 }; -int CTv::SetSpecialModeEQGain(int tmp_val) -{ - int i = 0; - int tmpEQPresetBufPtr[24]; - if (GetAudioEQPresetBufferPtr(tmpEQPresetBufPtr) != 0) { - GetDefault_EQGain_Table(tmpEQPresetBufPtr); - } - int tmpEQGainBuf[128] = { 0 }; - - if (tmp_val == CC_SOUND_MODE_USER) { - RealReadCurAudioEQGain(tmpEQGainBuf); - } else { - ArrayCopy(tmpEQGainBuf, - tmpEQPresetBufPtr + tmp_val * GetAudioEQBandCount(), - GetAudioEQBandCount()); - } + if (tmp_val == CC_SOUND_MODE_USER) { + RealReadCurAudioEQGain(tmpEQGainBuf); + } else { + ArrayCopy(tmpEQGainBuf, + tmpEQPresetBufPtr + tmp_val * GetAudioEQBandCount(), + GetAudioEQBandCount()); + } - AudioSetEQGain(tmpEQGainBuf); - - return tmp_val; + AudioSetEQGain(tmpEQGainBuf); + return tmp_val; } -int CTv::SetSpecialIndexEQGain(int buf_index, int w_val) -{ - int tmpEQGainBuf[128] = { 0 }; - - if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { - RealReadCurAudioEQGain(tmpEQGainBuf); - tmpEQGainBuf[buf_index] = w_val; +int CTv::SetSpecialIndexEQGain(int buf_index, int w_val) { + int tmpEQGainBuf[128] = { 0 }; - return AudioSetEQGain(tmpEQGainBuf); - } + if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { + RealReadCurAudioEQGain(tmpEQGainBuf); + tmpEQGainBuf[buf_index] = w_val; - return -1; + return AudioSetEQGain(tmpEQGainBuf); + } + return -1; } -int CTv::SaveSpecialIndexEQGain(int buf_index, int w_val) -{ - int tmpEQGainBuf[128] = { 0 }; +int CTv::SaveSpecialIndexEQGain(int buf_index, int w_val) { + int tmpEQGainBuf[128] = { 0 }; - if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { - RealReadCurAudioEQGain(tmpEQGainBuf); - tmpEQGainBuf[buf_index] = w_val; + if (buf_index >= 0 && buf_index < GetAudioEQBandCount()) { + RealReadCurAudioEQGain(tmpEQGainBuf); + tmpEQGainBuf[buf_index] = w_val; - return RealSaveCurAudioEQGain(tmpEQGainBuf, 0); - } + return RealSaveCurAudioEQGain(tmpEQGainBuf, 0); + } - return 0; + return 0; } // amAudio -int CTv::OpenAmAudio(unsigned int sr, int input_device, int output_device) -{ - LOGD("OpenAmAudio input_device = %d", input_device); - return amAudioOpen(sr, input_device, output_device); +int CTv::OpenAmAudio(unsigned int sr, int input_device, int output_device) { + LOGD("OpenAmAudio input_device = %d", input_device); + return amAudioOpen(sr, input_device, output_device); } -int CTv::CloseAmAudio(void) -{ - return amAudioClose(); +int CTv::CloseAmAudio(void) { + return amAudioClose(); } -int CTv::SetAmAudioInputSr(unsigned int sr, int output_device) -{ - LOGD("SetAmAudioInputSr "); - return amAudioSetInputSr(sr, CC_IN_USE_SPDIF_DEVICE, output_device); +int CTv::SetAmAudioInputSr(unsigned int sr, int output_device) { + LOGD("SetAmAudioInputSr "); + return amAudioSetInputSr(sr, CC_IN_USE_SPDIF_DEVICE, output_device); } -int CTv::SetAmAudioOutputMode(int mode) -{ - if (mode != CC_AMAUDIO_OUT_MODE_DIRECT && mode != CC_AMAUDIO_OUT_MODE_INTER_MIX - && mode != CC_AMAUDIO_OUT_MODE_DIRECT_MIX) { - LOGE("%s, mode error, it should be mix or direct!\n", __FUNCTION__); - return -1; - } +int CTv::SetAmAudioOutputMode(int mode) { + if (mode != CC_AMAUDIO_OUT_MODE_DIRECT && mode != CC_AMAUDIO_OUT_MODE_INTER_MIX + && mode != CC_AMAUDIO_OUT_MODE_DIRECT_MIX) { + LOGE("%s, mode error, it should be mix or direct!\n", __FUNCTION__); + return -1; + } - return amAudioSetOutputMode(mode); + return amAudioSetOutputMode(mode); } -int CTv::SetAmAudioMusicGain(int gain) -{ - return amAudioSetMusicGain(gain); +int CTv::SetAmAudioMusicGain(int gain) { + return amAudioSetMusicGain(gain); } -int CTv::SetAmAudioLeftGain(int gain) -{ - return amAudioSetLeftGain(gain); +int CTv::SetAmAudioLeftGain(int gain) { + return amAudioSetLeftGain(gain); } - -int CTv::SetAmAudioRightGain(int gain) -{ - return amAudioSetRightGain(gain); +int CTv::SetAmAudioRightGain(int gain) { + return amAudioSetRightGain(gain); } -int CTv::SetAudioDumpDataFlag(int tmp_flag) -{ - return amAudioSetDumpDataFlag(tmp_flag); +int CTv::SetAudioDumpDataFlag(int tmp_flag) { + return amAudioSetDumpDataFlag(tmp_flag); } -int GetAudioDumpDataFlag() -{ - return amAudioGetDumpDataFlag(); +int GetAudioDumpDataFlag() { + return amAudioGetDumpDataFlag(); } -static int RealCalVolDigitLUTBuf(int start_ind, int end_ind, int start_val, - int end_val, int lut_buf[]) -{ - int i = 0; - float tmp_step = 0; - if (end_ind < start_ind) { - return 0; - } +static int RealCalVolDigitLUTBuf(int start_ind, int end_ind, int start_val, + int end_val, int lut_buf[]) { + int i = 0; + float tmp_step = 0; - tmp_step = (float) (end_val - start_val) / (float) (end_ind - start_ind); + if (end_ind < start_ind) { + return 0; + } - for (i = start_ind; i < end_ind; i++) { - lut_buf[i] = start_val + (int) (tmp_step * (i - start_ind)); - } + tmp_step = (float) (end_val - start_val) / (float) (end_ind - start_ind); - lut_buf[end_ind] = end_val; + for (i = start_ind; i < end_ind; i++) { + lut_buf[i] = start_val + (int) (tmp_step * (i - start_ind)); + } - return 1; + lut_buf[end_ind] = end_val; + return 1; } -void CTv::AudioSetVolumeDigitLUTBuf(int lut_table_index, int *MainVolLutBuf) -{ - - int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; - mAudioAlsa.SetMainVolDigitLutBuf(MainVolLutBuf); +void CTv::AudioSetVolumeDigitLUTBuf(int lut_table_index, int *MainVolLutBuf) { + int tmpDefDigitLutBuf[CC_LUT_BUF_SIZE] = { 0 }; + mAudioAlsa.SetMainVolDigitLutBuf(MainVolLutBuf); - GetAudioAmpSupbassvolBuf(lut_table_index, tmpDefDigitLutBuf); - mAudioAlsa.SetSupperBassVolDigitLutBuf(tmpDefDigitLutBuf); - return; + GetAudioAmpSupbassvolBuf(lut_table_index, tmpDefDigitLutBuf); + mAudioAlsa.SetSupperBassVolDigitLutBuf(tmpDefDigitLutBuf); } -int CTv::InitTvAudio(int sr, int input_device) -{ - OpenAmAudio(sr, input_device, CC_OUT_USE_AMAUDIO); +int CTv::InitTvAudio(int sr, int input_device) { + OpenAmAudio(sr, input_device, CC_OUT_USE_AMAUDIO); - RefreshSrsEffectAndDacGain(); - SetCustomEQGain(); - - return 0; + RefreshSrsEffectAndDacGain(); + SetCustomEQGain(); + return 0; } -int CTv::UnInitTvAudio() -{ - return CloseAmAudio(); +int CTv::UnInitTvAudio() { + return CloseAmAudio(); } -int CTv::AudioChangeSampleRate(int sr) -{ - sr = HanldeAudioInputSr(sr); - - if (SetAmAudioInputSr(sr, CC_OUT_USE_AMAUDIO) != 0) { - return -1; - } +int CTv::AudioChangeSampleRate(int sr) { + sr = HanldeAudioInputSr(sr); - RefreshSrsEffectAndDacGain(); - SetCustomEQGain(); + if (SetAmAudioInputSr(sr, CC_OUT_USE_AMAUDIO) != 0) { + return -1; + } - return 0; + RefreshSrsEffectAndDacGain(); + SetCustomEQGain(); + return 0; } -int CTv::AudioSetAudioInSource(int audio_src_in_type) -{ - return mAudioAlsa.SetAudioInSource(audio_src_in_type); +int CTv::AudioSetAudioInSource(int audio_src_in_type) { + return mAudioAlsa.SetAudioInSource(audio_src_in_type); } -int CTv::AudioSetAudioSourceType(int source_type) -{ - int aud_arch_type = GetAudioArchitectureTypeCFG(); +int CTv::AudioSetAudioSourceType(int source_type) { + int aud_arch_type = GetAudioArchitectureTypeCFG(); - if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { - SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SOURCE, source_type); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { - mCustomerCtrl.SetSource(source_type); - } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { - } - return 0; + if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_ON_BOARD) { + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC) { + SendCmdToOffBoardFBCExternalDac(AUDIO_CMD_SET_SOURCE, source_type); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_CUSTOMER_LIB) { + mCustomerCtrl.SetSource(source_type); + } else if (aud_arch_type == CC_DAC_G9TV_EXTERNAL_DAC_DIGITAL) { + } + return 0; } -int CTv::AudioLineInSelectChannel(int audio_channel) -{ - LOGD ("%s, audio_channel = %d", __FUNCTION__, audio_channel); - mAudioAlsa.SetInternalDacLineInSelectChannel(audio_channel); - return 0; +int CTv::AudioLineInSelectChannel(int audio_channel) { + LOGD ("%s, audio_channel = %d", __FUNCTION__, audio_channel); + mAudioAlsa.SetInternalDacLineInSelectChannel(audio_channel); + return 0; } -int CTv::SetKalaokIO(int level) -{ - LOGD ("%s, SetKalaokIO = %d", __FUNCTION__, level); - if (GetKaraokAvEnable() == 1) { - mAudioAlsa.SetAudioSwitchIO(level); - } - return 0; + +int CTv::SetKalaokIO(int level) { + LOGD ("%s, SetKalaokIO = %d", __FUNCTION__, level); + if (GetKaraokAvEnable() == 1) { + mAudioAlsa.SetAudioSwitchIO(level); + } + return 0; } -int CTv::AudioSetLineInCaptureVolume(int l_vol, int r_vol) -{ - mAudioAlsa.SetInternalDacLineInCaptureVolume(l_vol, r_vol); - return 0; +int CTv::AudioSetLineInCaptureVolume(int l_vol, int r_vol) { + mAudioAlsa.SetInternalDacLineInCaptureVolume(l_vol, r_vol); + return 0; } -int CTv::openTvAudio() -{ - int tmp_val = 0; +int CTv::openTvAudio() { + int tmp_val = 0; - LOGD("%s, entering...\n", __FUNCTION__); - UnInitSetTvAudioCard(); + LOGD("%s, entering...\n", __FUNCTION__); + UnInitSetTvAudioCard(); - tmp_val = GetAudioDumpDataEnableFlagCfg(); - SetAudioDumpDataFlag(tmp_val); + tmp_val = GetAudioDumpDataEnableFlagCfg(); + SetAudioDumpDataFlag(tmp_val); - tmp_val = GetAudioInternalDacPGAInGain_Cfg(); - mAudioAlsa.SetAudioInternalDacPGAInGain(tmp_val, tmp_val); + tmp_val = GetAudioInternalDacPGAInGain_Cfg(); + mAudioAlsa.SetAudioInternalDacPGAInGain(tmp_val, tmp_val); - mAudioAlsa.SetMixerBypassSwitch (CC_SWITCH_OFF); - mAudioAlsa.SetMixerDacSwitch (CC_SWITCH_ON); + mAudioAlsa.SetMixerBypassSwitch (CC_SWITCH_OFF); + mAudioAlsa.SetMixerDacSwitch (CC_SWITCH_ON); - LoadAudioCtl(); + LoadAudioCtl(); - RefreshSrsEffectAndDacGain(); - InitSetAudioCtl(); - return 0; + RefreshSrsEffectAndDacGain(); + InitSetAudioCtl(); + return 0; } -int CTv::closeTvAudio() -{ - return 0; +int CTv::closeTvAudio() { + return 0; } -void CTv::LoadAudioCtl() -{ - // Get Current Audio Volume - LoadCurAudioMasterVolume(); - // Get Current Audio Balance - LoadCurAudioBalance(); +void CTv::LoadAudioCtl() { + // Get Current Audio Volume + LoadCurAudioMasterVolume(); + + // Get Current Audio Balance + LoadCurAudioBalance(); - // Get Current Supper Bass Switch - LoadCurAudioSupperBassSwitch(); + // Get Current Supper Bass Switch + LoadCurAudioSupperBassSwitch(); - // Get Current Supper Bass Volume - LoadCurAudioSupperBassVolume(); + // Get Current Supper Bass Volume + LoadCurAudioSupperBassVolume(); - // Get Current SRSSurround - LoadCurAudioSrsSurround(); + // Get Current SRSSurround + LoadCurAudioSrsSurround(); - // Get Current SRS DialogClarity - LoadCurAudioSrsDialogClarity(); + // Get Current SRS DialogClarity + LoadCurAudioSrsDialogClarity(); - // Get Current SRS TruBass - LoadCurAudioSrsTruBass(); + // Get Current SRS TruBass + LoadCurAudioSrsTruBass(); - // Get Current Audio Sound Mode - LoadCurAudioSoundMode(); + // Get Current Audio Sound Mode + LoadCurAudioSoundMode(); - // Get Current Audio Bass and Treble - LoadCurAudioBassVolume(); - LoadCurAudioTrebleVolume(); + // Get Current Audio Bass and Treble + LoadCurAudioBassVolume(); + LoadCurAudioTrebleVolume(); - // Get Current Wall Effect - LoadCurAudioWallEffect(); + // Get Current Wall Effect + LoadCurAudioWallEffect(); - // Get Current spdif switch - LoadCurAudioSPDIFSwitch(); + // Get Current spdif switch + LoadCurAudioSPDIFSwitch(); - // Get Current spdif mode - LoadCurAudioSPDIFMode(); + // Get Current spdif mode + LoadCurAudioSPDIFMode(); - // Get Current EQ mode - LoadCurAudioEQMode(); + // Get Current EQ mode + LoadCurAudioEQMode(); - // Get Current EQ Gain - LoadCurAudioEQGain(); + // Get Current EQ Gain + LoadCurAudioEQGain(); } -void CTv::InitSetAudioCtl() -{ - // Set Current Audio balance value - SetAudioBalance(GetAudioBalance()); +void CTv::InitSetAudioCtl() { + // Set Current Audio balance value + SetAudioBalance(GetAudioBalance()); - // Set Current Audio Volume - SetAudioMasterVolume(GetAudioMasterVolume()); + // Set Current Audio Volume + SetAudioMasterVolume(GetAudioMasterVolume()); - // Set Current Supper Bass Volume - SetAudioSupperBassVolume(GetAudioSupperBassVolume()); + // Set Current Supper Bass Volume + SetAudioSupperBassVolume(GetAudioSupperBassVolume()); - // Set Current Audio Sound Mode - SetAudioSoundMode(GetAudioSoundMode()); + // Set Current Audio Sound Mode + SetAudioSoundMode(GetAudioSoundMode()); - // Set Current Audio SPDIF Switch - SetAudioSPDIFSwitch(GetCurAudioSPDIFSwitch()); + // Set Current Audio SPDIF Switch + SetAudioSPDIFSwitch(GetCurAudioSPDIFSwitch()); - // Set Current Audio SPDIF mode - SetAudioSPDIFMode(GetCurAudioSPDIFMode()); + // Set Current Audio SPDIF mode + SetAudioSPDIFMode(GetCurAudioSPDIFMode()); } -int CTv::SetADC_Digital_Capture_Volume(int value) -{ - return mAudioAlsa.SetAudioInternalDacADCDigitalCaptureVolume( value, value); +int CTv::SetADC_Digital_Capture_Volume(int value) { + return mAudioAlsa.SetAudioInternalDacADCDigitalCaptureVolume( value, value); } -int CTv::SetPGA_IN_Value(int value) -{ - return mAudioAlsa.SetAudioInternalDacPGAInGain( value, value); + +int CTv::SetPGA_IN_Value(int value) { + return mAudioAlsa.SetAudioInternalDacPGAInGain( value, value); } -int CTv::SetDAC_Digital_PlayBack_Volume(int value) -{ - return mAudioAlsa.SetAudioInternalDacDACDigitalPlayBackVolume( value, value); + +int CTv::SetDAC_Digital_PlayBack_Volume(int value) { + return mAudioAlsa.SetAudioInternalDacDACDigitalPlayBackVolume( value, value); } -int CTv::setAudioPcmPlaybackVolume(int val) -{ - int pcm_volume = 0; - pcm_volume = val / 2; - if (pcm_volume > 24) pcm_volume = 24; - //return SetAudioPcmPlaybackVolume(pcm_volume); - return 0; +int CTv::setAudioPcmPlaybackVolume(int val) { + int pcm_volume = 0; + pcm_volume = val / 2; + if (pcm_volume > 24) pcm_volume = 24; + //return SetAudioPcmPlaybackVolume(pcm_volume); + return 0; } -int CTv::HanldeAudioInputSr(unsigned int sr) -{ - int tmp_cfg = 0; +int CTv::HanldeAudioInputSr(unsigned int sr) { + int tmp_cfg = 0; - tmp_cfg = GetAudioResampleTypeCFG(); - if (tmp_cfg & CC_AUD_RESAMPLE_TYPE_HW) { - mAudioAlsa.SetHardwareResample(sr); - } else { - mAudioAlsa.SetHardwareResample(-1); - } + tmp_cfg = GetAudioResampleTypeCFG(); + if (tmp_cfg & CC_AUD_RESAMPLE_TYPE_HW) { + mAudioAlsa.SetHardwareResample(sr); + } else { + mAudioAlsa.SetHardwareResample(-1); + } - if (!(tmp_cfg & CC_AUD_RESAMPLE_TYPE_SW)) { - sr = 48000; - } + if (!(tmp_cfg & CC_AUD_RESAMPLE_TYPE_SW)) { + sr = 48000; + } - return sr; + return sr; } -int CTv::AudioSSMRestoreDefaultSetting() -{ - int i = 0, tmp_val = 0; - int nMinUIVol = 0, nMaxUIVol = 0; - int *tmp_ptr = NULL; - int tmpEQGainBuf[128] = { 0 }; - unsigned char tmp_buf[CC_NO_LINE_POINTS_MAX_CNT] = { 0 }; +int CTv::AudioSSMRestoreDefaultSetting() { + int i = 0, tmp_val = 0; + int nMinUIVol = 0, nMaxUIVol = 0; + int *tmp_ptr = NULL; + int tmpEQGainBuf[128] = { 0 }; + unsigned char tmp_buf[CC_NO_LINE_POINTS_MAX_CNT] = { 0 }; - // Save Current Audio Volume - SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); + // Save Current Audio Volume + SaveCurAudioMasterVolume (CC_DEF_SOUND_VOL); - // Save Current Audio Balance - SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); + // Save Current Audio Balance + SaveCurAudioBalance (CC_DEF_SOUND_BALANCE_VAL); - // Save Current Supper Bass Switch - SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); + // Save Current Supper Bass Switch + SaveCurAudioSupperBassSwitch (CC_SWITCH_OFF); - // Save Current Supper Bass Volume - SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); + // Save Current Supper Bass Volume + SaveCurAudioSupperBassVolume (CC_DEF_SUPPERBASS_VOL); - // Save Current SRSSurround - SaveCurAudioSrsSurround(CC_SWITCH_OFF); + // Save Current SRSSurround + SaveCurAudioSrsSurround(CC_SWITCH_OFF); - // Save Current SRS DialogClarity - SaveCurAudioSrsDialogClarity(CC_SWITCH_OFF); + // Save Current SRS DialogClarity + SaveCurAudioSrsDialogClarity(CC_SWITCH_OFF); - // Save Current SRS TruBass - SaveCurAudioSrsTruBass(CC_SWITCH_OFF); + // Save Current SRS TruBass + SaveCurAudioSrsTruBass(CC_SWITCH_OFF); - // Save Current Audio Sound Mode - SaveCurAudioSoundMode (CC_SOUND_MODE_STD); + // Save Current Audio Sound Mode + SaveCurAudioSoundMode (CC_SOUND_MODE_STD); - // Save Current Wall Effect - SaveCurAudioWallEffect(CC_SWITCH_OFF); + // Save Current Wall Effect + SaveCurAudioWallEffect(CC_SWITCH_OFF); - // Save Current spdif switch - SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); + // Save Current spdif switch + SaveCurAudioSPDIFSwitch (CC_SWITCH_ON); - // Save Current spdif mode - SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); + // Save Current spdif mode + SaveCurAudioSPDIFMode (CC_SPDIF_MODE_PCM); - // Save Current avout and spidif mute state - SSMSaveAudioSPIDFMuteVal(CC_AUDIO_MUTE); - SSMSaveAudioAVOutMuteVal(CC_AUDIO_MUTE); + // Save Current avout and spidif mute state + SSMSaveAudioSPIDFMuteVal(CC_AUDIO_MUTE); + SSMSaveAudioAVOutMuteVal(CC_AUDIO_MUTE); - // Save Current EQ mode - SaveCurAudioEQMode (CC_EQ_MODE_NOMAL); + // Save Current EQ mode + SaveCurAudioEQMode (CC_EQ_MODE_NOMAL); - // Save Current EQ Gain - RestoreToAudioDefEQGain(tmpEQGainBuf); + // Save Current EQ Gain + RestoreToAudioDefEQGain(tmpEQGainBuf); - // Save Current Audio Bass and Treble - nMinUIVol = GetBassUIMinGainVal(); - nMaxUIVol = GetBassUIMaxGainVal(); - RealSaveCurAudioBassVolume((nMinUIVol + nMaxUIVol) / 2, 0); + // Save Current Audio Bass and Treble + nMinUIVol = GetBassUIMinGainVal(); + nMaxUIVol = GetBassUIMaxGainVal(); + RealSaveCurAudioBassVolume((nMinUIVol + nMaxUIVol) / 2, 0); - nMinUIVol = GetTrebleUIMinGainVal(); - nMaxUIVol = GetTrebleUIMaxGainVal(); - RealSaveCurAudioTrebleVolume((nMinUIVol + nMaxUIVol) / 2, 0); - - return 0; + nMinUIVol = GetTrebleUIMinGainVal(); + nMaxUIVol = GetTrebleUIMaxGainVal(); + RealSaveCurAudioTrebleVolume((nMinUIVol + nMaxUIVol) / 2, 0); + return 0; } static const char *gDefCapturePropName = "snd.card.default.card.capture"; -int CTv::InitSetTvAudioCard() -{ - int i = 0, totle_num = 0, capture_ind = 0; - char tmp_buf[32] = { 0 }; - char tv_card_name[64] = { 0 }; - char prop_value[PROPERTY_VALUE_MAX]; +int CTv::InitSetTvAudioCard() { + int i = 0, totle_num = 0, capture_ind = 0; + char tmp_buf[32] = { 0 }; + char tv_card_name[64] = { 0 }; + char prop_value[PROPERTY_VALUE_MAX]; #ifndef BOARD_ALSA_AUDIO_TINY - snd_card_refresh_info(); + snd_card_refresh_info(); #endif - if (GetTvAudioCardNeedSet()) { - memset(prop_value, '\0', PROPERTY_VALUE_MAX); - property_get("snd.card.totle.num", prop_value, "0"); - - totle_num = strtoul(prop_value, NULL, 10); - LOGD("%s, totle number = %d\n", __FUNCTION__, totle_num); - totle_num = 8; + if (GetTvAudioCardNeedSet()) { + memset(prop_value, '\0', PROPERTY_VALUE_MAX); + property_get("snd.card.totle.num", prop_value, "0"); - GetTvAudioCardName(tv_card_name); + totle_num = strtoul(prop_value, NULL, 10); + LOGD("%s, totle number = %d\n", __FUNCTION__, totle_num); + totle_num = 8; - for (i = 0; i < totle_num; i++) { - sprintf(tmp_buf, "snd.card.%d.name", i); - memset(prop_value, '\0', PROPERTY_VALUE_MAX); - property_get(tmp_buf, prop_value, "null"); + GetTvAudioCardName(tv_card_name); - LOGD("%s, key string \"%s\", value string \"%s\".\n", __FUNCTION__, - tmp_buf, prop_value); + for (i = 0; i < totle_num; i++) { + sprintf(tmp_buf, "snd.card.%d.name", i); + memset(prop_value, '\0', PROPERTY_VALUE_MAX); + property_get(tmp_buf, prop_value, "null"); - if (strcmp(prop_value, tv_card_name) == 0) { - break; - } - } + LOGD("%s, key string \"%s\", value string \"%s\".\n", __FUNCTION__, tmp_buf, prop_value); - capture_ind = i; + if (strcmp(prop_value, tv_card_name) == 0) { + break; + } + } - if (capture_ind == totle_num) { - capture_ind = -1; - LOGE("%s, can't find tv card \"%s\".\n", __FUNCTION__, - tv_card_name); - } - } else { - capture_ind = -1; - } + capture_ind = i; - sprintf(tmp_buf, "%d", capture_ind); - property_set(gDefCapturePropName, tmp_buf); - LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, - tmp_buf); + if (capture_ind == totle_num) { + capture_ind = -1; + LOGE("%s, can't find tv card \"%s\".\n", __FUNCTION__, tv_card_name); + } + } else { + capture_ind = -1; + } - return 0; + sprintf(tmp_buf, "%d", capture_ind); + property_set(gDefCapturePropName, tmp_buf); + LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, tmp_buf); + return 0; } -int CTv::UnInitSetTvAudioCard() -{ - char tmp_buf[32] = { 0 }; +int CTv::UnInitSetTvAudioCard() { + char tmp_buf[32] = { 0 }; #ifndef BOARD_ALSA_AUDIO_TINY - snd_card_refresh_info(); + snd_card_refresh_info(); #endif - sprintf(tmp_buf, "%d", -1); - property_set(gDefCapturePropName, tmp_buf); - LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, - tmp_buf); - - return 0; + sprintf(tmp_buf, "%d", -1); + property_set(gDefCapturePropName, tmp_buf); + LOGD("%s, set \"%s\" as \"%s\".\n", __FUNCTION__, gDefCapturePropName, tmp_buf); + return 0; } #define CS_SPDIF_MODE_DEV_PATH "/sys/class/audiodsp/digital_raw" -int CTv::SetSPDIFMode(int mode_val) -{ - FILE *spdif_mode_fp = NULL; - - spdif_mode_fp = fopen(CS_SPDIF_MODE_DEV_PATH, "w"); - if (spdif_mode_fp == NULL) { - LOGE("%s, Open file %s error(%s)!\n", __FUNCTION__, CS_SPDIF_MODE_DEV_PATH, strerror(errno)); - return -1; - } - - if (mode_val == CC_SPDIF_MODE_PCM) { - fprintf(spdif_mode_fp, "%d", 0); - } else if (mode_val == CC_SPDIF_MODE_RAW ) { - fprintf(spdif_mode_fp, "%d", 1); - } - - fclose(spdif_mode_fp); - spdif_mode_fp = NULL; - - return 0; -} - -int CTv::SwitchAVOutBypass(int sw) -{ - if (sw == 0 ) { - mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_OFF ); - mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_ON ); - } else { - mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_ON ); - mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_OFF ); - } - return 0; -} - -int CTv::SetAudioSwitchIO(int value) -{ - return mAudioAlsa.SetAudioSwitchIO( value); -} -int CTv::SetOutput_Swap(int value) -{ - return mAudioAlsa.SetOutput_Swap( value); -} - -int CTv::SendCmdToOffBoardFBCExternalDac(int cmd, int para) -{ - int set_val = 0; - CFbcCommunication *pFBC = GetSingletonFBC(); - if (pFBC != NULL) { - if (cmd == AUDIO_CMD_SET_MUTE) { - if (para == CC_AUDIO_MUTE) { - set_val = CC_MUTE_ON; - } else if (para == CC_AUDIO_UNMUTE) { - set_val = CC_MUTE_OFF; - } else { - return -1; - } - - return pFBC->cfbc_Set_Mute(COMM_DEV_SERIAL, set_val); - } else if (cmd == AUDIO_CMD_SET_VOLUME_BAR) { - LOGD("%s, send AUDIO_CMD_SET_VOLUME_BAR (para = %d) to fbc.\n", __FUNCTION__, para); - return pFBC->cfbc_Set_Volume_Bar(COMM_DEV_SERIAL, para); - } else if (cmd == AUDIO_CMD_SET_BALANCE) { - LOGD("%s, send AUDIO_CMD_SET_BALANCE (para = %d) to fbc.\n", __FUNCTION__, para); - return pFBC->cfbc_Set_Balance(COMM_DEV_SERIAL, para); - } else if (cmd == AUDIO_CMD_SET_SOURCE) { - LOGD("%s, send AUDIO_CMD_SET_SOURCE (para = %d) to fbc.\n", __FUNCTION__, para); - return pFBC->cfbc_Set_FBC_Audio_Source(COMM_DEV_SERIAL, para); - } - } - - return 0; -} - -int CTv::GetHdmiAvHotplugDetectOnoff() -{ - return m_hdmiav_hotplugdetect_en; +int CTv::SetSPDIFMode(int mode_val) { + FILE *spdif_mode_fp = NULL; + + spdif_mode_fp = fopen(CS_SPDIF_MODE_DEV_PATH, "w"); + if (spdif_mode_fp == NULL) { + LOGE("%s, Open file %s error(%s)!\n", __FUNCTION__, CS_SPDIF_MODE_DEV_PATH, strerror(errno)); + return -1; + } + + if (mode_val == CC_SPDIF_MODE_PCM) { + fprintf(spdif_mode_fp, "%d", 0); + } else if (mode_val == CC_SPDIF_MODE_RAW ) { + fprintf(spdif_mode_fp, "%d", 1); + } + + fclose(spdif_mode_fp); + spdif_mode_fp = NULL; + + return 0; +} + +int CTv::SwitchAVOutBypass(int sw) { + if (sw == 0 ) { + mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_OFF ); + mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_ON ); + } else { + mAudioAlsa.SetMixerBypassSwitch ( CC_SWITCH_ON ); + mAudioAlsa.SetMixerDacSwitch ( CC_SWITCH_OFF ); + } + return 0; +} + +int CTv::SetAudioSwitchIO(int value) { + return mAudioAlsa.SetAudioSwitchIO( value); } + +int CTv::SetOutput_Swap(int value) { + return mAudioAlsa.SetOutput_Swap( value); +} + +int CTv::SendCmdToOffBoardFBCExternalDac(int cmd, int para) { + int set_val = 0; + CFbcCommunication *pFBC = GetSingletonFBC(); + if (pFBC != NULL) { + if (cmd == AUDIO_CMD_SET_MUTE) { + if (para == CC_AUDIO_MUTE) { + set_val = CC_MUTE_ON; + } else if (para == CC_AUDIO_UNMUTE) { + set_val = CC_MUTE_OFF; + } else { + return -1; + } + + return pFBC->cfbc_Set_Mute(COMM_DEV_SERIAL, set_val); + } else if (cmd == AUDIO_CMD_SET_VOLUME_BAR) { + LOGD("%s, send AUDIO_CMD_SET_VOLUME_BAR (para = %d) to fbc.\n", __FUNCTION__, para); + return pFBC->cfbc_Set_Volume_Bar(COMM_DEV_SERIAL, para); + } else if (cmd == AUDIO_CMD_SET_BALANCE) { + LOGD("%s, send AUDIO_CMD_SET_BALANCE (para = %d) to fbc.\n", __FUNCTION__, para); + return pFBC->cfbc_Set_Balance(COMM_DEV_SERIAL, para); + } else if (cmd == AUDIO_CMD_SET_SOURCE) { + LOGD("%s, send AUDIO_CMD_SET_SOURCE (para = %d) to fbc.\n", __FUNCTION__, para); + return pFBC->cfbc_Set_FBC_Audio_Source(COMM_DEV_SERIAL, para); + } + } + return 0; +} + +int CTv::GetHdmiAvHotplugDetectOnoff() { + return m_hdmiav_hotplugdetect_en; +} + diff --git a/tvapi/libtv/tv/CTv.h b/tvapi/libtv/tv/CTv.h index 7210f40..2520962 100644 --- a/tvapi/libtv/tv/CTv.h +++ b/tvapi/libtv/tv/CTv.h @@ -248,7 +248,7 @@ public: int SendHDMIRxCECGiveOSDNameMessage(tv_source_input_t source_input, unsigned char data_buf[]); int GetHdmiHdcpKeyKsvInfo(int data_buf[]); - virtual int hdmi_out_towhat(); + virtual bool hdmiOutWithFbc(); int StartUpgradeFBC(char *file_name, int mode, int upgrade_blk_size); int SetSerialSwitch(int dev_id, int switch_val); int SendSerialData(int dev_id, int data_len, unsigned char data_buf[]); @@ -781,7 +781,7 @@ protected: tv_window_mode_t m_win_mode; int m_blackout_enable;//1 enable 0 disable int m_cur_playing_prog_id; - bool mB_hdmiout_fbc; + bool mHdmiOutFbc; CFbcCommunication *fbcIns; diff --git a/tvapi/libtv/tvconfig/tvconfig.h b/tvapi/libtv/tvconfig/tvconfig.h index f2cf316..5415dbd 100644 --- a/tvapi/libtv/tvconfig/tvconfig.h +++ b/tvapi/libtv/tvconfig/tvconfig.h @@ -5,6 +5,14 @@ #define CC_CFG_VALUE_STR_MAX_LEN (512) +#define CFG_SECTION_TV "TV" +#define CFG_SECTION_ATV "ATV" +#define CFG_SECTION_SRC_INPUT "SourceInputMap" +#define CFG_SECTION_SETTING "SETTING" +#define CFG_SECTION_FBCUART "FBCUART" + +#define CFG_BLUE_SCREEN_COLOR "tvin.bluescreen.color" + extern int tv_config_load(const char *file_name); extern int tv_config_unload(); extern int tv_config_save(); diff --git a/tvapi/libtv/tvdb/CTvDatabase.cpp b/tvapi/libtv/tvdb/CTvDatabase.cpp index 1a19976..5f9fd40 100644 --- a/tvapi/libtv/tvdb/CTvDatabase.cpp +++ b/tvapi/libtv/tvdb/CTvDatabase.cpp @@ -67,7 +67,7 @@ int CTvDatabase::UnInitTvDb() int CTvDatabase::InitTvDb(const char *path) { if (path != NULL) { - if (Tv_Utils_IsFileExist(path) == 0 && config_get_int("TV", "tv_db_created", 0) == 1) { //exist or created + if (Tv_Utils_IsFileExist(path) && config_get_int("TV", "tv_db_created", 0) == 1) { //exist or created LOGD("tv db file(%s) exist and created, open it", path); if (openDb(path) < 0 ) { LOGD("db(%s) open fail", path); @@ -80,7 +80,7 @@ int CTvDatabase::InitTvDb(const char *path) LOGD("scan region table is NULL, so import freq XML again\n"); } } else { - if (Tv_Utils_IsFileExist(path) == 0) { // if just exist, create flag not set, delete it + if (Tv_Utils_IsFileExist(path)) { // if just exist, create flag not set, delete it LOGD("tv db file (%s) exist, but delete it", path); if (unlink(path) != 0) { LOGD("delete tv db file(%s) err=%s", path, strerror(errno)); diff --git a/tvapi/libtv/tvin/CHDMIRxCEC.cpp b/tvapi/libtv/tvin/CHDMIRxCEC.cpp index 8bf7d79..22906a3 100644 --- a/tvapi/libtv/tvin/CHDMIRxCEC.cpp +++ b/tvapi/libtv/tvin/CHDMIRxCEC.cpp @@ -125,7 +125,7 @@ int CTvin::CHDMIRxCEC::GetModuleEnableFlag() const char *config_value = NULL; if (mModuleEnableFlag < 0) { - config_value = config_get_str("TV", "tvin.hdmirx.cec.enable", "null"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.hdmirx.cec.enable", "null"); if (strcasecmp(config_value, "null") == 0) { mModuleEnableFlag = 0; } else if (strcasecmp(config_value, "1") == 0 || strcasecmp(config_value, "true") == 0) { diff --git a/tvapi/libtv/tvin/CTvin.cpp b/tvapi/libtv/tvin/CTvin.cpp index 66a2a1f..034713c 100644 --- a/tvapi/libtv/tvin/CTvin.cpp +++ b/tvapi/libtv/tvin/CTvin.cpp @@ -106,10 +106,10 @@ CTvin::~CTvin() int CTvin::OpenTvin() { const char *config_value; - config_value = config_get_str ( "TV", "tvin.manual.set.tvpath", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "tvin.manual.set.tvpath", "null" ); strcpy ( config_tv_path, config_value ); memset ( config_default_path, 0x0, 64 ); - config_value = config_get_str ( "TV", "tvin.manual.set.defaultpath", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "tvin.manual.set.defaultpath", "null" ); strcpy ( config_default_path, config_value ); return 0; } @@ -182,8 +182,8 @@ char *CTvin::VDIN_CheckVideoPath ( const char *videopath ) } } - LOGW ( "%s, video path before check [%s]\n", "TV", videopath ); - LOGW ( "%s, video path after check [%s]\n", "TV", gVideoPath ); + LOGW ( "%s, video path before check [%s]\n", CFG_SECTION_TV, videopath ); + LOGW ( "%s, video path after check [%s]\n", CFG_SECTION_TV, gVideoPath ); return gVideoPath; } @@ -560,7 +560,7 @@ int CTvin::VDIN_SetDisplayVFreq ( int freq, int display_resolution , bool isFbc) } if (display_mode_type == -1) { - config_value = config_get_str ( "TV", "tvin.display.mode.type", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "tvin.display.mode.type", "null" ); if (strcasecmp(config_value, "null") == 0 || strcasecmp(config_value, "hdmi_out") == 0) { display_mode_type = 0; } else if (strcasecmp(config_value, "lvds_out") == 0) { @@ -2213,7 +2213,7 @@ int CTvin::TvinApi_SetCompPhaseEnable ( int enable ) if ( enable == 1 ) { ret = SetFileAttrValue ( "/sys/module/tvin_afe/parameters/enable_dphase", "Y" ); - LOGD ( "%s, enable TvinApi_SetCompPhase.", "TV" ); + LOGD ( "%s, enable TvinApi_SetCompPhase.", CFG_SECTION_TV ); } return ret; @@ -2233,7 +2233,7 @@ int CTvin::VDIN_GetPortConnect ( int port ) return 0; } - //LOGD("%s, port:%x,status:%d", "TV",port,status); + //LOGD("%s, port:%x,status:%d", CFG_SECTION_TV,port,status); return status; } @@ -2528,34 +2528,33 @@ unsigned int CTvin::Tvin_TransPortStringToValue(const char *port_str) void CTvin::Tvin_LoadSourceInputToPortMap() { - const char *SourceInputMapSection = "SourceInputMap"; const char *config_value = NULL; - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.atv", "TVIN_PORT_CVBS3"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.atv", "TVIN_PORT_CVBS3"); mSourceInputToPortMap[SOURCE_TV] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.av1", "TVIN_PORT_CVBS1"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.av1", "TVIN_PORT_CVBS1"); mSourceInputToPortMap[SOURCE_AV1] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.av2", "TVIN_PORT_CVBS2"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.av2", "TVIN_PORT_CVBS2"); mSourceInputToPortMap[SOURCE_AV2] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.ypbpr1", "TVIN_PORT_COMP0"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.ypbpr1", "TVIN_PORT_COMP0"); mSourceInputToPortMap[SOURCE_YPBPR1] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.ypbpr2", "TVIN_PORT_COMP1"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.ypbpr2", "TVIN_PORT_COMP1"); mSourceInputToPortMap[SOURCE_YPBPR2] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.hdmi1", "TVIN_PORT_HDMI0"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.hdmi1", "TVIN_PORT_HDMI0"); mSourceInputToPortMap[SOURCE_HDMI1] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.hdmi2", "TVIN_PORT_HDMI2"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.hdmi2", "TVIN_PORT_HDMI2"); mSourceInputToPortMap[SOURCE_HDMI2] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.hdmi3", "TVIN_PORT_HDMI1"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.hdmi3", "TVIN_PORT_HDMI1"); mSourceInputToPortMap[SOURCE_HDMI3] = Tvin_TransPortStringToValue(config_value); - config_value = config_get_str(SourceInputMapSection, "ro.tv.tvinchannel.vga", "TVIN_PORT_VGA0"); + config_value = config_get_str(CFG_SECTION_SRC_INPUT, "ro.tv.tvinchannel.vga", "TVIN_PORT_VGA0"); mSourceInputToPortMap[SOURCE_VGA] = Tvin_TransPortStringToValue(config_value); mSourceInputToPortMap[SOURCE_MPEG] = TVIN_PORT_MPEG0; @@ -2584,25 +2583,25 @@ tv_audio_channel_t CTvin::Tvin_GetInputSourceAudioChannelIndex ( tv_source_input const char *config_value = NULL; if ( source_input == SOURCE_TV ) { - config_value = config_get_str("TV", "tvin.aud.chan.atv", "2"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.atv", "2"); } else if ( source_input == SOURCE_AV1 ) { - config_value = config_get_str("TV", "tvin.aud.chan.av1", "1"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.av1", "1"); } else if ( source_input == SOURCE_AV2 ) { - config_value = config_get_str("TV", "tvin.aud.chan.av2", "3"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.av2", "3"); } else if ( source_input == SOURCE_YPBPR1 ) { - config_value = config_get_str("TV", "tvin.aud.chan.comp1", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.comp1", "0"); } else if ( source_input == SOURCE_YPBPR2 ) { - config_value = config_get_str("TV", "tvin.aud.chan.comp2", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.comp2", "0"); } else if ( source_input == SOURCE_HDMI1 ) { - config_value = config_get_str("TV", "tvin.aud.chan.hdmi1", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.hdmi1", "0"); } else if ( source_input == SOURCE_HDMI2 ) { - config_value = config_get_str("TV", "tvin.aud.chan.hdmi2", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.hdmi2", "0"); } else if ( source_input == SOURCE_HDMI3 ) { - config_value = config_get_str("TV", "tvin.aud.chan.hdmi3", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.hdmi3", "0"); } else if ( source_input == SOURCE_VGA ) { - config_value = config_get_str("TV", "tvin.aud.chan.vga", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.vga", "0"); } else if ( source_input == SOURCE_MPEG ) { - config_value = config_get_str("TV", "tvin.aud.chan.mpeg", "0"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.chan.mpeg", "0"); } if (config_value != NULL) { @@ -2617,7 +2616,7 @@ tv_audio_in_source_type_t CTvin::Tvin_GetAudioInSourceType ( tv_source_input_t s const char *config_value = NULL; if (source_input == SOURCE_TV) { - config_value = config_get_str("TV", "tvin.aud.insource.atv", "TV_AUDIO_IN_SOURCE_TYPE_LINEIN"); + config_value = config_get_str(CFG_SECTION_TV, "tvin.aud.insource.atv", "TV_AUDIO_IN_SOURCE_TYPE_LINEIN"); if (strcasecmp(config_value, "TV_AUDIO_IN_SOURCE_TYPE_ATV") == 0) { return TV_AUDIO_IN_SOURCE_TYPE_ATV; } @@ -2647,7 +2646,7 @@ int CTvin::isVgaFmtInHdmi ( tvin_sig_fmt_t fmt ) || fmt == TVIN_SIG_FMT_HDMI_1366X768_00HZ || fmt == TVIN_SIG_FMT_HDMI_1600X1200_00HZ || fmt == TVIN_SIG_FMT_HDMI_1920X1200_00HZ ) { - LOGD ( "%s, HDMI source : VGA format.", "TV" ); + LOGD ( "%s, HDMI source : VGA format.", CFG_SECTION_TV ); return 1; } @@ -2681,10 +2680,10 @@ int CTvin::isSDFmtInHdmi ( tvin_sig_fmt_t fmt ) || fmt == TVIN_SIG_FMT_HDMI_1440X480I_240HZ || fmt == TVIN_SIG_FMT_HDMI_800X600_00HZ || fmt == TVIN_SIG_FMT_HDMI_720X400_00HZ ) { - LOGD ( "%s, SD format.", "TV" ); + LOGD ( "%s, SD format.", CFG_SECTION_TV ); return true; } else { - LOGD ( "%s, HD format.", "TV" ); + LOGD ( "%s, HD format.", CFG_SECTION_TV ); return false; } } @@ -2720,10 +2719,10 @@ bool CTvin::Tvin_is50HzFrameRateFmt ( tvin_sig_fmt_t fmt ) || fmt == TVIN_SIG_FMT_CVBS_PAL_M || fmt == TVIN_SIG_FMT_CVBS_PAL_CN || fmt == TVIN_SIG_FMT_CVBS_SECAM ) { - LOGD ( "%s, Frame rate == 50Hz.", "TV" ); + LOGD ( "%s, Frame rate == 50Hz.", CFG_SECTION_TV ); return true; } else { - LOGD ( "%s, Frame rate != 50Hz.", "TV" ); + LOGD ( "%s, Frame rate != 50Hz.", CFG_SECTION_TV ); return false; } } @@ -2761,10 +2760,10 @@ bool CTvin::Tvin_IsDeinterlaceFmt ( tvin_sig_fmt_t fmt ) || fmt == TVIN_SIG_FMT_CVBS_PAL_I || fmt == TVIN_SIG_FMT_CVBS_PAL_M || fmt == TVIN_SIG_FMT_CVBS_SECAM ) { - LOGD ( "%s, Interlace format.", "TV" ); + LOGD ( "%s, Interlace format.", CFG_SECTION_TV ); return true; } else { - LOGD ( "%s, Progressive format.", "TV" ); + LOGD ( "%s, Progressive format.", CFG_SECTION_TV ); return false; } } @@ -2854,7 +2853,7 @@ int CTvin::Tvin_AddPath ( tvin_path_id_t pathid ) if ( pathid >= TV_PATH_VDIN_AMVIDEO && pathid < TV_PATH_DECODER_3D_AMVIDEO ) { if ( m_pathid == pathid ) { - LOGW ( "%s, no need to add the same tvin path.\n", "TV" ); + LOGW ( "%s, no need to add the same tvin path.\n", CFG_SECTION_TV ); return 0; } @@ -2862,10 +2861,10 @@ int CTvin::Tvin_AddPath ( tvin_path_id_t pathid ) ret = VDIN_RmTvPath(); if ( ret > 0 ) { - LOGD ( "%s, remove tvin path ok, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, remove tvin path ok, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else { - LOGW ( "%s, remove tvin path faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGW ( "%s, remove tvin path faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); usleep ( dly * 1000 ); } } @@ -2874,10 +2873,10 @@ int CTvin::Tvin_AddPath ( tvin_path_id_t pathid ) ret = VDIN_RmDefPath(); if ( ret > 0 ) { - LOGD ( "%s, remove default path ok, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, remove default path ok, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else { - LOGW ( "%s, remove default path faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGW ( "%s, remove default path faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); usleep ( dly * 1000 ); } } @@ -2899,10 +2898,10 @@ int CTvin::Tvin_AddPath ( tvin_path_id_t pathid ) } if ( ret >= 0 ) { - LOGD ( "%s, add pathid[%d] ok, %d ms gone.\n", "TV", pathid, i ); + LOGD ( "%s, add pathid[%d] ok, %d ms gone.\n", CFG_SECTION_TV, pathid, i ); break; } else { - LOGW ( "%s, add pathid[%d] faild, %d ms gone.\n", "TV", pathid, i ); + LOGW ( "%s, add pathid[%d] faild, %d ms gone.\n", CFG_SECTION_TV, pathid, i ); usleep ( dly * 1000 ); } } @@ -2924,7 +2923,7 @@ int CTvin::Tvin_RemovePath ( tv_path_type_t pathtype ) ret = Tvin_CheckPathActive ( pathtype, 0 ); if ( ret == TV_PATH_STATUS_INACTIVE ) { - LOGD ( "%s, check path is inactive, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, check path is inactive, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else if ( ret == TV_PATH_STATUS_INACTIVE || ret == TV_PATH_STATUS_ERROR ) { usleep ( dly * 1000 ); @@ -2934,7 +2933,7 @@ int CTvin::Tvin_RemovePath ( tv_path_type_t pathtype ) } if ( i == 500 ) { - LOGE ( "%s, check path active faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGE ( "%s, check path active faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); } if ( pathtype == TV_PATH_TYPE_DEFAULT ) { @@ -2942,10 +2941,10 @@ int CTvin::Tvin_RemovePath ( tv_path_type_t pathtype ) ret = VDIN_RmDefPath(); if ( ret > 0 ) { - LOGD ( "%s, remove default path ok, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, remove default path ok, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else { - LOGW ( "%s, remove default path faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGW ( "%s, remove default path faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); usleep ( dly * 1000 ); } } @@ -2954,10 +2953,10 @@ int CTvin::Tvin_RemovePath ( tv_path_type_t pathtype ) ret = VDIN_RmTvPath(); if ( ret > 0 ) { - LOGD ( "%s, remove tvin path ok, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, remove tvin path ok, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else { - LOGW ( "%s, remove tvin path faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGW ( "%s, remove tvin path faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); usleep ( dly * 1000 ); } } @@ -2968,10 +2967,10 @@ int CTvin::Tvin_RemovePath ( tv_path_type_t pathtype ) ret = VDIN_RmPreviewPath(); if ( ret > 0 ) { - LOGD ( "%s, remove preview path ok, %d ms gone.\n", "TV", ( dly * i ) ); + LOGD ( "%s, remove preview path ok, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); break; } else { - LOGW ( "%s, remove preview path faild, %d ms gone.\n", "TV", ( dly * i ) ); + LOGW ( "%s, remove preview path faild, %d ms gone.\n", CFG_SECTION_TV, ( dly * i ) ); usleep ( dly * 1000 ); } } @@ -3012,7 +3011,7 @@ int CTvin::Tvin_CheckPathActive ( tv_path_type_t path_type, int isCheckD2D3 ) f = fopen ( "/sys/class/vfm/map", "r" ); if ( !f ) { - LOGE ( "%s, can not open /sys/class/vfm/map!\n", "TV" ); + LOGE ( "%s, can not open /sys/class/vfm/map!\n", CFG_SECTION_TV ); return TV_PATH_STATUS_NO_DEV; } @@ -3026,7 +3025,7 @@ int CTvin::Tvin_CheckPathActive ( tv_path_type_t path_type, int isCheckD2D3 ) active_str = tvin_active_str; inactive_str = tvin_inactive_str; } else { - LOGW ( "%s, there is no %d path_type.\n", "TV", path_type ); + LOGW ( "%s, there is no %d path_type.\n", CFG_SECTION_TV, path_type ); break; } @@ -3034,31 +3033,31 @@ int CTvin::Tvin_CheckPathActive ( tv_path_type_t path_type, int isCheckD2D3 ) if ( isCheckD2D3 == 0 ) { if ( strstr ( str_find, active_str ) && strstr ( str_find, di_active_str ) ) { is_active = TV_PATH_STATUS_ACTIVE; - //LOGD("%s, %s is active.\n", "TV", path); + //LOGD("%s, %s is active.\n", CFG_SECTION_TV, path); } else if ( strstr ( str_find, inactive_str ) && ( strstr ( str_find, di_inactive_str ) || ( !strstr ( str_find, di_inactive_str ) ) ) ) { is_active = TV_PATH_STATUS_INACTIVE; - //LOGD("%s, %s is inactive.\n", "TV", path); + //LOGD("%s, %s is inactive.\n", CFG_SECTION_TV, path); } else { is_active = TV_PATH_STATUS_ERROR; - LOGE ( "%s, %s is error!\n", "TV", path ); + LOGE ( "%s, %s is error!\n", CFG_SECTION_TV, path ); } break; } else { if ( strstr ( str_find, active_str ) && strstr ( str_find, di_active_str ) && strstr ( str_find, d2d3_active_str ) ) { is_active = TV_PATH_STATUS_ACTIVE; - //LOGD("%s, %s is active.\n", "TV", path); + //LOGD("%s, %s is active.\n", CFG_SECTION_TV, path); } else if ( strstr ( str_find, inactive_str ) && ( strstr ( str_find, di_inactive_str ) || ( !strstr ( str_find, di_inactive_str ) ) ) && ( strstr ( str_find, d2d3_inactive_str ) || ( !strstr ( str_find, d2d3_inactive_str ) ) ) ) { is_active = TV_PATH_STATUS_INACTIVE; - //LOGD("%s, %s is inactive.\n", "TV", path); + //LOGD("%s, %s is inactive.\n", CFG_SECTION_TV, path); } else { is_active = TV_PATH_STATUS_ERROR; - LOGE ( "%s, %s is error!\n", "TV", path ); + LOGE ( "%s, %s is error!\n", CFG_SECTION_TV, path ); } break; diff --git a/tvapi/libtv/tvsetting/CBlobDeviceFile.cpp b/tvapi/libtv/tvsetting/CBlobDeviceFile.cpp index ea5d5b7..822265b 100644 --- a/tvapi/libtv/tvsetting/CBlobDeviceFile.cpp +++ b/tvapi/libtv/tvsetting/CBlobDeviceFile.cpp @@ -18,8 +18,8 @@ CBlobDeviceFile::CBlobDeviceFile() m_dev_fd = -1; mDataBuf = new unsigned char[m_dev_total_size]; - const char *device_path = config_get_str("SETTING", "device_path", "/param/default_data"); - const char *device_size = config_get_str("SETTING", "device_size", "0x1000"); + const char *device_path = config_get_str(CFG_SECTION_SETTING, "device_path", "/param/default_data"); + const char *device_size = config_get_str(CFG_SECTION_SETTING, "device_size", "0x1000"); strcpy(m_dev_path, device_path); } diff --git a/tvapi/libtv/tvsetting/CTvSetting.cpp b/tvapi/libtv/tvsetting/CTvSetting.cpp index 27b842f..feb94cc 100644 --- a/tvapi/libtv/tvsetting/CTvSetting.cpp +++ b/tvapi/libtv/tvsetting/CTvSetting.cpp @@ -34,7 +34,7 @@ bool CTvSettingLoad() mpSettingDeviceFactory = new CTvSettingDeviceFactory(); mpCurDevice = mpSettingDeviceFactory->getSaveDeviceFromConfigFile(); if (mpCurDevice == NULL) { - LOGD("%s, CTvSettingLoad = NULL", "TV"); + LOGD("%s, CTvSettingLoad = NULL", CFG_SECTION_TV); return false; } else { mpCurDevice->OpenDevice(); @@ -66,14 +66,14 @@ static int SSMWriteNTypes(int offset, int data_len, T *data_buf) pthread_mutex_lock(&ssm_r_w_op_mutex); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; } if (mpCurDevice == NULL) { - LOGE("%s, ssm_device is NULL.\n", "TV"); + LOGE("%s, ssm_device is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -81,7 +81,7 @@ static int SSMWriteNTypes(int offset, int data_len, T *data_buf) if (mpCurDevice->WriteBytes(offset, data_len * sizeof(T), (unsigned char *) data_buf) < 0) { - LOGE("%s, device WriteNBytes error.\n", "TV"); + LOGE("%s, device WriteNBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -97,14 +97,14 @@ static int SSMReadNTypes(int offset, int data_len, T *data_buf) pthread_mutex_lock(&ssm_r_w_op_mutex); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; } if (mpCurDevice == NULL) { - LOGE("%s, ssm_device is NULL.\n", "TV"); + LOGE("%s, ssm_device is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -112,7 +112,7 @@ static int SSMReadNTypes(int offset, int data_len, T *data_buf) if (mpCurDevice->ReadBytes(offset, data_len * sizeof(T), (unsigned char *) data_buf) < 0) { - LOGE("%s, device ReadNBytes error.\n", "TV"); + LOGE("%s, device ReadNBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; } @@ -204,13 +204,13 @@ int SSMReadFlash_N_N310_N311(int offset, int data_len, int *data_buf) int EEPWriteOneByte(int offset, unsigned char *data_buf) { int fd = 0; - const char *device_path = config_get_str("TV", "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); + const char *device_path = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); pthread_mutex_lock(&ssm_r_w_op_mutex); LOGD ( "~~~EEPWriteOneByte~~~##offset %d##rw_val %s##" , offset, data_buf); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -219,7 +219,7 @@ int EEPWriteOneByte(int offset, unsigned char *data_buf) fd = open(device_path, O_RDWR); if (fd < 0) { - LOGE("%s, ####i2c test device open failed####.\n", "TV"); + LOGE("%s, ####i2c test device open failed####.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -228,7 +228,7 @@ int EEPWriteOneByte(int offset, unsigned char *data_buf) lseek(fd, offset, SEEK_SET); if (write(fd, data_buf, 1) < 0) { - LOGE("%s, device WriteOneBytes error.\n", "TV"); + LOGE("%s, device WriteOneBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -236,7 +236,7 @@ int EEPWriteOneByte(int offset, unsigned char *data_buf) close(fd); - LOGE("%s, device WriteOneBytes OK.\n", "TV"); + LOGE("%s, device WriteOneBytes OK.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return 0; @@ -245,13 +245,13 @@ int EEPWriteOneByte(int offset, unsigned char *data_buf) int EEPReadOneByte(int offset , unsigned char *data_buf) { int fd = 0; - //const char* device_type = config_get_str("SETTING", "peripheral.eeprom.device", "disable"); - const char *device_path = config_get_str("TV", "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); + //const char* device_type = config_get_str(CFG_SECTION_SETTING, "peripheral.eeprom.device", "disable"); + const char *device_path = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); pthread_mutex_lock(&ssm_r_w_op_mutex); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -260,7 +260,7 @@ int EEPReadOneByte(int offset , unsigned char *data_buf) fd = open(device_path, O_RDWR); if (fd < 0) { - LOGE("%s, ssm_device is NULL.\n", "TV"); + LOGE("%s, ssm_device is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -268,7 +268,7 @@ int EEPReadOneByte(int offset , unsigned char *data_buf) lseek(fd, offset, SEEK_SET); if (read(fd, data_buf, 1) < 0) { - LOGE("%s, device ReadOneBytes error.\n", "TV"); + LOGE("%s, device ReadOneBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; } @@ -284,13 +284,13 @@ int EEPReadOneByte(int offset , unsigned char *data_buf) int EEPWriteNByte(int offset, int data_len, unsigned char *data_buf) { int fd = 0; - const char *device_path = config_get_str("TV", "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); + const char *device_path = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); pthread_mutex_lock(&ssm_r_w_op_mutex); LOGD ( "~~~EEPWriteNByte~~~##offset %d##data_len %d##" , offset, data_len); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -299,7 +299,7 @@ int EEPWriteNByte(int offset, int data_len, unsigned char *data_buf) fd = open(device_path, O_RDWR); if (fd < 0) { - LOGE("%s, ####i2c test device open failed####.\n", "TV"); + LOGE("%s, ####i2c test device open failed####.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -308,7 +308,7 @@ int EEPWriteNByte(int offset, int data_len, unsigned char *data_buf) lseek(fd, offset, SEEK_SET); if (write(fd, data_buf, data_len) < 0) { - LOGE("%s, device WriteNBytes error.\n", "TV"); + LOGE("%s, device WriteNBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -316,7 +316,7 @@ int EEPWriteNByte(int offset, int data_len, unsigned char *data_buf) close(fd); - LOGE("%s, device WriteNBytes OK.\n", "TV"); + LOGE("%s, device WriteNBytes OK.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return 0; @@ -324,11 +324,11 @@ int EEPWriteNByte(int offset, int data_len, unsigned char *data_buf) int EEPReadNByte(int offset, int data_len, unsigned char *data_buf) { int fd = 0; - const char *device_path = config_get_str("TV", "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); + const char *device_path = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.path", "/sys/devices/i2c-2/2-0050/eeprom"); pthread_mutex_lock(&ssm_r_w_op_mutex); if (data_buf == NULL) { - LOGE("%s, data_buf is NULL.\n", "TV"); + LOGE("%s, data_buf is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -337,7 +337,7 @@ int EEPReadNByte(int offset, int data_len, unsigned char *data_buf) fd = open(device_path, O_RDWR); if (fd < 0) { - LOGE("%s, ssm_device is NULL.\n", "TV"); + LOGE("%s, ssm_device is NULL.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -345,7 +345,7 @@ int EEPReadNByte(int offset, int data_len, unsigned char *data_buf) lseek(fd, offset, SEEK_SET); if (read(fd, data_buf, data_len) < 0) { - LOGE("%s, device ReadNBytes error.\n", "TV"); + LOGE("%s, device ReadNBytes error.\n", CFG_SECTION_TV); pthread_mutex_unlock(&ssm_r_w_op_mutex); return -1; @@ -363,7 +363,7 @@ int EEPReadNByte(int offset, int data_len, unsigned char *data_buf) int SSMSaveEEP_One_N310_N311(int offset, int rw_val) { unsigned char tmp_val = rw_val; - const char *device_config = config_get_str("TV", "peripheral.eeprom.device", "disable"); + const char *device_config = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.device", "disable"); if (strcmp(device_config, "enable") != 0) { LOGD ( "~~~ SSMSaveEEP_One ~~~##peripheral.eeprom.device error##"); @@ -377,7 +377,7 @@ int SSMSaveEEP_One_N310_N311(int offset, int rw_val) int SSMReadEEP_One_N310_N311(int offset) { unsigned char tmp_val = 0; - const char *device_config = config_get_str("TV", "peripheral.eeprom.device", "disable"); + const char *device_config = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.device", "disable"); if (strcmp(device_config, "enable") != 0) { LOGD ( "~~~ SSMReadEEP_One ~~~##peripheral.eeprom.device error##"); @@ -396,7 +396,7 @@ int SSMSaveEEP_N_N310_N311(int offset, int data_len, int *data_buf) { int i = 0; unsigned char *ptr = NULL; - const char *device_config = config_get_str("TV", "peripheral.eeprom.device", "disable"); + const char *device_config = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.device", "disable"); if (strcmp(device_config, "enable") != 0) { LOGD ( "~~~ SSMSaveEEP_N ~~~##peripheral.eeprom.device error##"); @@ -433,7 +433,7 @@ int SSMReadEEP_N_N310_N311(int offset, int data_len, int *data_buf) { int i = 0; unsigned char *ptr = NULL; - const char *device_config = config_get_str("TV", "peripheral.eeprom.device", "disable"); + const char *device_config = config_get_str(CFG_SECTION_TV, "peripheral.eeprom.device", "disable"); if (strcmp(device_config, "enable") != 0) { LOGD ( "~~~ SSMReadEEP_N ~~~##peripheral.eeprom.device error##"); @@ -925,7 +925,7 @@ int SSMSaveNonStandardValue(unsigned short rw_val) data[1] = (unsigned char) rw_val; } - LOGD("%s, save NonStandard_value = %d", "TV", rw_val); + LOGD("%s, save NonStandard_value = %d", CFG_SECTION_TV, rw_val); return SSMWriteNTypes(SSM_RW_NON_STANDARD_START, 2, data); } @@ -936,7 +936,7 @@ int SSMReadNonStandardValue(void) int data[] = { 0, 0 }; if (SSMReadNTypes(SSM_RW_NON_STANDARD_START, 2, data) < 0) { - LOGE("%s, read NonStandard_value error.", "TV"); + LOGE("%s, read NonStandard_value error.", CFG_SECTION_TV); return 0; } @@ -946,7 +946,7 @@ int SSMReadNonStandardValue(void) value += data[0]; } - LOGD("%s, read NonStandard_value = %d.", "TV", value); + LOGD("%s, read NonStandard_value = %d.", CFG_SECTION_TV, value); return value; } @@ -963,11 +963,11 @@ int SSMReadAdbSwitchValue(void) unsigned char switch_val = 0; if (SSMReadNTypes(SSM_RW_ADB_SWITCH_START, 1, &switch_val) < 0) { - LOGD("%s, read switch value error", "TV"); + LOGD("%s, read switch value error", CFG_SECTION_TV); return -1; } - LOGD("%s, read switch value = %d", "TV", switch_val); + LOGD("%s, read switch value = %d", CFG_SECTION_TV, switch_val); return switch_val; } @@ -984,11 +984,11 @@ int SSMReadSerialCMDSwitchValue(void) unsigned char switch_val = 0; if (SSMReadNTypes(SSM_RW_SERIAL_CMD_SWITCH_START, 1, &switch_val) < 0) { - LOGD("%s, read switch value error", "TV"); + LOGD("%s, read switch value error", CFG_SECTION_TV); return -1; } - LOGD("%s, read switch value = %d", "TV", switch_val); + LOGD("%s, read switch value = %d", CFG_SECTION_TV, switch_val); return switch_val; } @@ -1005,11 +1005,11 @@ int SSMReadNoiseGateThresholdValue(void) unsigned char tmp_val = 0; if (SSMReadNTypes(SSM_RW_NOISE_GATE_THRESHOLD_START, 1, &tmp_val) < 0) { - LOGD("%s, read NoiseGateThreshold error", "TV"); + LOGD("%s, read NoiseGateThreshold error", CFG_SECTION_TV); return -1; } - LOGD("%s, read NoiseGateThreshold = %d", "TV", tmp_val); + LOGD("%s, read NoiseGateThreshold = %d", CFG_SECTION_TV, tmp_val); return tmp_val; } @@ -1030,13 +1030,13 @@ int SSMReadGraphyBacklight(void) unsigned char value = 0; if (SSMReadNTypes(SSM_RW_UI_GRHPHY_BACKLIGHT_START, 1, &value) < 0) { - LOGD("%s, read graphybacklight error.\n", "TV"); + LOGD("%s, read graphybacklight error.\n", CFG_SECTION_TV); return -1; } if (/*value < 0 || */value > 100) { LOGD("%s, range of graphybacklight (%d) is not between 0-100.\n", - "TV", value); + CFG_SECTION_TV, value); return -1; } @@ -1055,7 +1055,7 @@ int SSMReadFastSuspendFlag(void) unsigned char value = 0; if (SSMReadNTypes(SSM_RW_FASTSUSPEND_FLAG_START, 1, &value) < 0) { - LOGD("%s, read FastSuspendFlag error.\n", "TV"); + LOGD("%s, read FastSuspendFlag error.\n", CFG_SECTION_TV); return -1; } @@ -1082,7 +1082,7 @@ int SSMReadCABufferSizeValue(void) unsigned char data[] = { 0, 0 }; if (SSMReadNTypes(SSM_RW_CA_BUFFER_SIZE_START, 2, data) < 0) { - LOGE("%s, read ca_buffer_size error", "TV"); + LOGE("%s, read ca_buffer_size error", CFG_SECTION_TV); return 0; } @@ -1264,7 +1264,7 @@ int SSMDeviceMarkCheck() for (i = 0; i < 3; i++) { tmp_ch = 0; if (SSMReadNTypes(mark_offset[i], 1, &tmp_ch) < 0) { - LOGE("%s, SSMDeviceMarkCheck Read Mark failed!!!\n", "TV"); + LOGE("%s, SSMDeviceMarkCheck Read Mark failed!!!\n", CFG_SECTION_TV); break; } @@ -1272,7 +1272,7 @@ int SSMDeviceMarkCheck() failed_count += 1; LOGE( "%s, SSMDeviceMarkCheck Mark[%d]'s offset = %d, Mark[%d]'s Value = %d, read value = %d.\n", - "TV", i, mark_offset[i], i, mark_values[i], tmp_ch); + CFG_SECTION_TV, i, mark_offset[i], i, mark_values[i], tmp_ch); } } @@ -1316,7 +1316,7 @@ static int SSMGetPreCopyingEnableCfg() { const char *prop_value; - prop_value = config_get_str("TV", "ssm.precopying.en", "null"); + prop_value = config_get_str(CFG_SECTION_TV, "ssm.precopying.en", "null"); if (strcmp(prop_value, "null") == 0 || strcmp(prop_value, "0") == 0 || strcmp(prop_value, "disable") == 0) { return 0; @@ -1333,7 +1333,7 @@ static int SSMGetPreCopyingDevicePathCfg(char dev_path[]) return -1; } - prop_value = config_get_str("TV", "ssm.precopying.devpath", "null"); + prop_value = config_get_str(CFG_SECTION_TV, "ssm.precopying.devpath", "null"); if (strcmp(prop_value, "null") == 0) { return 1; } @@ -1352,7 +1352,7 @@ int SSMHandlePreCopying() char tmpPreCopyingDevicePath[256] = { '\0' }; if (SSMGetPreCopyingEnableCfg() == 0) { - LOGD("%s, Pre copying is disable now.\n", "TV"); + LOGD("%s, Pre copying is disable now.\n", CFG_SECTION_TV); return 0; } @@ -1363,7 +1363,7 @@ int SSMHandlePreCopying() device_fd = open(tmpPreCopyingDevicePath, O_RDONLY); if (device_fd < 0) { - LOGE("%s, Open device file \"%s\" error: %s.\n", "TV", + LOGE("%s, Open device file \"%s\" error: %s.\n", CFG_SECTION_TV, tmpPreCopyingDevicePath, strerror(errno)); return -1; } @@ -1417,9 +1417,9 @@ int GetSSMCfgBufferData(const char *key_str, int *buf_item_count, int radix, const char *config_value; char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - config_value = config_get_str("TV", key_str, "null"); + config_value = config_get_str(CFG_SECTION_TV, key_str, "null"); if (strcasecmp(config_value, "null") == 0) { - LOGE("%s, can't get config \"%s\"!!!\n", "TV", key_str); + LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); return -1; } @@ -1438,7 +1438,7 @@ int GetSSMCfgBufferData(const char *key_str, int *buf_item_count, int radix, cfg_item_count += 1; } else { LOGE("%s, we get data count more than desire count (%d)!!!\n", - "TV", *buf_item_count); + CFG_SECTION_TV, *buf_item_count); return -1; } } diff --git a/tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp b/tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp index 7c26695..15fb708 100644 --- a/tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp +++ b/tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp @@ -169,9 +169,9 @@ CTvSettingDeviceFactory::~CTvSettingDeviceFactory() CBlobDevice *CTvSettingDeviceFactory::getSaveDeviceFromConfigFile() { - const char *device_type = config_get_str("SETTING", "store.device.type", "file"); - const char *device_path = config_get_str("SETTING", "device_path", "/param/default_data"); - const char *device_size = config_get_str("SETTING", "device_size", "0x1000"); + const char *device_type = config_get_str(CFG_SECTION_SETTING, "store.device.type", "file"); + const char *device_path = config_get_str(CFG_SECTION_SETTING, "device_path", "/param/default_data"); + const char *device_size = config_get_str(CFG_SECTION_SETTING, "device_size", "0x1000"); LOGD("getSaveDeviceFromConfigFile type=%s path=%s size=%s", device_type, device_path, device_size); // diff --git a/tvapi/libtv/tvsetting/TvKeyData.cpp b/tvapi/libtv/tvsetting/TvKeyData.cpp index ac5ecb6..747b527 100644 --- a/tvapi/libtv/tvsetting/TvKeyData.cpp +++ b/tvapi/libtv/tvsetting/TvKeyData.cpp @@ -241,7 +241,7 @@ int KeyData_GetBarCodeDataLen() const char *config_value; if (gSSMBarCodeLen <= 0) { - config_value = config_get_str("TV", CS_BARCODE_LEN_CFG, "null"); + config_value = config_get_str(CFG_SECTION_TV, CS_BARCODE_LEN_CFG, "null"); if (strcmp(config_value, "null") == 0) { gSSMBarCodeLen = 32; } else { @@ -504,7 +504,7 @@ static int GetSSMMacAddressStartWorkEnableCFG() { const char *config_value; - config_value = config_get_str("TV", CS_MAC_ADDRESS_STARTWRK_EN_CFG, "null"); + config_value = config_get_str(CFG_SECTION_TV, CS_MAC_ADDRESS_STARTWRK_EN_CFG, "null"); if (strcmp(config_value, "null") == 0) { LOGD( "%s, get config is \"%s\", return 0 to not enable mac address start work.\n", @@ -638,7 +638,7 @@ static void *SSMMacAddressStartWorkMainApp(void *data) LOGD("%s, entering...\n", __FUNCTION__); if (GetSSMMacAddressStartWorkEnableCFG() == 0) { - LOGE("%s, ssm mac address start work is not enable.\n", "TV"); + LOGE("%s, ssm mac address start work is not enable.\n", CFG_SECTION_TV); return NULL; } @@ -720,7 +720,7 @@ static int KillMacAddressStartWorkThread() if (i == tmp_timeout_count) { LOGE( "%s, we have try %d times, but the mac address start work thread's exec flag is still(%d)!!!\n", - "TV", tmp_timeout_count, + CFG_SECTION_TV, tmp_timeout_count, GetMacAddressStartWorkThreadExecFlag()); return -1; } @@ -793,7 +793,7 @@ int GetSSMHandleHDCPKeyEnableCFG() { const char *config_value; - config_value = config_get_str("TV", CS_HDCP_KEY_EN_CFG, "null"); + config_value = config_get_str(CFG_SECTION_TV, CS_HDCP_KEY_EN_CFG, "null"); #if 0 LOGD("%s, get \"%s\" is \"%s\".\n", __FUNCTION__, CS_HDCP_KEY_EN_CFG, config_value); @@ -812,7 +812,7 @@ int GetSSMHandleHDCPKeyDemoEnableCFG() { const char *config_value; - config_value = config_get_str("TV", CS_HDCP_KEY_DEMO_EN_CFG, "null"); + config_value = config_get_str(CFG_SECTION_TV, CS_HDCP_KEY_DEMO_EN_CFG, "null"); #if 0 LOGD("%s, get \"%s\" is \"%s\".\n", __FUNCTION__, CS_HDCP_KEY_DEMO_EN_CFG, config_value); @@ -855,14 +855,14 @@ int RealHandleHDCPKey(unsigned char hdcp_key_buf[]) dev_fd = open("/sys/class/hdmirx/hdmirx0/edid", O_RDWR); if (dev_fd < 0) { - LOGE("%s, open edid file ERROR(%s)!!\n", "TV", strerror(errno)); + LOGE("%s, open edid file ERROR(%s)!!\n", CFG_SECTION_TV, strerror(errno)); return -1; } if (write(dev_fd, hdcp_key_buf, CC_HDCP_KEY_TOTAL_SIZE) < 0) { close(dev_fd); dev_fd = -1; - LOGE("%s, write edid file ERROR(%s)!!\n", "TV", strerror(errno)); + LOGE("%s, write edid file ERROR(%s)!!\n", CFG_SECTION_TV, strerror(errno)); return -1; } @@ -879,7 +879,7 @@ int GetSSMHandleHDMIEdidByCustomerEnableCFG() { const char *config_value; - config_value = config_get_str("TV", CS_HDMI_EDID_EN_CFG, "null"); + config_value = config_get_str(CFG_SECTION_TV, CS_HDMI_EDID_EN_CFG, "null"); #if 0 LOGD("%s, get \"%s\" is \"%s\".\n", __FUNCTION__, CS_HDMI_EDID_EN_CFG, config_value); @@ -903,7 +903,7 @@ int RealHandleHDMIEdid(unsigned char customer_hdmi_edid_buf[]) dev_fd = open("/sys/class/hdmirx/hdmirx0/edid", O_RDWR); if (dev_fd < 0) { - LOGE("%s, open edid file ERROR(%s)!!\n", "TV", strerror(errno)); + LOGE("%s, open edid file ERROR(%s)!!\n", CFG_SECTION_TV, strerror(errno)); return -1; } @@ -911,7 +911,7 @@ int RealHandleHDMIEdid(unsigned char customer_hdmi_edid_buf[]) < 0) { close(dev_fd); dev_fd = -1; - LOGE("%s, write edid file ERROR(%s)!!\n", "TV", strerror(errno)); + LOGE("%s, write edid file ERROR(%s)!!\n", CFG_SECTION_TV, strerror(errno)); return -1; } @@ -925,7 +925,7 @@ int AppendEdidPrefixCode(unsigned char customer_hdmi_edid_buf[], unsigned char hdmi_edid_buf[]) { if (customer_hdmi_edid_buf == NULL || hdmi_edid_buf == NULL) { - LOGE("%s, Append hdmi edid's prefixCode ERROR(%s)!!\n", "TV", + LOGE("%s, Append hdmi edid's prefixCode ERROR(%s)!!\n", CFG_SECTION_TV, strerror(errno)); return -1; } @@ -982,10 +982,10 @@ static int GetFilePathCFG(char *key_str, char path_buf[]) const char *cfg_value; path_buf[0] = '\0'; - cfg_value = config_get_str("TV", key_str, ""); + cfg_value = config_get_str(CFG_SECTION_TV, key_str, ""); strcpy(path_buf, cfg_value); #if 0 - LOGD("%s, get \"%s\" is \"%s\".\n", "TV", key_str, path_buf); + LOGD("%s, get \"%s\" is \"%s\".\n", CFG_SECTION_TV, key_str, path_buf); #endif return tmp_ret; } @@ -994,12 +994,12 @@ static int GetFileOffsetCFG(char *key_str) { const char *cfg_value; - cfg_value = config_get_str("TV", key_str, "null"); + cfg_value = config_get_str(CFG_SECTION_TV, key_str, "null"); #if 0 - LOGD("%s, get \"%s\" is \"%s\".\n", "TV", key_str, cfg_value); + LOGD("%s, get \"%s\" is \"%s\".\n", CFG_SECTION_TV, key_str, cfg_value); #endif if (strcmp(cfg_value, "null") == 0) { - LOGD("%s, get config \"%s\" is \"%s\", return 0 for default.\n", "TV", + LOGD("%s, get config \"%s\" is \"%s\", return 0 for default.\n", CFG_SECTION_TV, key_str, cfg_value); return 0; } @@ -1011,7 +1011,7 @@ static int handleDataFilePath(char *file_name, int offset, int nsize, char file_path[]) { if (file_name == NULL) { - LOGE("%s, file_name is NULL!!!\n", "TV"); + LOGE("%s, file_name is NULL!!!\n", CFG_SECTION_TV); return -1; } @@ -1027,7 +1027,7 @@ static int ReadDataFromFile(char *file_name, int offset, int nsize, char file_path[512] = { '\0' }; if (data_buf == NULL) { - LOGE("%s, data_buf is NULL!!!\n", "TV"); + LOGE("%s, data_buf is NULL!!!\n", CFG_SECTION_TV); return -1; } @@ -1046,7 +1046,7 @@ static int ReadDataFromFile(char *file_name, int offset, int nsize, device_fd = open(tmp_ptr, O_RDONLY); if (device_fd < 0) { - LOGE("%s: open file \"%s\" error(%s).\n", "TV", file_name, + LOGE("%s: open file \"%s\" error(%s).\n", CFG_SECTION_TV, file_name, strerror(errno)); return -1; } @@ -1069,7 +1069,7 @@ static int SaveDataToFile(char *file_name, int offset, int nsize, char file_path[512] = { '\0' }; if (data_buf == NULL) { - LOGE("%s, data_buf is NULL!!!\n", "TV"); + LOGE("%s, data_buf is NULL!!!\n", CFG_SECTION_TV); return -1; } @@ -1088,7 +1088,7 @@ static int SaveDataToFile(char *file_name, int offset, int nsize, device_fd = open(tmp_ptr, O_RDWR | O_SYNC); if (device_fd < 0) { - LOGE("%s: open file \"%s\" error(%s).\n", "TV", file_name, + LOGE("%s: open file \"%s\" error(%s).\n", CFG_SECTION_TV, file_name, strerror(errno)); return -1; } @@ -1114,12 +1114,12 @@ static int RealRWData(RWDataInfo *data_info) LOGD("%s, file_name is %s.\n", __FUNCTION__, file_name); #endif if (strlen(file_name) == 0) { - LOGE("%s, length of file_name is 0!!!\n", "TV"); + LOGE("%s, length of file_name is 0!!!\n", CFG_SECTION_TV); return -2; } if (data_info->rw_off < 0) { - LOGE("%s, data_info->rw_off (%d) is less than 0!!!\n", "TV", + LOGE("%s, data_info->rw_off (%d) is less than 0!!!\n", CFG_SECTION_TV, data_info->rw_off); return -1; } @@ -1127,14 +1127,14 @@ static int RealRWData(RWDataInfo *data_info) if (data_info->rw_off + data_info->rw_size > data_info->max_size) { LOGE( "%s, data_info->rw_off + data_info->rw_size (%d) is more than data_info->max_size(%d) !!!\n", - "TV", data_info->rw_off + data_info->rw_size, + CFG_SECTION_TV, data_info->rw_off + data_info->rw_size, data_info->max_size); return -1; } file_off = GetFileOffsetCFG(data_info->off_cfg_name); if (file_off < 0) { - LOGE("%s, file_off (%d) is less than 0!!!\n", "TV", file_off); + LOGE("%s, file_off (%d) is less than 0!!!\n", CFG_SECTION_TV, file_off); return -1; } @@ -1321,7 +1321,7 @@ int GetHDMIEdidFromFile(int rd_off, int rd_size, int port, tmpInfo.path_cfg_name = (char *) CS_HDMI_PORT3_EDID_FILE_PATH_CFG; break; default: - LOGE("%s, port is error, =%d\n", "TV", port); + LOGE("%s, port is error, =%d\n", CFG_SECTION_TV, port); tmpInfo.path_cfg_name = (char *) CS_HDMI_EDID_FILE_PATH_CFG; break; } diff --git a/tvapi/libtv/tvsetting/audio_cfg.cpp b/tvapi/libtv/tvsetting/audio_cfg.cpp index f19ff35..523db76 100644 --- a/tvapi/libtv/tvsetting/audio_cfg.cpp +++ b/tvapi/libtv/tvsetting/audio_cfg.cpp @@ -40,39 +40,39 @@ int GetAudioAmpMasterNolinePointData(int get_type, const char *value_buf, int da { const char *config_value; if (value_buf != NULL) { - config_value = config_get_str("TV", value_buf, "null"); + config_value = config_get_str(CFG_SECTION_TV, value_buf, "null"); } else { switch (get_type) { case CC_GET_LUT_TV: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.tv", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.tv", "null"); } break; case CC_GET_LUT_AV: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.av", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.av", "null"); } break; case CC_GET_LUT_COMP: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.comp", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.comp", "null"); } break; case CC_GET_LUT_HDMI: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.hdmi", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.hdmi", "null"); } break; case CC_GET_LUT_VGA: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.vga", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.vga", "null"); } break; case CC_GET_LUT_MPEG: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.mpeg", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.mpeg", "null"); } break; case CC_GET_LUT_HDMI_4K2K: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.hdmi4k2k", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.hdmi4k2k", "null"); } break; case CC_GET_LUT_USB_4K2K: { - config_value = config_get_str("TV", "audio.amp.master.noline.point.data.usb4k2k", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.data.usb4k2k", "null"); } break; default: { @@ -82,7 +82,7 @@ int GetAudioAmpMasterNolinePointData(int get_type, const char *value_buf, int da } } if (strcasecmp(config_value, "null") == 0) { - //LOGE("%s, can't get config \"%s\"!!!\n", "TV", key_str); + //LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); return -1; } @@ -112,7 +112,7 @@ int GetDefault_EQGain_Table(int *EqTable) int GetAudioEQPresetBufferPtr(int *EqTable) { int bufs_count = 0, buf_item_count = 0; - const char *config_value = config_get_str("TV", "audio.eq.presetbuf", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.eq.presetbuf", "null"); if (strcasecmp(config_value, "null") == 0) { return -1; } @@ -155,7 +155,7 @@ int GetAudioAmpMainvolBuf(const char *TableKeyName, int data_buf[]) int bufs_count = 0, buf_item_count = 0; const char *config_value; - config_value = config_get_str("TV", TableKeyName, "null"); + config_value = config_get_str(CFG_SECTION_TV, TableKeyName, "null"); if (strcasecmp(config_value, "null") == 0) { return -1; } @@ -192,39 +192,39 @@ int GetAudioAmpSupbassvolBuf(int get_type, int data_buf[]) switch (get_type) { case CC_GET_LUT_TV: { - config_value = config_get_str("TV", "audio.amp.supbassvol.tv.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.tv.lutbuf", "null"); } break; case CC_GET_LUT_AV: { - config_value = config_get_str("TV", "audio.amp.supbassvol.av.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.av.lutbuf", "null"); } break; case CC_GET_LUT_COMP: { - config_value = config_get_str("TV", "audio.amp.supbassvol.comp.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.comp.lutbuf", "null"); } break; case CC_GET_LUT_HDMI: { - config_value = config_get_str("TV", "audio.amp.supbassvol.hdmi.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.hdmi.lutbuf", "null"); } break; case CC_GET_LUT_VGA: { - config_value = config_get_str("TV", "audio.amp.supbassvol.vga.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.vga.lutbuf", "null"); } break; case CC_GET_LUT_MPEG: { - config_value = config_get_str("TV", "audio.amp.supbassvol.mpeg.lutbuf", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.mpeg.lutbuf", "null"); } break; case CC_GET_LUT_HDMI_4K2K: { - config_value = config_get_str("TV", "audio.amp.supbassvol.hdmi4k2k.lb.name", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.hdmi4k2k.lb.name", "null"); } break; case CC_GET_LUT_USB_4K2K: { - config_value = config_get_str("TV", "audio.amp.supbassvol.usb4k2k.lb.name", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.usb4k2k.lb.name", "null"); } break; @@ -261,7 +261,7 @@ int GetAudioAmpSupbassvolBuf(int get_type, int data_buf[]) int GetAudioAmplifierMasterNoLineSwitchFlag() { - const char *config_value = config_get_str("TV", "audio.amp.master.noline.switch", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.switch", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -272,7 +272,7 @@ int GetAudioAmplifierMasterNoLineSwitchFlag() int GetAudioAmplifierSupperBassNoLineSwitchFlag() { - const char *config_value = config_get_str("TV", "audio.amp.supperbass.noline.switch", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.noline.switch", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -283,7 +283,7 @@ int GetAudioAmplifierSupperBassNoLineSwitchFlag() int GetAudioAmplifierMasterNoLinePointsCount() { - const char *config_value = config_get_str("TV", "audio.amp.master.noline.point.cnt", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.noline.point.cnt", "null"); if (strcmp(config_value, "null") == 0) { return 11; @@ -294,7 +294,7 @@ int GetAudioAmplifierMasterNoLinePointsCount() int GetAudioAmplifierSupperBassNoLinePointsCount() { - const char *config_value = config_get_str("TV", "audio.amp.supperbass.noline.point.cnt", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.noline.point.cnt", "null"); if (strcmp(config_value, "null") == 0) { return 5; @@ -305,10 +305,10 @@ int GetAudioAmplifierSupperBassNoLinePointsCount() int GetAudioAmplifierBalanceExchangeCFG() { - const char *config_value = config_get_str("TV", "audio.amp.balance.exchg", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.balance.exchg", "null"); // if (data_buf[0] >= 0 && data_buf[0] <= 100) { - // LOGD("%s, we have get the index buffer.\n", "TV"); + // LOGD("%s, we have get the index buffer.\n", CFG_SECTION_TV); // return 0; // } @@ -321,7 +321,7 @@ int GetAudioAmplifierBalanceExchangeCFG() int GetAudioMainVolLutBufCFGIndexModifyEnable() { - const char *config_value = config_get_str("TV", "audio.amp.master.cfgindex.mod.en", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.master.cfgindex.mod.en", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -347,7 +347,7 @@ int GetAudioMainVolLutBufNameModifyUbootenvCFG() int GetAudioMainVolLutBufNameModifyEnableCFG() { - const char *config_value = config_get_str("TV", "audio.amp.mainvol.lutbufname.mod.en", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.mainvol.lutbufname.mod.en", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -359,7 +359,7 @@ int GetAudioMainVolLutBufNameModifyEnableCFG() int GetAudioSupperBassVolLutBufCFGIndexModifyEnable() { - const char *config_value = config_get_str("TV", "audio.amp.supperbass.cfgindex.mod.en", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supperbass.cfgindex.mod.en", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -370,7 +370,7 @@ int GetAudioSupperBassVolLutBufCFGIndexModifyEnable() int GetAudioSupperBassVolLutBufNameModifyEnableCFG() { - const char *config_value = config_get_str("TV", "audio.amp.supbassvol.lutbufname.mod.en", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.amp.supbassvol.lutbufname.mod.en", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -382,7 +382,7 @@ int GetAudioSupperBassVolLutBufNameModifyEnableCFG() int GetAudioDVISupportEnable() { - const char *config_value = config_get_str("TV", "audio.dvi.support.enable", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.dvi.support.enable", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -394,7 +394,7 @@ int GetAudioDVISupportEnable() int GetTvAudioCardName(char tv_card_name_buf[]) { - const char *value = config_get_str("TV", "audio.tv.card.name", "null"); + const char *value = config_get_str(CFG_SECTION_TV, "audio.tv.card.name", "null"); strcpy(tv_card_name_buf, value); if (strcmp(value, "null") == 0) { @@ -406,7 +406,7 @@ int GetTvAudioCardName(char tv_card_name_buf[]) int GetTvAudioCardNeedSet() { - const char *config_value = config_get_str("TV", "audio.tv.card.needset", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.tv.card.needset", "null"); if (strcmp(config_value, "null") == 0) { return 0; } @@ -421,7 +421,7 @@ int GetTvAudioCardNeedSet() int GetAudioEffectAmplifierGainCfg(const char *cfg_name, int def_gain_val, int max_gain_val) { int tmp_val; - const char *config_value = config_get_str("TV", cfg_name, "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); if (strcmp(config_value, "null") == 0) { tmp_val = def_gain_val; } else { @@ -437,7 +437,7 @@ int GetAudioEffectAmplifierGainCfg(const char *cfg_name, int def_gain_val, int m int GetAudioSRSSourroundEnableCFG() { - const char *config_value = config_get_str("TV", "audio.srs.sourround.enable", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.srs.sourround.enable", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -449,7 +449,7 @@ int GetAudioSRSSourroundEnableCFG() int GetAudioSRSGainCfg(const char *cfg_name, int def_gain_val) { int tmp_val = 0; - const char *config_value = config_get_str("TV", cfg_name, "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); if (strcmp(config_value, "null") == 0) { tmp_val = def_gain_val; @@ -470,7 +470,7 @@ int GetAudioSRSSupperBassTrubassSpeakerSizeCfg() strcpy(cfg_name, "audio.srs.turbass.speakersize"); - const char *config_value = config_get_str("TV", cfg_name, "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, cfg_name, "null"); if (strcmp(config_value, "null") == 0) { return -1; @@ -486,7 +486,7 @@ int GetAudioSRSSupperBassTrubassSpeakerSizeCfg() int GetAudioDumpDataEnableFlagCfg() { - const char *config_value = config_get_str("TV", "audio.dump.data.en", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.dump.data.en", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -497,7 +497,7 @@ int GetAudioDumpDataEnableFlagCfg() int GetAudioSupperBassSwitchDisableCFG() { - const char *config_value = config_get_str("TV", "audio.supperbass.switch.disable", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.supperbass.switch.disable", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -508,7 +508,7 @@ int GetAudioSupperBassSwitchDisableCFG() int GetAudioWallEffectTypeCfg() { - const char *config_value = config_get_str("TV", "audio.walleffect.type", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.walleffect.type", "null"); if (strcmp(config_value, "null") == 0) { return 0; @@ -519,7 +519,7 @@ int GetAudioWallEffectTypeCfg() int Get2d4gHeadsetEnable() { - const char *config_value = config_get_str ( "TV", "tvin.2d4G.headset.en", "null" ); + const char *config_value = config_get_str ( CFG_SECTION_TV, "tvin.2d4G.headset.en", "null" ); if (strcmp(config_value, "enable") == 1) { return 1; } @@ -530,12 +530,12 @@ int Get2d4gHeadsetEnable() const char *GetAudExtDacLibPath() { - return config_get_str("TV", "audio.external.dac.libpath", "/system/lib/libdac.so"); + return config_get_str(CFG_SECTION_TV, "audio.external.dac.libpath", "/system/lib/libdac.so"); } int GetKaraokAvEnable() { - const char *config_value = config_get_str("TV", "audio.switch.karaok.av.enable", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.switch.karaok.av.enable", "null"); if (strtoul(config_value, NULL, 10) == 1) return 1; @@ -552,9 +552,9 @@ int GetDefaultAvOutGainBuf(int *nAvoutTable) int GetAvOutGainBuf_Cfg(int *nAvoutTable) { int bufs_count = 0, buf_item_count = 0; - const char *config_value = config_get_str("TV", "audio.avoutgain.presetbuf", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.avoutgain.presetbuf", "null"); if (strcasecmp(config_value, "null") == 0) { - // LOGE("%s, can't get config \"%s\"!!!\n", "TV", key_str); + // LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); return -1; } @@ -585,7 +585,7 @@ int GetAvOutGainBuf_Cfg(int *nAvoutTable) int GetADCDigitalCaptureVol_Cfg(void) { int capture_vol = 0; - const char *config_value = config_get_str("TV", "audio.adc.digital.capture.vol", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.adc.digital.capture.vol", "null"); if (strcmp(config_value, "null") == 0) { return -1; @@ -596,7 +596,7 @@ int GetADCDigitalCaptureVol_Cfg(void) int GetAudioInternalDacPGAInGain_Cfg(void) { - const char *config_value = config_get_str("TV", "audio.internal.dac.pga_in.gain", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.pga_in.gain", "null"); if (strcmp(config_value, "null") == 0) { return 16; @@ -610,11 +610,11 @@ int GetAudioInternalDACDigitalPlayBackVolume_Cfg(int audio_src_in_type) const char *config_value = NULL; if (audio_src_in_type == 2) { // CC_AUDIO_IN_SOURCE_HDMI - config_value = config_get_str("TV", "audio.internal.dac.playback.volume_hdmi", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_hdmi", "null"); } else if (audio_src_in_type == 0) { // CC_AUDIO_IN_SOURCE_LINEIN - config_value = config_get_str("TV", "audio.internal.dac.playback.volume_linein", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_linein", "null"); } else if (audio_src_in_type == 1) { // CC_AUDIO_IN_SOURCE_ATV - config_value = config_get_str("TV", "audio.internal.dac.playback.volume_atv", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.internal.dac.playback.volume_atv", "null"); } if (strcmp(config_value, "null") == 0) { @@ -627,32 +627,32 @@ int GetAudioInternalDACDigitalPlayBackVolume_Cfg(int audio_src_in_type) int GetAudioOutputSwapStatus(tv_source_input_t source_input) { int sw_status = 0; - const char *config_value = config_get_str("TV", "audio.output.swap.enable", "null"); + const char *config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.enable", "null"); if ( strcmp ( config_value, "enable" ) == 0 ) { switch (source_input) { case SOURCE_AV1: - config_value = config_get_str("TV", "audio.output.swap.av1", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.av1", "null"); break; case SOURCE_AV2: - config_value = config_get_str("TV", "audio.output.swap.av2", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.av2", "null"); break; case SOURCE_HDMI1: - config_value = config_get_str("TV", "audio.output.swap.hdmi1", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi1", "null"); break; case SOURCE_HDMI2: - config_value = config_get_str("TV", "audio.output.swap.hdmi2", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi2", "null"); break; case SOURCE_HDMI3: - config_value = config_get_str("TV", "audio.output.swap.hdmi3", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.hdmi3", "null"); break; case SOURCE_TV: - config_value = config_get_str("TV", "audio.output.swap.tv", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.tv", "null"); break; case SOURCE_DTV: - config_value = config_get_str("TV", "audio.output.swap.dtv", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.dtv", "null"); break; case SOURCE_MPEG: - config_value = config_get_str("TV", "audio.output.swap.mpeg", "null"); + config_value = config_get_str(CFG_SECTION_TV, "audio.output.swap.mpeg", "null"); break; default: break; @@ -669,7 +669,7 @@ int GetAudioArchitectureTypeCFG() static int architecture_type = -1; const char *config_value = NULL; - config_value = config_get_str ( "TV", "audio.architecture.type", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "audio.architecture.type", "null" ); if (strcasecmp(config_value, "null") == 0) { architecture_type = CC_DAC_G9TV_EXTERNAL_DAC_OFF_BOARD_FBC; } else if ((strcasecmp(config_value, "t866_external_dac_offboard_fbc") == 0) || (strcasecmp(config_value, "g9tv_external_dac_offboard_fbc") == 0)) { @@ -699,7 +699,7 @@ int GetAudioResampleTypeCFG() gAudioResampleType = 0; char *pSave; - config_value = config_get_str ( "TV", "audio.resample.type", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "audio.resample.type", "null" ); strncpy(cfg_buf, config_value, sizeof(cfg_buf)); if (strcmp(cfg_buf, "") != 0) { token = strtok_r(cfg_buf, strDelimit, &pSave); diff --git a/tvapi/libtv/tvutils/tvutils.cpp b/tvapi/libtv/tvutils/tvutils.cpp index e957467..88060fb 100644 --- a/tvapi/libtv/tvutils/tvutils.cpp +++ b/tvapi/libtv/tvutils/tvutils.cpp @@ -94,13 +94,13 @@ static int Miscioctl(const char *file_path, int request, ...) void *arg; if (file_path == NULL) { - LOGE("%s, file path is NULL!!!\n", "TV"); + LOGE("%s, file path is NULL!!!\n", CFG_SECTION_TV); return -1; } fd = open(file_path, O_RDWR); if (fd < 0) { - LOGE("%s, Open %s ERROR(%s)!!\n", "TV", file_path, strerror(errno)); + LOGE("%s, Open %s ERROR(%s)!!\n", CFG_SECTION_TV, file_path, strerror(errno)); return -1; } @@ -124,24 +124,24 @@ int cfg_get_one_item(const char *key_str, const char *strDelimit, int item_index char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; if (key_str == NULL) { - LOGE("%s, key_str's pointer is NULL.\n", "TV"); + LOGE("%s, key_str's pointer is NULL.\n", CFG_SECTION_TV); return -1; } if (cfg_str == NULL) { - LOGE("%s, cfg_str's pointer is NULL.\n", "TV"); + LOGE("%s, cfg_str's pointer is NULL.\n", CFG_SECTION_TV); return -1; } if (item_index < 0) { - LOGE("%s, item_index can't be less than 0.\n", "TV"); + LOGE("%s, item_index can't be less than 0.\n", CFG_SECTION_TV); return -1; } - config_value = config_get_str("TV", key_str, "null"); + config_value = config_get_str(CFG_SECTION_TV, key_str, "null"); if (strcasecmp(config_value, "null") == 0) { cfg_str[0] = '\0'; - LOGE("%s, can't get config \"%s\"!!!\n", "TV", key_str); + LOGE("%s, can't get config \"%s\"!!!\n", CFG_SECTION_TV, key_str); return -1; } @@ -175,22 +175,22 @@ int cfg_split(char *line_data, char *strDelimit, int *item_cnt, char **item_bufs char *token = NULL; if (line_data == NULL) { - LOGE("%s, line_data is NULL", "TV"); + LOGE("%s, line_data is NULL", CFG_SECTION_TV); return -1; } if (strDelimit == NULL) { - LOGE("%s, strDelimit is NULL", "TV"); + LOGE("%s, strDelimit is NULL", CFG_SECTION_TV); return -1; } if (item_cnt == NULL) { - LOGE("%s, item_cnt is NULL", "TV"); + LOGE("%s, item_cnt is NULL", CFG_SECTION_TV); return -1; } if (item_bufs == NULL) { - LOGE("%s, item_bufs is NULL", "TV"); + LOGE("%s, item_bufs is NULL", CFG_SECTION_TV); return -1; } @@ -404,7 +404,7 @@ static int setServer(const char *fileName) sock = socket(PF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - LOGE("%s, socket create failed (errno = %d: %s).\n", "TV", errno, strerror(errno)); + LOGE("%s, socket create failed (errno = %d: %s).\n", CFG_SECTION_TV, errno, strerror(errno)); return -1; } @@ -416,7 +416,7 @@ static int setServer(const char *fileName) //bind sockfd & addr ret = bind(sock, (struct sockaddr *) &srv_addr, sizeof(srv_addr)); if (ret == -1) { - LOGE("%s, cannot bind server socket.\n", "TV"); + LOGE("%s, cannot bind server socket.\n", CFG_SECTION_TV); close(sock); unlink(CS_ATV_SOCKET_FILE_NAME); return -1; @@ -425,7 +425,7 @@ static int setServer(const char *fileName) //listen sockfd ret = listen(sock, 1); if (ret == -1) { - LOGE("%s, cannot listen the client connect request.\n", "TV"); + LOGE("%s, cannot listen the client connect request.\n", CFG_SECTION_TV); close(sock); unlink(CS_ATV_SOCKET_FILE_NAME); return -1; @@ -444,13 +444,13 @@ static int acceptMessage(int listen_fd) len = sizeof(clt_addr); com_fd = accept(listen_fd, (struct sockaddr *) &clt_addr, &len); if (com_fd < 0) { - LOGE("%s, cannot accept client connect request.\n", "TV"); + LOGE("%s, cannot accept client connect request.\n", CFG_SECTION_TV); close(listen_fd); unlink(CS_ATV_SOCKET_FILE_NAME); return -1; } - LOGD("%s, com_fd = %d\n", "TV", com_fd); + LOGD("%s, com_fd = %d\n", CFG_SECTION_TV, com_fd); return com_fd; } @@ -517,11 +517,11 @@ static int parse_socket_message(char *msg_str, int *para_cnt, int para_buf[]) //read message from client memset((void *) recv_buf, 0, sizeof(recv_buf)); rd_len = read(com_fd, recv_buf, sizeof(recv_buf)); - LOGD("%s, message from client (%d)) : %s\n", "TV", rd_len, recv_buf); + LOGD("%s, message from client (%d)) : %s\n", CFG_SECTION_TV, rd_len, recv_buf); set_mode = parse_socket_message(recv_buf, ¶_count, para_buf); if (set_mode == 0) { - LOGD("%s, receive quit message, starting to quit.\n", "TV"); + LOGD("%s, receive quit message, starting to quit.\n", CFG_SECTION_TV); sprintf(recv_buf, "%s", "quiting now..."); write(com_fd, recv_buf, strlen(recv_buf) + 1); break; @@ -529,11 +529,11 @@ static int parse_socket_message(char *msg_str, int *para_cnt, int para_buf[]) ret = -1; if (para_count == 1) { - LOGD("%s, SetAudioVolumeCompensationVal value = %d\n", "TV", para_buf[0]); + LOGD("%s, SetAudioVolumeCompensationVal value = %d\n", CFG_SECTION_TV, para_buf[0]); ret = SetAudioVolumeCompensationVal(para_buf[0]); } else if (para_count == 2) { - LOGD("%s, SetAudioVolumeCompensationVal value = %d, type = %d\n", "TV", para_buf[0], para_buf[1]); + LOGD("%s, SetAudioVolumeCompensationVal value = %d, type = %d\n", CFG_SECTION_TV, para_buf[0], para_buf[1]); ret = SetAudioVolumeCompensationVal(para_buf[0]); @@ -549,7 +549,7 @@ static int parse_socket_message(char *msg_str, int *para_cnt, int para_buf[]) ret = -1; if (para_count == 1) { - LOGE("%s, mode = %d ------->\n", "TV", para_buf[0]); + LOGE("%s, mode = %d ------->\n", CFG_SECTION_TV, para_buf[0]); switch (para_buf[0]) { case 4: //BT @@ -569,9 +569,9 @@ static int parse_socket_message(char *msg_str, int *para_cnt, int para_buf[]) break; } if (ret == 0) { - LOGE("%s, sk_hdi_av_set_3d_mode return sucess.\n", "TV"); + LOGE("%s, sk_hdi_av_set_3d_mode return sucess.\n", CFG_SECTION_TV); } else { - LOGE("%s, sk_hdi_av_set_3d_mode return error(%d).\n", "TV", ret); + LOGE("%s, sk_hdi_av_set_3d_mode return error(%d).\n", CFG_SECTION_TV, ret); } } @@ -610,13 +610,13 @@ static int connectToServer(char *file_name) struct sockaddr_un addr; if (file_name == NULL) { - LOGE("%s, file name is NULL\n", "TV"); + LOGE("%s, file name is NULL\n", CFG_SECTION_TV); return -1; } sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) { - LOGE("%s, socket create failed (errno = %d: %s)\n", "TV", errno, strerror(errno)); + LOGE("%s, socket create failed (errno = %d: %s)\n", CFG_SECTION_TV, errno, strerror(errno)); return -1; } @@ -627,7 +627,7 @@ static int connectToServer(char *file_name) if (tmp_ret < 0) { // ENOENT means socket file doesn't exist // ECONNREFUSED means socket exists but nobody is listening - LOGE("%s, AF_UNIX connect failed for '%s': %s\n", "TV", file_name, strerror(errno)); + LOGE("%s, AF_UNIX connect failed for '%s': %s\n", CFG_SECTION_TV, file_name, strerror(errno)); close(sock); return -1; } @@ -641,16 +641,16 @@ static int realSendSocketMsg(char *file_name, char *msg_str, char recv_buf[]) char tmp_buf[1024]; if (file_name == NULL) { - LOGE("%s, file name is NULL\n", "TV"); + LOGE("%s, file name is NULL\n", CFG_SECTION_TV); return -1; } if (msg_str == NULL) { - LOGE("%s, msg string is NULL\n", "TV"); + LOGE("%s, msg string is NULL\n", CFG_SECTION_TV); return -1; } - LOGD("%s, message to server (%d)) : %s\n", "TV", strlen(msg_str), msg_str); + LOGD("%s, message to server (%d)) : %s\n", CFG_SECTION_TV, strlen(msg_str), msg_str); sock = connectToServer(file_name); @@ -660,10 +660,10 @@ static int realSendSocketMsg(char *file_name, char *msg_str, char recv_buf[]) if (recv_buf == NULL) { memset((void *) tmp_buf, 0, sizeof(tmp_buf)); rd_len = read(sock, tmp_buf, sizeof(tmp_buf)); - LOGD("%s, message from server (%d)) : %s\n", "TV", rd_len, tmp_buf); + LOGD("%s, message from server (%d)) : %s\n", CFG_SECTION_TV, rd_len, tmp_buf); } else { rd_len = read(sock, recv_buf, 1024); - LOGD("%s, message from server (%d)) : %s\n", "TV", rd_len, recv_buf); + LOGD("%s, message from server (%d)) : %s\n", CFG_SECTION_TV, rd_len, recv_buf); } close(sock); @@ -709,17 +709,17 @@ int I2C_WriteNbyte(int i2c_no, int dev_addr, int slave_addr, int len, unsigned c if (i2c_no == 1) { device_fd = open(CS_I2C_1_DEV_PATH, O_RDWR); if (device_fd < 0) { - LOGE("%s, Open device file %S error: %s.\n", "TV", CS_I2C_1_DEV_PATH, strerror(errno)); + LOGE("%s, Open device file %S error: %s.\n", CFG_SECTION_TV, CS_I2C_1_DEV_PATH, strerror(errno)); return -1; } } else if (i2c_no == 2) { device_fd = open(CS_I2C_2_DEV_PATH, O_RDWR); if (device_fd < 0) { - LOGE("%s, Open device file %S error: %s.\n", "TV", CS_I2C_2_DEV_PATH, strerror(errno)); + LOGE("%s, Open device file %S error: %s.\n", CFG_SECTION_TV, CS_I2C_2_DEV_PATH, strerror(errno)); return -1; } } else { - LOGE("%s, invalid i2c no (%d).\n", "TV", i2c_no); + LOGE("%s, invalid i2c no (%d).\n", CFG_SECTION_TV, i2c_no); return -1; } @@ -766,17 +766,17 @@ int I2C_ReadNbyte(int i2c_no, int dev_addr, int slave_addr, int len, unsigned ch if (i2c_no == 1) { device_fd = open(CS_I2C_1_DEV_PATH, O_RDWR); if (device_fd < 0) { - LOGE("%s, Open device file %S error: %s.\n", "TV", CS_I2C_1_DEV_PATH, strerror(errno)); + LOGE("%s, Open device file %S error: %s.\n", CFG_SECTION_TV, CS_I2C_1_DEV_PATH, strerror(errno)); return -1; } } else if (i2c_no == 2) { device_fd = open(CS_I2C_2_DEV_PATH, O_RDWR); if (device_fd < 0) { - LOGE("%s, Open device file %S error: %s.\n", "TV", CS_I2C_2_DEV_PATH, strerror(errno)); + LOGE("%s, Open device file %S error: %s.\n", CFG_SECTION_TV, CS_I2C_2_DEV_PATH, strerror(errno)); return -1; } } else { - LOGE("%s, invalid i2c no (%d).\n", "TV", i2c_no); + LOGE("%s, invalid i2c no (%d).\n", CFG_SECTION_TV, i2c_no); return -1; } @@ -838,11 +838,11 @@ int GetFileAttrIntValue(const char *fp) if (read(fd, temp_str, sizeof(temp_str)) > 0) { if (sscanf(temp_str, "%d", &temp) >= 0) { - LOGD("%s -> get %s value =%d!\n", "TV", fp, temp); + LOGD("%s -> get %s value =%d!\n", CFG_SECTION_TV, fp, temp); close(fd); return temp; } else { - LOGE("%s -> get %s value error(%s)\n", "TV", fp, strerror(errno)); + LOGE("%s -> get %s value error(%s)\n", CFG_SECTION_TV, fp, strerror(errno)); close(fd); return -1; } @@ -870,7 +870,7 @@ int *GetFileAttrIntValueStr(const char *fp) } if (read(fd, temp_str, sizeof(temp_str)) > 0) { - LOGD("%s,temp_str = %s\n", "TV", temp_str); + LOGD("%s,temp_str = %s\n", CFG_SECTION_TV, temp_str); p = strtok(temp_str, " "); while (p != NULL) { sscanf(p, "%d", &temp[i]); @@ -908,7 +908,7 @@ int Set_Fixed_NonStandard(int value) } if (ret <= 0) { - LOGE("%s -> set /sys/module/tvin_afe/parameters/force_nostd error(%s)!\n", "TV", strerror(errno)); + LOGE("%s -> set /sys/module/tvin_afe/parameters/force_nostd error(%s)!\n", CFG_SECTION_TV, strerror(errno)); } close(fd); @@ -965,7 +965,7 @@ static void UserPet_KillThread(void) } pthread_join(UserPet_ThreadId, NULL); UserPet_ThreadId = 0; - LOGD("%s, done.", "TV"); + LOGD("%s, done.", CFG_SECTION_TV); } void TvMisc_EnableWDT(bool kernelpet_disable, unsigned int userpet_enable, unsigned int kernelpet_timeout, unsigned int userpet_timeout, unsigned int userpet_reset) @@ -1135,7 +1135,7 @@ int Tv_Utils_CheckFs(void) mount_type[255] = 0; mount_opts[255] = 0; if ((match == 6) && (!strncmp(mount_dev, "/dev/block", 10))) { - LOGD("%s, %s %s %s %s %d %d!", "TV", mount_dev, mount_dir, mount_type, mount_opts, mount_freq, mount_passno); + LOGD("%s, %s %s %s %s %d %d!", CFG_SECTION_TV, mount_dev, mount_dir, mount_type, mount_opts, mount_freq, mount_passno); if (!strncmp(mount_dir, "/param", 6)) { param_status |= 0x01; } else if (!strncmp(mount_dir, "/atv", 4)) { @@ -1168,22 +1168,22 @@ int Tv_Utils_CheckFs(void) switch (param_status) { case 0x03: - LOGW("%s, param partition is read-only!", "TV"); + LOGW("%s, param partition is read-only!", CFG_SECTION_TV); break; case 0x00: - LOGW("%s, param partition can not be mounted!", "TV"); + LOGW("%s, param partition can not be mounted!", CFG_SECTION_TV); break; default: break; } switch (atv_status) { case 0x03: - LOGW("%s, atv partition is read-only!", "TV"); + LOGW("%s, atv partition is read-only!", CFG_SECTION_TV); cool_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "cool_reboot"); break; case 0x00: - LOGW("%s, atv partition can not be mounted!", "TV"); + LOGW("%s, atv partition can not be mounted!", CFG_SECTION_TV); recovery_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); default: @@ -1191,23 +1191,23 @@ int Tv_Utils_CheckFs(void) } switch (dtv_status) { case 0x03: - LOGW("%s, dtv partition is read-only!", "TV"); + LOGW("%s, dtv partition is read-only!", CFG_SECTION_TV); //android_reboot(ANDROID_RB_RESTART2, 0, "cool_reboot"); break; case 0x00: - LOGW("%s, dtv partition can not be mounted!", "TV"); + LOGW("%s, dtv partition can not be mounted!", CFG_SECTION_TV); //android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); default: break; } switch (data_status) { case 0x03: - LOGW("%s, data partition is read-only!", "TV"); + LOGW("%s, data partition is read-only!", CFG_SECTION_TV); cool_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "cool_reboot"); break; case 0x00: - LOGW("%s, data partition can not be mounted!", "TV"); + LOGW("%s, data partition can not be mounted!", CFG_SECTION_TV); recovery_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); break; @@ -1216,12 +1216,12 @@ int Tv_Utils_CheckFs(void) } switch (cache_status) { case 0x03: - LOGW("%s, cache partition is read-only!", "TV"); + LOGW("%s, cache partition is read-only!", CFG_SECTION_TV); cool_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "cool_reboot"); break; case 0x00: - LOGW("%s, cache partition can not be mounted!", "TV"); + LOGW("%s, cache partition can not be mounted!", CFG_SECTION_TV); recovery_reboot = 1; //android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); break; @@ -1244,7 +1244,7 @@ int Tv_Utils_SetFileAttrStr(const char *file_path, char val_str_buf[]) tmpfp = fopen(file_path, "w"); if (tmpfp == NULL) { - LOGE("%s, write open file %s error(%s)!!!\n", "TV", file_path, strerror(errno)); + LOGE("%s, write open file %s error(%s)!!!\n", CFG_SECTION_TV, file_path, strerror(errno)); return -1; } @@ -1262,7 +1262,7 @@ int Tv_Utils_GetFileAttrStr(const char *file_path, int buf_size, char val_str_bu tmpfp = fopen(file_path, "r"); if (tmpfp == NULL) { - LOGE("%s, read open file %s error(%s)!!!\n", "TV", file_path, strerror(errno)); + LOGE("%s, read open file %s error(%s)!!!\n", CFG_SECTION_TV, file_path, strerror(errno)); val_str_buf[0] = '\0'; return -1; } @@ -1275,12 +1275,12 @@ int Tv_Utils_GetFileAttrStr(const char *file_path, int buf_size, char val_str_bu return 0; } - -int Tv_Utils_IsFileExist(const char *file_name) +//check file exist or not +bool Tv_Utils_IsFileExist(const char *file_name) { struct stat tmp_st; - return stat(file_name, &tmp_st); + return stat(file_name, &tmp_st) == 0; } #define CC_EDID_SIZE (256) @@ -1333,10 +1333,10 @@ void monitor_info_set_date ( unsigned char *edidbuf ) edidbuf[16] = week; edidbuf[17] = ( 1900 + p->tm_year ) - 1990; - LOGD ( "###############%s##############", "TV" ); + LOGD ( "###############%s##############", CFG_SECTION_TV ); LOGD ( "Week number is %d", week ); LOGD ( "%d %02d %02d", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday ); - LOGD ( "###############%s##############", "TV" ); + LOGD ( "###############%s##############", CFG_SECTION_TV ); } @@ -1376,7 +1376,7 @@ void monitor_info_set_name ( unsigned char *edidbuf ) int config_value_len; const char *config_value; unsigned char str_manufacturer_name[14]; - config_value = config_get_str ( "TV", "tvin.hdmiedid.name", "null" ); + config_value = config_get_str ( CFG_SECTION_TV, "tvin.hdmiedid.name", "null" ); if ( strcmp ( config_value, "null" ) != 0 ) { config_value_len = strlen ( config_value ); @@ -1663,7 +1663,7 @@ int GetPlatformHaveDDFlag() { const char *config_value; - config_value = config_get_str("TV", "platform.havedd", "null"); + config_value = config_get_str(CFG_SECTION_TV, "platform.havedd", "null"); if (strcmp(config_value, "true") == 0 || strcmp(config_value, "1") == 0) { return 1; } @@ -1675,7 +1675,7 @@ int GetPlatformProjectInfoSrc() { const char *config_value; - config_value = config_get_str("TV", "platform.projectinfo.src", "null"); + config_value = config_get_str(CFG_SECTION_TV, "platform.projectinfo.src", "null"); if (strcmp(config_value, "null") == 0 || strcmp(config_value, "prop") == 0) { return 0; } else if (strcmp(config_value, "emmckey") == 0) { diff --git a/tvapi/libtv/tvutils/tvutils.h b/tvapi/libtv/tvutils/tvutils.h index a982e1b..272fcef 100644 --- a/tvapi/libtv/tvutils/tvutils.h +++ b/tvapi/libtv/tvutils/tvutils.h @@ -45,7 +45,7 @@ extern int cfg_get_one_item(const char *key_str, const char *strDelimit, int ite extern int Tv_Utils_CheckFs(void); extern int Tv_Utils_SetFileAttrStr(const char *file_path, char val_str_buf[]); extern int Tv_Utils_GetFileAttrStr(const char *file_path, int buf_size, char val_str_buf[]); -extern int Tv_Utils_IsFileExist(const char *file_name); +extern bool Tv_Utils_IsFileExist(const char *file_name); extern void monitor_info_name_init ( unsigned char *edidbuf ); extern void monitor_info_set_name ( unsigned char *edidbuf ); extern void monitor_info_set_imagesize ( unsigned char *edidbuf ); diff --git a/tvapi/libtv/vpp/CVpp.cpp b/tvapi/libtv/vpp/CVpp.cpp index d3cfdc4..005b40e 100644 --- a/tvapi/libtv/vpp/CVpp.cpp +++ b/tvapi/libtv/vpp/CVpp.cpp @@ -241,7 +241,7 @@ int CVpp::Vpp_GetVppConfig(void) { const char *strDelimit = ","; char data_str[CC_CFG_VALUE_STR_MAX_LEN] = { 0 }; - config_value = config_get_str("TV", "vpp.pqmode.depend.bklight", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.pqmode.depend.bklight", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_pqmode_depend_bklight = true; @@ -249,7 +249,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_pqmode_depend_bklight = false; } - config_value = config_get_str("TV", "vpp.color.temp.bysource", "enable"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.color.temp.bysource", "enable"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_colortemp_by_source = true; @@ -257,7 +257,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_colortemp_by_source = true; } - config_value = config_get_str("TV", "vpp.panoroma.switch", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.panoroma.switch", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_panorama_switch = true; @@ -265,7 +265,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_panorama_switch = false; } - config_value = config_get_str("TV", "vpp.backlight.reverse", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.reverse", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_backlight_reverse = true; @@ -273,7 +273,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_backlight_reverse = false; } - config_value = config_get_str("TV", "vpp.backlight.init", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.backlight.init", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_backlight_init = true; @@ -281,7 +281,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_backlight_init = false; } - config_value = config_get_str("TV", "vpp.pqwithout.hue", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.pqwithout.hue", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_pqmode_without_hue = true; @@ -289,7 +289,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_pqmode_without_hue = false; } - config_value = config_get_str("TV", "vpp.hue.reverse", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.hue.reverse", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_hue_reverse = true; @@ -297,7 +297,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_hue_reverse = false; } - config_value = config_get_str("TV", "vpp.gamma.onoff", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.gamma.onoff", "null"); if (strcmp(config_value, "disable") == 0) { mbVppCfg_gamma_onoff = true; @@ -305,7 +305,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_gamma_onoff = false; } - config_value = config_get_str("TV", "vpp.whitebalance.same_param", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.whitebalance.same_param", "null"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_whitebalance_sameparam = true; @@ -313,7 +313,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_whitebalance_sameparam = false; } - config_value = config_get_str("TV", "vpp.new.cm", "disable"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.new.cm", "disable"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_new_cm = true; @@ -321,7 +321,7 @@ int CVpp::Vpp_GetVppConfig(void) { mbVppCfg_new_cm = false; } - config_value = config_get_str("TV", "vpp.new.nr", "disable"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.new.nr", "disable"); if (strcmp(config_value, "enable") == 0) { mbVppCfg_new_nr = true; @@ -1179,7 +1179,7 @@ int CVpp::Vpp_SetXVYCCMode(vpp_xvycc_mode_t xvycc_mode, tv_source_input_type_t s memset(prop_value, '\0', 16); const char *config_value; - config_value = config_get_str("TV", "vpp.xvycc.switch_control", "null"); + config_value = config_get_str(CFG_SECTION_TV, "vpp.xvycc.switch_control", "null"); if (strcmp(config_value, "enable") == 0) { if (mpPqData->PQ_GetXVYCCParams((vpp_xvycc_mode_t) xvycc_mode, source_port, sig_fmt, is3d, @@ -2049,7 +2049,7 @@ int CVpp::CheckTempDataLable(void) { LOGD("%s, lable ok.\n", __FUNCTION__); return 1; } else { - LOGD("%s, lable error.\n", "TV"); + LOGD("%s, lable error.\n", CFG_SECTION_TV); return 0; } } @@ -2664,7 +2664,7 @@ int CVpp::FactorySetLVDSSSC(int step) { if (step > 3) step = 3; - PanelIdx = config_get_str ( "TV", "get.panel.index", "0" ); + PanelIdx = config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); panel_idx = strtoul(PanelIdx, NULL, 10); LOGD ("%s, panel_idx = %x",__FUNCTION__, panel_idx); SSMReadLVDSSSC(data); @@ -2686,7 +2686,7 @@ int CVpp::FactorySetLVDSSSC(int step) { int CVpp::FactoryGetLVDSSSC(void) { unsigned char data[2] = {0,0}; int value = 0, panel_idx = 0; - const char *PanelIdx = config_get_str ( "TV", "get.panel.index", "0" ); + const char *PanelIdx = config_get_str ( CFG_SECTION_TV, "get.panel.index", "0" ); panel_idx = strtoul(PanelIdx, NULL, 10); SSMReadLVDSSSC(data); @@ -2824,7 +2824,7 @@ int CVpp::FactorySetBacklightPWM_Frequency(int freq) { int CVpp::FactoryGetBacklightPWM_Frequency(void) { int freq = 50; - LOGD("%s,FactoryGetBacklightPWM_Frequency set freq %d .\n", "TV", freq); + LOGD("%s,FactoryGetBacklightPWM_Frequency set freq %d .\n", CFG_SECTION_TV, freq); return freq; } @@ -2851,7 +2851,7 @@ int CVpp::FactoryGetBacklightPWM_Duty(void) { } int CVpp::FactorySetLVDS_ColorDepth(int depth) { - LOGD("%s,FactorySetLVDS_ColorDepth set depth %d .\n", "TV", depth); + LOGD("%s,FactorySetLVDS_ColorDepth set depth %d .\n", CFG_SECTION_TV, depth); return 1; } diff --git a/tvapi/tvtests/android_tvtest.cpp b/tvapi/tvtests/android_tvtest.cpp index 26253b6..c22a663 100644 --- a/tvapi/tvtests/android_tvtest.cpp +++ b/tvapi/tvtests/android_tvtest.cpp @@ -1,33 +1,32 @@ #define LOG_TAG "Tv-JNI" #include -#include +#include #include #include using namespace android; - void usage(char *processname) { - fprintf(stderr, "Usage: %s [arg1]... [argn]\n", processname); - return; + fprintf(stderr, "Usage: %s [arg1]... [argn]\n", processname); + return; } int main(int argc, char **argv) { - if (argc < 2) - usage(argv[0]); - sp tv = Tv::connect(); - int cmd = atoi(argv[1]); - int arg1 = atoi(argv[2]); - //send cmd - Parcel p, r; - p.writeInt32(cmd); - p.writeInt32(arg1); - tv->processCmd(p, &r); - //exit - tv.clear(); - return 0; + if (argc < 2) + usage(argv[0]); + sp tv = TvClient::connect(); + int cmd = atoi(argv[1]); + int arg1 = atoi(argv[2]); + //send cmd + Parcel p, r; + p.writeInt32(cmd); + p.writeInt32(arg1); + tv->processCmd(p, &r); + //exit + tv.clear(); + return 0; } -- cgit