From 3179d6b1860c83828b757ed987917afd856b5346 Mon Sep 17 00:00:00 2001 From: Guosong Zhou Date: Thu, 13 Oct 2016 12:13:40 +0000 Subject: PD#132607: screen_source: change port type for amlvideo2 Change-Id: Ice036b2372ffafc95479c0e328324992c743ecc7 --- diff --git a/aml_screen.cpp b/aml_screen.cpp index cbaa289..d3bb77d 100644 --- a/aml_screen.cpp +++ b/aml_screen.cpp @@ -192,16 +192,6 @@ int screen_source_set_frame_rate(struct aml_screen_device* dev, int frameRate) return gScreenHals[dev->device_id]->set_frame_rate(frameRate); } -int screen_source_set_source_type(struct aml_screen_device* dev, SOURCETYPE sourceType) -{ - return gScreenHals[dev->device_id]->set_source_type(sourceType); -} - -int screen_source_get_source_type(struct aml_screen_device* dev) -{ - return gScreenHals[dev->device_id]->get_source_type(); -} - int screen_source_get_current_sourcesize(struct aml_screen_device* dev, int *w, int *h) { return gScreenHals[dev->device_id]->get_current_sourcesize(w, h); @@ -222,9 +212,21 @@ int screen_source_stop_v4l2_device(struct aml_screen_device* dev) return gScreenHals[dev->device_id]->stop_v4l2_device(); } -int screen_source_set_port_type(struct aml_screen_device* dev,int sourceType) +int screen_source_get_port_type(struct aml_screen_device* dev) +{ + return gScreenHals[dev->device_id]->get_port_type(); +} +/** + * set_port_type() parameter description: + portType is consisted by 32-bit binary. + bit 28 : start tvin service flag, 1 : enable, 0 : disable. + bit 24 : vdin device num : 0 or 1, which means use vdin0 or vdin1. + bit 15~0 : tvin port type --TVIN_PORT_VIU,TVIN_PORT_HDMI0... + (port type define in tvin.h) + */ +int screen_source_set_port_type(struct aml_screen_device* dev,unsigned int portType) { - return gScreenHals[dev->device_id]->set_port_type(sourceType); + return gScreenHals[dev->device_id]->set_port_type(portType); } /* int screen_source_inc_buffer_refcount(struct aml_screen_device* dev, int* ptr) @@ -306,13 +308,12 @@ static int aml_screen_device_open(const struct hw_module_t* module, const char* dev->ops.setPreviewWindow = screen_source_set_preview_window; dev->ops.setDataCallBack = screen_source_set_data_callback; dev->ops.set_frame_rate = screen_source_set_frame_rate; - dev->ops.set_source_type = screen_source_set_source_type; - dev->ops.get_source_type = screen_source_get_source_type; dev->ops.get_current_sourcesize = screen_source_get_current_sourcesize; dev->ops.set_screen_mode = screen_source_set_screen_mode; // dev->ops.inc_buffer_refcount = screen_source_inc_buffer_refcount; dev->ops.start_v4l2_device = screen_source_start_v4l2_device; dev->ops.stop_v4l2_device = screen_source_stop_v4l2_device; + dev->ops.get_port_type = screen_source_get_port_type; dev->ops.set_port_type = screen_source_set_port_type; dev->device_id = deviceid; *device = &dev->common; diff --git a/v4l2_vdin.cpp b/v4l2_vdin.cpp index 54bbf10..5d531e7 100644 --- a/v4l2_vdin.cpp +++ b/v4l2_vdin.cpp @@ -598,42 +598,38 @@ int vdin_screen_source::set_amlvideo2_crop(int x, int y, int width, int height) return ret ; } -int vdin_screen_source::set_source_type(int sourceType) +/** + * set_port_type() parameter description: + portType is consisted by 32-bit binary. + bit 28 : start tvin service flag, 1 : enable, 0 : disable. + bit 24 : vdin device num : 0 or 1, which means use vdin0 or vdin1. + bit 15~0 : tvin port type --TVIN_PORT_VIU,TVIN_PORT_HDMI0... + (port type define in tvin.h) + */ +int vdin_screen_source::set_port_type(unsigned int portType) { - ALOGV("[%s %d]", __FUNCTION__, __LINE__); + ALOGD("[%s %d]", __FUNCTION__, __LINE__); int ret = 0; - - ret = ioctl(mCameraHandle, VIDIOC_S_INPUT, &sourceType); - if(ret < 0){ - ALOGE("Set source type fail: %s. ret:%d", strerror(errno),ret); + ALOGE("portType:%x",portType); + ret = ioctl(mCameraHandle, VIDIOC_S_INPUT, &portType); + if (ret < 0) { + ALOGE("Set port type fail: %s. ret:%d", strerror(errno),ret); } return ret; } - -int vdin_screen_source::set_port_type(int sourceType) - { - ALOGD("[%s %d]", __FUNCTION__, __LINE__); - int ret = 0; - unsigned int portType = (unsigned int)sourceType; - ALOGE("portType:%d",portType); - ret = ioctl(mCameraHandle, VIDIOC_S_INPUT, &portType); - if (ret < 0) { - ALOGE("Set port type fail: %s. ret:%d", strerror(errno),ret); - } - return ret; - } -int vdin_screen_source::get_source_type() +int vdin_screen_source::get_port_type() { ALOGV("[%s %d]", __FUNCTION__, __LINE__); int ret = -1; - int sourceType; + int portType; - ret = ioctl(mCameraHandle, VIDIOC_G_INPUT, &sourceType); + ret = ioctl(mCameraHandle, VIDIOC_G_INPUT, &portType); if(ret < 0){ - ALOGE("Set source type fail: %s. ret:%d", strerror(errno),ret); + ALOGE("get port type fail: %s. ret:%d", strerror(errno),ret); return ret; } - return sourceType; + ALOGE("get portType:%x",portType); + return portType; } int vdin_screen_source::get_current_sourcesize(int *width, int *height) diff --git a/v4l2_vdin.h b/v4l2_vdin.h index a67e244..4909c01 100644 --- a/v4l2_vdin.h +++ b/v4l2_vdin.h @@ -74,7 +74,14 @@ typedef void (*app_data_callback)(void *user, aml_screen_buffer_info_t *buff_inf GRALLOC_USAGE_HW_RENDER | \ GRALLOC_USAGE_SW_READ_RARELY | \ GRALLOC_USAGE_SW_WRITE_NEVER - +/** + * set_port_type() parameter description: + portType is consisted by 32-bit binary. + bit 28 : start tvin service flag, 1 : enable, 0 : disable. + bit 24 : vdin device num : 0 or 1, which means use vdin0 or vdin1. + bit 15~0 : tvin port type --TVIN_PORT_VIU,TVIN_PORT_HDMI0... + (port type define in tvin.h) + */ class vdin_screen_source { public: vdin_screen_source(); @@ -96,13 +103,12 @@ class vdin_screen_source { int set_data_callback(app_data_callback callback, void* user); int set_preview_window(ANativeWindow* window); int set_frame_rate(int frameRate); - int set_source_type(int sourceType); - int get_source_type(); int get_current_sourcesize(int * width,int * height); int set_screen_mode(int mode); int start_v4l2_device(); int stop_v4l2_device(); - int set_port_type(int sourceType); + int get_port_type(); + int set_port_type(unsigned int portType); private: int init_native_window(); int workThread(); -- cgit