169 files changed, 64432 insertions, 116 deletions
diff --git a/tv_input.cpp b/tv_input.cpp index ea709de..822c7c8 100644 --- a/tv_input.cpp +++ b/tv_input.cpp @@ -22,7 +22,8 @@ #include <cutils/native_handle.h> #include <hardware/tv_input.h> - +#include <tv/CTv.h> +#include <tvserver/TvService.h> /*****************************************************************************/ #define ATV_DEV_ID 1 @@ -32,19 +33,20 @@ #define HDMI2_DEV_ID 5 #define HDMI3_DEV_ID 6 -typedef struct tv_input_private -{ +typedef struct tv_input_private { tv_input_device_t device; // Callback related data - const tv_input_callback_ops_t* callback; - void* callback_data; + const tv_input_callback_ops_t *callback; + void *callback_data; + //TvService* pTvService; + CTv *pTv; } tv_input_private_t; -static int notify_ATV_device_available(tv_input_private_t* priv) +static int notify_ATV_device_available(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id =ATV_DEV_ID; + tv_input_event_t event; + event.device_info.device_id = ATV_DEV_ID; event.device_info.type = TV_INPUT_TYPE_TUNER; event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; event.device_info.audio_type = AUDIO_DEVICE_NONE; @@ -52,10 +54,10 @@ static int notify_ATV_device_available(tv_input_private_t* priv) return 0; } -static int notify_DTV_device_available(tv_input_private_t* priv) +static int notify_DTV_device_available(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id =DTV_DEV_ID; + tv_input_event_t event; + event.device_info.device_id = DTV_DEV_ID; event.device_info.type = TV_INPUT_TYPE_TUNER; event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; event.device_info.audio_type = AUDIO_DEVICE_NONE; @@ -63,10 +65,10 @@ static int notify_DTV_device_available(tv_input_private_t* priv) return 0; } -static int notify_AV_device_available(tv_input_private_t* priv) +static int notify_AV_device_available(tv_input_private_t *priv) { - tv_input_event_t event; - event.device_info.device_id =AV_DEV_ID; + tv_input_event_t event; + event.device_info.device_id = AV_DEV_ID; event.device_info.type = TV_INPUT_TYPE_COMPONENT; event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; event.device_info.audio_type = AUDIO_DEVICE_NONE; @@ -74,10 +76,10 @@ static int notify_AV_device_available(tv_input_private_t* priv) return 0; } -static int notify_hdmi_device_available(tv_input_private_t* priv, int dev_id, uint32_t port_id) +static int notify_hdmi_device_available(tv_input_private_t *priv, int dev_id, uint32_t port_id) { - tv_input_event_t event; - event.device_info.device_id =dev_id; + tv_input_event_t event; + event.device_info.device_id = dev_id; event.device_info.type = TV_INPUT_TYPE_HDMI; event.type = TV_INPUT_EVENT_DEVICE_AVAILABLE; event.device_info.hdmi.port_id = port_id; @@ -86,144 +88,151 @@ static int notify_hdmi_device_available(tv_input_private_t* priv, int dev_id, ui return 0; } -static int get_stream_configs(int dev_id, int* num_configurations, const tv_stream_config_t** configs) +static int get_stream_configs(int dev_id, int *num_configurations, const tv_stream_config_t **configs) { - tv_stream_config_t* mconfig = (tv_stream_config_t*)malloc(sizeof(mconfig)); - if (!mconfig) { - return -1; - } - switch (dev_id) { - case ATV_DEV_ID: - mconfig->stream_id=ATV_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - case DTV_DEV_ID: - mconfig->stream_id=DTV_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - case AV_DEV_ID: - mconfig->stream_id=AV_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - case HDMI1_DEV_ID: - mconfig->stream_id=HDMI1_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - case HDMI2_DEV_ID: - mconfig->stream_id=HDMI2_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - case HDMI3_DEV_ID: - mconfig->stream_id=HDMI3_DEV_ID; - mconfig->type =TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; - mconfig->max_video_width = 1920; - mconfig->max_video_height = 1080; - *num_configurations = 1; - *configs = mconfig; - break; - default: - break; - } - return 0; + tv_stream_config_t *mconfig = (tv_stream_config_t *)malloc(sizeof(mconfig)); + if (!mconfig) { + return -1; + } + switch (dev_id) { + case ATV_DEV_ID: + mconfig->stream_id = ATV_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + case DTV_DEV_ID: + mconfig->stream_id = DTV_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + case AV_DEV_ID: + mconfig->stream_id = AV_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + case HDMI1_DEV_ID: + mconfig->stream_id = HDMI1_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + case HDMI2_DEV_ID: + mconfig->stream_id = HDMI2_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + case HDMI3_DEV_ID: + mconfig->stream_id = HDMI3_DEV_ID; + mconfig->type = TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE ; + mconfig->max_video_width = 1920; + mconfig->max_video_height = 1080; + *num_configurations = 1; + *configs = mconfig; + break; + default: + break; + } + return 0; } -static int tv_input_device_open(const struct hw_module_t* module, - const char* name, struct hw_device_t** device); +static int tv_input_device_open(const struct hw_module_t *module, + const char *name, struct hw_device_t **device); static struct hw_module_methods_t tv_input_module_methods = { - open: tv_input_device_open +open: + tv_input_device_open }; tv_input_module_t HAL_MODULE_INFO_SYM = { - common: { - tag: HARDWARE_MODULE_TAG, +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, +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) +static int tv_input_initialize(struct tv_input_device *dev, + 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; + 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); -/* DTV_DEVICE_AVAILABLE */ - notify_DTV_device_available(priv); -/* AV_DEVICE_AVAILABLE */ - notify_AV_device_available(priv); -/* HDMI1_DEVICE_AVAILABLE */ - notify_hdmi_device_available(priv, HDMI1_DEV_ID, 1); -/* HDMI2_DEVICE_AVAILABLE */ - notify_hdmi_device_available(priv, HDMI2_DEV_ID, 2); -/* HDMI3_DEVICE_AVAILABLE */ - notify_hdmi_device_available(priv, HDMI3_DEV_ID, 3); + /* ATV_DEVICE_AVAILABLE */ + notify_ATV_device_available(priv); + /* DTV_DEVICE_AVAILABLE */ + notify_DTV_device_available(priv); + /* AV_DEVICE_AVAILABLE */ + notify_AV_device_available(priv); + /* HDMI1_DEVICE_AVAILABLE */ + notify_hdmi_device_available(priv, HDMI1_DEV_ID, 1); + /* HDMI2_DEVICE_AVAILABLE */ + notify_hdmi_device_available(priv, HDMI2_DEV_ID, 2); + /* HDMI3_DEVICE_AVAILABLE */ + notify_hdmi_device_available(priv, HDMI3_DEV_ID, 3); 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) +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) { - if (get_stream_configs(device_id, num_configurations, configs) == 0) { - return 0; - } + if (get_stream_configs(device_id, num_configurations, configs) == 0) { + return 0; + } return -EINVAL; } -static int tv_input_open_stream(struct tv_input_device*, int, tv_stream_t*) +static int tv_input_open_stream(struct tv_input_device *, int, tv_stream_t *) { return -EINVAL; } -static int tv_input_close_stream(struct tv_input_device*, int, int) +static int tv_input_close_stream(struct tv_input_device *, int, int) { return -EINVAL; } static int tv_input_request_capture( - struct tv_input_device*, int, int, buffer_handle_t, uint32_t) + struct tv_input_device *, int, int, buffer_handle_t, uint32_t) { return -EINVAL; } -static int tv_input_cancel_capture(struct tv_input_device*, int, int, uint32_t) +static int tv_input_cancel_capture(struct tv_input_device *, int, int, uint32_t) { return -EINVAL; } @@ -232,7 +241,10 @@ static int tv_input_cancel_capture(struct tv_input_device*, int, int, uint32_t) static int tv_input_device_close(struct hw_device_t *dev) { - tv_input_private_t* priv = (tv_input_private_t*)dev; + tv_input_private_t *priv = (tv_input_private_t *)dev; + if (priv->pTv != NULL) { + delete priv->pTv; + } if (priv) { free(priv); } @@ -241,25 +253,27 @@ static int tv_input_device_close(struct hw_device_t *dev) /*****************************************************************************/ -static int tv_input_device_open(const struct hw_module_t* module, - const char* name, struct hw_device_t** device) +static int tv_input_device_open(const struct hw_module_t *module, + 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)); + tv_input_private_t *dev = (tv_input_private_t *)malloc(sizeof(*dev)); /* initialize our state here */ memset(dev, 0, sizeof(*dev)); - + /*intialize tv*/ + dev->pTv = new CTv(); + TvService::instantiate(dev->pTv); /* 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<hw_module_t*>(module); + dev->device.common.module = const_cast<hw_module_t *>(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; + 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; |