diff --git a/.gitignore b/.gitignore index c6127b3..9c773e3 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ modules.order Module.symvers Mkfile.old dkms.conf + +#IntelliJ CLion Files +.idea/ diff --git a/build.sh b/build.sh index c201406..9c4b75b 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ #!/bin/sh make -C driver clean make -C driver -cp driver/cx511h.ko ./ +cp driver/gc573.ko ./ diff --git a/driver/Makefile b/driver/Makefile index 7a47546..9a09f80 100644 --- a/driver/Makefile +++ b/driver/Makefile @@ -14,7 +14,7 @@ else KERNEL_VER:=$(shell uname -r) endif -BOARD ?= cx511h +BOARD ?= gc573 ifeq ($(MAKELEVEL),0) export BASE_DIR:=$(realpath $(dir $(MAKEFILE_LIST)))/ @@ -23,46 +23,53 @@ include $(BASE_DIR)helper.mk MODULE_NAME ?= $(BOARD) UTILS_DIR := $(BASE_DIR)utils/ +LIB_DIR := $(BASE_DIR)lib/ ifeq ($(call check_dir,$(BOARD_BASE_DIR)/$(BOARD)),$(NULL)) $(error no board $(BOARD) exists) endif -lib_file:=../AverMediaLib_64.a +basic-objs := entry.o cxt_mgr.o - -basic-objs := entry.o cxt_mgr.o utils := $(call dirs, $(UTILS_DIR)) utils_src := $(call rpath, $(foreach util, $(utils), $(call list_files_from_file, $(UTILS_DIR)$(util)SOURCE))) utils_objs := $(patsubst %.c, %.o, $(utils_src)) utils_inc := $(foreach util, $(utils), $(addprefix -I, $(UTILS_DIR)$(util)include)) -board_src:=$(call rpath,$(call list_files_from_file,$(BOARD_BASE_DIR)/$(BOARD)/SOURCE)) + +board_src:=$(call rpath,$(call list_files_from_file, $(BOARD_BASE_DIR)/$(BOARD)/SOURCE)) board_objs:=$(patsubst %.c,%.o,$(board_src)) +lib_src:=$(call rpath,$(wildcard $(LIB_DIR)*.c) $(wildcard $(LIB_DIR)*.o) $(subst _shipped,,$(wildcard $(LIB_DIR)*.o_shipped))) +lib_objs := $(patsubst %.c, %.o, $(lib_src)) +lib_cmd := $(addprefix $(call rpath, $(LIB_DIR))., $(addsuffix .cmd, $(subst _shipped,, $(notdir $(wildcard $(LIB_DIR)*.o_shipped))))) +lib_inc := $(addprefix -I, $(LIB_DIR)include) + common-include-dir := $(BASE_DIR)include common-include := $(addprefix -I, $(common-include-dir)) -common-include += $(utils_inc) +common-include += $(utils_inc) $(lib_inc) $(MODULE_NAME)-objs += $(basic-objs) $(MODULE_NAME)-objs += $(utils_objs) $(MODULE_NAME)-objs += $(board_objs) -$(MODULE_NAME)-objs += AverMediaLib_64.o +$(MODULE_NAME)-objs += $(lib_objs) #$(call add_cflags, $(MODULE_NAME)-objs, common-include) -fno-common -EXTRA_CFLAGS += $(common-include) -Wno-maybe-uninitialized -EXTRA_LDFLAGS += --whole-archive +EXTRA_CFLAGS += -Wno-vla -Wno-declaration-after-statement $(common-include) -Wno-maybe-uninitialized +EXTRA_LDFLAGS += --whole-archive obj-m += $(MODULE_NAME).o - -build: - cp $(lib_file) AverMediaLib_64.o +build: + $(info test1 $(lib_cmd)) + $(info test $(call rpath, $(LIB_DIR))) + $(shell touch $(lib_cmd)) make -C $(KDIR) M=$(BASE_DIR) modules all: buildlib build make -C $(KDIR) M=$(BASE_DIR) modules clean: + $(shell rm $(lib_cmd)) $(MAKE) -C $(KDIR) M=$(BASE_DIR) clean .PHONY: all clean buildlib build diff --git a/driver/board/cx511h/ReleaseNote.txt b/driver/board/gc573/ReleaseNote.txt similarity index 100% rename from driver/board/cx511h/ReleaseNote.txt rename to driver/board/gc573/ReleaseNote.txt diff --git a/driver/board/cx511h/SOURCE b/driver/board/gc573/SOURCE similarity index 100% rename from driver/board/cx511h/SOURCE rename to driver/board/gc573/SOURCE diff --git a/driver/board/cx511h/board_alsa.c b/driver/board/gc573/board_alsa.c similarity index 89% rename from driver/board/cx511h/board_alsa.c rename to driver/board/gc573/board_alsa.c index f74e5af..bd51d0f 100644 --- a/driver/board/cx511h/board_alsa.c +++ b/driver/board/gc573/board_alsa.c @@ -29,12 +29,12 @@ typedef struct BASIC_CXT_HANDLE_DECLARE; alsa_model_handle_t alsa_handle; handle_t aver_xilinx_handle; - handle_t i2c_chip_handle[CL511H_I2C_CHIP_COUNT]; + handle_t i2c_chip_handle[GC573_I2C_CHIP_COUNT]; }board_alsa_cxt_t; -static board_chip_desc_t cl511h_chip_desc[CL511H_I2C_CHIP_COUNT]= +static board_chip_desc_t gc573_chip_desc[GC573_I2C_CHIP_COUNT]= { - [CL511H_I2C_CHIP_ITE6805_0]= + [GC573_I2C_CHIP_ITE6805_0]= { .name=ITE6805_DRVNAME, .index=1, @@ -42,9 +42,9 @@ static board_chip_desc_t cl511h_chip_desc[CL511H_I2C_CHIP_COUNT]= }; -static alsa_model_pcm_info_t cl511h_pcm_info= +static alsa_model_pcm_info_t gc573_pcm_info= { - .name="cl511h capture pcm", + .name="gc573 capture pcm", .capture_count=1, }; @@ -76,7 +76,7 @@ static void board_alsa_capture_start(void *data) { board_alsa_cxt_t *board_alsa=data; aver_xilinx_audio_cbinfo_t audio_cbinfo; - //handle_t ite6805_handle=board_alsa->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_alsa->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //enum ite6805_audio_sample fe_audioinfo=0; //aver_xilinx_audio_cfg_t cfg; @@ -126,11 +126,11 @@ void board_alsa_init(cxt_mgr_handle_t cxt_mgr) break; } if (subsystem_id == 0x5730) - alsa_info.name="AVerMedia CL511H"; - alsa_info.pcm_count=sizeof(cl511h_pcm_info)/sizeof(alsa_model_pcm_info_t); + alsa_info.name="AVerMedia GC573"; + alsa_info.pcm_count=sizeof(gc573_pcm_info)/sizeof(alsa_model_pcm_info_t); alsa_info.support_fmt_mask=BIT_ALSA_MODEL_FMT_S16_LE | BIT_ALSA_MODEL_FMT_S24_LE; alsa_info.support_rate_mask=BIT_ALSA_MODEL_RATE_32K|BIT_ALSA_MODEL_RATE_44_1K|BIT_ALSA_MODEL_RATE_48K| BIT_ALSA_MODEL_RATE_96K | BIT_ALSA_MODEL_RATE_192K; - alsa_info.pcm_info=&cl511h_pcm_info; + alsa_info.pcm_info=&gc573_pcm_info; alsa_info.period_size=7680*4;//12*1024; alsa_info.max_period_num=128; board_alsa->alsa_handle=alsa_model_init(cxt_mgr,&alsa_info); @@ -155,9 +155,9 @@ void board_alsa_init(cxt_mgr_handle_t cxt_mgr) break; } - for(i=0;ii2c_chip_handle[i]=i2c_model_get_nth_driver_handle(i2c_mgr,cl511h_chip_desc[i].name,cl511h_chip_desc[i].index); + board_alsa->i2c_chip_handle[i]=i2c_model_get_nth_driver_handle(i2c_mgr,gc573_chip_desc[i].name,gc573_chip_desc[i].index); debug_msg("board_alsa i2c_chip_handle[%d] %p\n",i,board_alsa->i2c_chip_handle[i]); } diff --git a/driver/board/cx511h/board_alsa.h b/driver/board/gc573/board_alsa.h similarity index 100% rename from driver/board/cx511h/board_alsa.h rename to driver/board/gc573/board_alsa.h diff --git a/driver/board/cx511h/board_config.c b/driver/board/gc573/board_config.c similarity index 89% rename from driver/board/cx511h/board_config.c rename to driver/board/gc573/board_config.c index e770a0f..bc718f2 100644 --- a/driver/board/cx511h/board_config.c +++ b/driver/board/gc573/board_config.c @@ -33,18 +33,18 @@ static char *no_signal_pic = NULL; module_param(no_signal_pic, charp, 0444); MODULE_PARM_DESC(no_signal_pic, "Loading this bitmap file and display it when the input is no signal"); -//static char *out_of_range_pic = NULL; -//module_param(out_of_range_pic, charp, 0444); -//MODULE_PARM_DESC(out_of_range_pic, "Loading this bitmap file and display it when the content is out of range"); +static char *out_of_range_pic = NULL; +module_param(out_of_range_pic, charp, 0444); +MODULE_PARM_DESC(out_of_range_pic, "Loading this bitmap file and display it when the content is out of range"); -static char *copy_protetion_pic = NULL; -module_param(copy_protetion_pic, charp, 0444); -MODULE_PARM_DESC(copy_protetion_pic, "Loading this bitmap file and display it when the content was protected"); +static char *copy_protection_pic = NULL; +module_param(copy_protection_pic, charp, 0444); +MODULE_PARM_DESC(copy_protection_pic, "Loading this bitmap file and display it when the content was protected"); int board_init(void); void board_exit(void); -const char *BOARD_NAME="CL511H"; +const char *BOARD_NAME="GC573"; //pci_model_driver_setup_t pci_setup; extern int subsystem_id; @@ -54,7 +54,7 @@ pci_model_id_t id_table[]={ .device=0x0054, //according to hw DEVICE ID config .sub_vendor = 0x1461, .sub_device = 0x5730, - .driver_data=CL511H, + .driver_data=GC573, }, { 0 @@ -170,14 +170,14 @@ int board_probe(struct device *dev,unsigned long driver_info) ret=board_gpio_init(cxt_mgr); if(ret!=0) { - mesg("board_gpio_init\n"); + pr_err("board_gpio_init failed\n"); err=ERROR_BOARD_GPIO_INIT; break; } ret=board_i2c_init(cxt_mgr,driver_info); if(ret!=0) { - mesg("board_i2c_init\n"); + pr_err("board_i2c_init failed\n"); err=ERROR_BOARD_I2C_INIT; break; } @@ -186,13 +186,14 @@ int board_probe(struct device *dev,unsigned long driver_info) ite6805_handle_1=i2c_model_get_driver_handle(i2c_mgr,ITE6805_DRVNAME); if(!ite6805_handle_1) { - break; + pr_err("error getting ite6805 handle\n"); + break; } ite6805_add_trace(ite6805_handle_1,trace_handle); - mesg("%s subsystem_id=%x\n",__func__,subsystem_id); + pr_info("subsystem_id=%x\n", subsystem_id); - pic_bmp_init(cxt_mgr, no_signal_pic, NULL, copy_protetion_pic); + pic_bmp_init(cxt_mgr, no_signal_pic, out_of_range_pic, copy_protection_pic); board_alsa_init(cxt_mgr); board_v4l2_init(cxt_mgr,subsystem_id); //aver_xilinx_sha204_init(aver_xilinx_handle); @@ -206,10 +207,13 @@ int board_probe(struct device *dev,unsigned long driver_info) { case ERROR_AVER_XILINX: cxt_manager_unref_context(i2c_mgr); + // fall through case ERROR_I2C_MGR: cxt_manager_unref_context(gpio_mgr); + // fall through case ERROR_GPIO_MGR: cxt_manager_unref_context(trace_handle); + // fall through case ERROR_TRACE_HANDLE: case NO_PCI_HANDLE: diff --git a/driver/board/cx511h/board_gpio.c b/driver/board/gc573/board_gpio.c similarity index 98% rename from driver/board/cx511h/board_gpio.c rename to driver/board/gc573/board_gpio.c index 36918f8..235d488 100644 --- a/driver/board/cx511h/board_gpio.c +++ b/driver/board/gc573/board_gpio.c @@ -113,7 +113,7 @@ int board_gpio_init(cxt_mgr_handle_t cxt_mgr) // board_gpio_cxt->gpio_pin_handle[i]=gpio_model_request_pin_handle(gpio_mgr,pin_name[i]); // if(board_gpio_cxt->gpio_pin_handle[i]==GPIO_MODEL_BAD_PIN_HANDLE) // { -// printk(" request %s failed\n",pin_name[i]); +// pr_info(" request %s failed\n",pin_name[i]); // } // } } diff --git a/driver/board/cx511h/board_gpio.h b/driver/board/gc573/board_gpio.h similarity index 100% rename from driver/board/cx511h/board_gpio.h rename to driver/board/gc573/board_gpio.h diff --git a/driver/board/cx511h/board_i2c.c b/driver/board/gc573/board_i2c.c similarity index 97% rename from driver/board/cx511h/board_i2c.c rename to driver/board/gc573/board_i2c.c index 12380b4..2bc5b0e 100644 --- a/driver/board/cx511h/board_i2c.c +++ b/driver/board/gc573/board_i2c.c @@ -40,7 +40,7 @@ static ite6805_cfg_t ite6805_cfg={ }; -static i2c_dev_info_t cx511h_i2c_bus1_devices[]= +static i2c_dev_info_t gc573_i2c_bus1_devices[]= { { .name=ITE6805_DRVNAME, @@ -55,7 +55,7 @@ static i2c_dev_info_t cx511h_i2c_bus1_devices[]= static i2c_dev_info_t *board_i2c_bus_devices[SUPPORT_BOARD_NUM][BOARD_I2C_BUS_NUM]= { - [CL511H][I2C_BUS_COM]= &cx511h_i2c_bus1_devices[0], //reserved one I2C + [GC573][I2C_BUS_COM]= &gc573_i2c_bus1_devices[0], //reserved one I2C }; diff --git a/driver/board/cx511h/board_i2c.h b/driver/board/gc573/board_i2c.h similarity index 100% rename from driver/board/cx511h/board_i2c.h rename to driver/board/gc573/board_i2c.h diff --git a/driver/board/cx511h/board_v4l2.c b/driver/board/gc573/board_v4l2.c similarity index 67% rename from driver/board/cx511h/board_v4l2.c rename to driver/board/gc573/board_v4l2.c index fc072c0..4d1e4b5 100644 --- a/driver/board/cx511h/board_v4l2.c +++ b/driver/board/gc573/board_v4l2.c @@ -9,7 +9,8 @@ * Version: * ================================================================= */ - +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + //#include #include "board.h" #include "cxt_mgr.h" @@ -36,7 +37,7 @@ typedef struct i2c_model_handle_t i2c_model_handle; task_model_handle_t task_model_handle; handle_t aver_xilinx_handle; - handle_t i2c_chip_handle[CL511H_I2C_CHIP_COUNT]; + handle_t i2c_chip_handle[GC573_I2C_CHIP_COUNT]; ite6805_frameinfo_t cur_fe_frameinfo; enum ite6805_audio_sample cur_fe_audioinfo; int cur_bchs_value; @@ -45,9 +46,9 @@ typedef struct int board_id; }board_v4l2_context_t; -static board_chip_desc_t cl511h_chip_desc[CL511H_I2C_CHIP_COUNT]= +static board_chip_desc_t gc573_chip_desc[GC573_I2C_CHIP_COUNT]= { - [CL511H_I2C_CHIP_ITE6805_0]= + [GC573_I2C_CHIP_ITE6805_0]= { .name=ITE6805_DRVNAME, .index=1, @@ -55,9 +56,9 @@ static board_chip_desc_t cl511h_chip_desc[CL511H_I2C_CHIP_COUNT]= }; -static framegrabber_setup_input_info_t cl511h_input_info[] = +static framegrabber_setup_input_info_t gc573_input_info[] = { - [CL511H_HDMI_INPUT] = + [GC573_HDMI_INPUT] = { .name = "HDMI", .support_framesize_info = @@ -86,15 +87,15 @@ static framegrabber_setup_input_info_t cl511h_input_info[] = | REFRESHRATE_25_BIT | REFRESHRATE_24_BIT, }, }, - [CL511H_INPUT_COUNT] = + [GC573_INPUT_COUNT] = { .name = NULL, }, }; -static framegrabber_property_t cl511h_property={ - .name="CL511H", - .input_setup_info=cl511h_input_info, +static framegrabber_property_t gc573_property={ + .name="GC573", + .input_setup_info=gc573_input_info, .support_out_pixfmt_mask=FRAMEGRABBER_PIXFMT_BITMSK,//FRAMEGRABBER_PIXFMT_YUYV_BIT , //tt 0615 //.max_supported_line_width=3840, //.max_supported_line_width=4096, @@ -105,51 +106,51 @@ static framegrabber_property_t cl511h_property={ static v4l2_model_device_setup_t device_info= { .type = DEVICE_TYPE_GRABBER, - .driver_name="CL511H", - .card_name="AVerMedia CL511H", + .driver_name="GC573", + .card_name="AVerMedia GC573", .capabilities= V4L2_MODEL_CAPS_CAPTURE_BIT | V4L2_MODEL_CAPS_READWRITE_BIT | V4L2_MODEL_CAPS_STREAMING_BIT, .buffer_type=V4L2_MODEL_BUF_TYPE_DMA_SG, }; static void *board_v4l2_alloc(void); static void board_v4l2_release(void *cxt); -static void cx511h_v4l2_stream_on(v4l2_model_callback_parameter_t *cb_info); -static void cx511h_v4l2_stream_off(v4l2_model_callback_parameter_t *cb_info); -static void cx511h_stream_on(framegrabber_handle_t handle); -static void cx511h_stream_off(framegrabber_handle_t handle); -//static void cx511h_bchs_read(framegrabber_handle_t handle); -static void cx511h_bchs_write(framegrabber_handle_t handle); -static void cx511h_brightness_read(framegrabber_handle_t handle,int *brightness); -static void cx511h_contrast_read(framegrabber_handle_t handle,int *contrast); -static void cx511h_hue_read(framegrabber_handle_t handle,int *hue); -static void cx511h_saturation_read(framegrabber_handle_t handle,int *saturation); -static void cx511h_hdcp_state_read(framegrabber_handle_t handle,int *hdcp_state); -static void cx511h_hdcp_state_set(framegrabber_handle_t handle,int hdcp_state); -static int cx511h_i2c_read(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit); -static int cx511h_i2c_write(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit); -static int cx511h_reg_read(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int *data); -static int cx511h_reg_write(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int data); - -static int cx511h_flash_dump(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump); // -static int cx511h_flash_update(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump); // - -static framegrabber_interface_t cx511h_ops={ - .stream_on = cx511h_stream_on, - .stream_off = cx511h_stream_off, - //.bchs_get = cx511h_bchs_read, - .brightness_get = cx511h_brightness_read, - .contrast_get = cx511h_contrast_read, - .hue_get = cx511h_hue_read, - .saturation_get = cx511h_saturation_read, - .bchs_set = cx511h_bchs_write, - .flash_read = cx511h_flash_dump, - .flash_update = cx511h_flash_update, - .hdcp_state_get = cx511h_hdcp_state_read, - .hdcp_state_set = cx511h_hdcp_state_set, - .i2c_read = cx511h_i2c_read, - .i2c_write = cx511h_i2c_write, - .reg_read = cx511h_reg_read, - .reg_write = cx511h_reg_write, +static void gc573_v4l2_stream_on(v4l2_model_callback_parameter_t *cb_info); +static void gc573_v4l2_stream_off(v4l2_model_callback_parameter_t *cb_info); +static void gc573_stream_on(framegrabber_handle_t handle); +static void gc573_stream_off(framegrabber_handle_t handle); +//static void gc573_bchs_read(framegrabber_handle_t handle); +static void gc573_bchs_write(framegrabber_handle_t handle); +static void gc573_brightness_read(framegrabber_handle_t handle,int *brightness); +static void gc573_contrast_read(framegrabber_handle_t handle,int *contrast); +static void gc573_hue_read(framegrabber_handle_t handle,int *hue); +static void gc573_saturation_read(framegrabber_handle_t handle,int *saturation); +static void gc573_hdcp_state_read(framegrabber_handle_t handle,int *hdcp_state); +static void gc573_hdcp_state_set(framegrabber_handle_t handle,int hdcp_state); +static int gc573_i2c_read(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit); +static int gc573_i2c_write(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit); +static int gc573_reg_read(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int *data); +static int gc573_reg_write(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int data); + +static int gc573_flash_dump(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump); // +static int gc573_flash_update(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump); // + +static framegrabber_interface_t gc573_ops={ + .stream_on = gc573_stream_on, + .stream_off = gc573_stream_off, + //.bchs_get = gc573_bchs_read, + .brightness_get = gc573_brightness_read, + .contrast_get = gc573_contrast_read, + .hue_get = gc573_hue_read, + .saturation_get = gc573_saturation_read, + .bchs_set = gc573_bchs_write, + .flash_read = gc573_flash_dump, + .flash_update = gc573_flash_update, + .hdcp_state_get = gc573_hdcp_state_read, + .hdcp_state_set = gc573_hdcp_state_set, + .i2c_read = gc573_i2c_read, + .i2c_write = gc573_i2c_write, + .reg_read = gc573_reg_read, + .reg_write = gc573_reg_write, }; static void *board_v4l2_alloc() @@ -177,7 +178,7 @@ static void board_v4l2_release(void *cxt) } } -static void cx511h_v4l2_stream_on(v4l2_model_callback_parameter_t *cb_info) +static void gc573_v4l2_stream_on(v4l2_model_callback_parameter_t *cb_info) { board_v4l2_context_t *board_v4l2_cxt=cb_info->asso_data; @@ -185,13 +186,13 @@ static void cx511h_v4l2_stream_on(v4l2_model_callback_parameter_t *cb_info) } -static void cx511h_v4l2_stream_off(v4l2_model_callback_parameter_t *cb_info) +static void gc573_v4l2_stream_off(v4l2_model_callback_parameter_t *cb_info) { board_v4l2_context_t *board_v4l2_cxt=cb_info->asso_data; debug_msg("%s %p\n",__func__,board_v4l2_cxt); } -static void cx511h_stream_on(framegrabber_handle_t handle) +static void gc573_stream_on(framegrabber_handle_t handle) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); aver_xilinx_video_process_cfg_t vip_cfg; @@ -204,16 +205,15 @@ static void cx511h_stream_on(framegrabber_handle_t handle) framegrabber_framemode_e framemode; const framegrabber_pixfmt_t *pixfmt=framegrabber_g_out_pixelfmt(handle); - handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //ite6805_get_hdcp_state(ite6805_handle, &hdcp_state); //ite6805_set_hdcp_state(ite6805_handle, hdcp_state); - enum ite6805_audio_sample fe_audioinfo=0; +// enum ite6805_audio_sample fe_audioinfo=0; ite6805_frameinfo_t *fe_frameinfo=&board_v4l2_cxt->cur_fe_frameinfo; //aver_xilinx_frame_info_t detected_frameinfo; - mesg("%s\n",__func__); //aver_xilinx_get_frameinfo(board_v4l2_cxt->aver_xilinx_handle,&detected_frameinfo); framemode=framegrabber_g_input_interlace(board_v4l2_cxt->fg_handle); framegrabber_g_input_framesize(board_v4l2_cxt->fg_handle,&width,&height); @@ -227,16 +227,18 @@ static void cx511h_stream_on(framegrabber_handle_t handle) //framegrabber_s_out_framerate(board_v4l2_cxt->fg_handle,0); framegrabber_g_out_framesize(board_v4l2_cxt->fg_handle,&out_width,&out_height); - debug_msg("%s in %dx%d out %dx%d\n",__func__,width,height,out_width,out_height); - + if ((out_width ==0) || (out_height ==0)) { - debug_msg("debug...\n"); + pr_info("Output framesize is not set: Setting to 1920x1080\n"); + out_width = 1920; out_height = 1080; - framegrabber_s_out_framesize(board_v4l2_cxt->fg_handle,1920,1080); + framegrabber_s_out_framesize(board_v4l2_cxt->fg_handle,out_width,out_height); } + pr_info("in %dx%d out %dx%d\n",width, height,out_width,out_height); + if(framemode==FRAMEGRABBER_FRAMEMODE_INTERLACED) vip_cfg.in_videoformat.is_interlace=TRUE; else @@ -257,17 +259,17 @@ static void cx511h_stream_on(framegrabber_handle_t handle) framegrabber_s_input_audioinfo(board_v4l2_cxt->fg_handle,audio_rate); - mesg("%s...vip_cfg.audio_rate_index=%d\n",__func__,vip_cfg.audio_rate); + pr_info("vip_cfg.audio_rate_index=%d\n", vip_cfg.audio_rate); ite6805_get_frameinfo(ite6805_handle,fe_frameinfo); - debug_msg("%s========fe_frameinfo->packet_colorspace=%d\n",__func__,fe_frameinfo->packet_colorspace); + pr_info("fe_frameinfo->packet_colorspace=%d\n", fe_frameinfo->packet_colorspace); vip_cfg.in_videoformat.fps = framegrabber_g_input_framerate(board_v4l2_cxt->fg_handle); //if(vip_cfg.is_interlace==TRUE) //vip_cfg.in_framerate = vip_cfg.in_framerate * 2; vip_cfg.packet_colorspace = fe_frameinfo->packet_colorspace; - vip_cfg.in_videoformat.vactive = width; - vip_cfg.in_videoformat.hactive = height; + vip_cfg.in_videoformat.vactive = height; + vip_cfg.in_videoformat.hactive = width; //if (vip_cfg.in_videoformat.is_interlace==TRUE) //vip_cfg.in_videoformat.hactive *= 2; vip_cfg.out_videoformat.width=out_width; @@ -283,7 +285,7 @@ static void cx511h_stream_on(framegrabber_handle_t handle) vip_cfg.in_ddrmode = fe_frameinfo->ddr_mode; //vip_cfg.out_framerate= 0; //for test vip_cfg.out_videoformat.fps=frameinterval; - mesg("%s..in_framerate=%d out_framerate=%d pixel_clock=%d\n",__func__,vip_cfg.in_videoformat.fps,vip_cfg.out_videoformat.fps,vip_cfg.pixel_clock); + pr_info("in_framerate=%d out_framerate=%d, pixel_clock=%d, in_ddrmode=%d\n",vip_cfg.in_videoformat.fps,vip_cfg.out_videoformat.fps,vip_cfg.pixel_clock, vip_cfg.in_ddrmode); ite6805_get_workingmode(ite6805_handle, &(vip_cfg.in_workingmode)) ; vip_cfg.in_colorspacemode = 0; // 0-yuv, 1-rgb limit, 2-rgb full @@ -291,67 +293,86 @@ static void cx511h_stream_on(framegrabber_handle_t handle) vip_cfg.in_videoformat.colorspace = VIDEO_RGB_MODE; vip_cfg.in_packetsamplingmode = 1; // 0-rgb, 1-422, 2-444 vip_cfg.in_packetcsc_bt = COLORMETRY_ITU709; + ite6805_get_sampingmode(ite6805_handle, &(vip_cfg.in_packetsamplingmode)); vip_cfg.currentCSC = CAPTURE_BT709_COMPUTER; - + + pr_info("in_colorspacemode = %d, in_packetsamplingmode = %d, in_videoformat_colorspace = %d\n", vip_cfg.in_colorspacemode , (int) vip_cfg.in_videoformat.colorspace, vip_cfg.in_packetsamplingmode); + //enable video bypass - if (((vip_cfg.in_videoformat.vactive == 4096) && (vip_cfg.out_videoformat.width == 4096) - && (vip_cfg.out_videoformat.height == 2160) && (vip_cfg.out_videoformat.height == 2160)) || //4096x2160 - ((vip_cfg.in_videoformat.vactive == 3840) && (vip_cfg.out_videoformat.width == 3840) - && (vip_cfg.out_videoformat.height == 2160) && (vip_cfg.out_videoformat.height == 2160)) || //3840x2160 - ((vip_cfg.in_videoformat.vactive == 2560) && (vip_cfg.out_videoformat.width == 2560) - && (vip_cfg.in_videoformat.hactive == 1600) && (vip_cfg.out_videoformat.height == 1600)) || //2560x1600 - ((vip_cfg.in_videoformat.vactive == 2560) && (vip_cfg.out_videoformat.width == 2560) - && (vip_cfg.in_videoformat.hactive == 1440) && (vip_cfg.out_videoformat.height == 1440)) || //2560x1440 - ((vip_cfg.in_videoformat.vactive == 2560) && (vip_cfg.out_videoformat.width == 2560) - && (vip_cfg.in_videoformat.hactive == 1080) && (vip_cfg.out_videoformat.height == 1080)) || //2560x1080 - ((vip_cfg.in_videoformat.vactive == 1920) && (vip_cfg.out_videoformat.width == 1920) - && (vip_cfg.in_videoformat.hactive == 1440) && (vip_cfg.out_videoformat.height == 1440)) || //1920x1440 - ((vip_cfg.in_videoformat.vactive == 1856) && (vip_cfg.out_videoformat.width == 1856) - && (vip_cfg.in_videoformat.hactive == 1392) && (vip_cfg.out_videoformat.height == 1392)) || //1856x1392 - ((vip_cfg.in_videoformat.vactive == 1792) && (vip_cfg.out_videoformat.width == 1792) - && (vip_cfg.in_videoformat.hactive == 1344) && (vip_cfg.out_videoformat.height == 1344)) || //1792x1344 - ((vip_cfg.in_videoformat.vactive == 2048) && (vip_cfg.out_videoformat.width == 2048) - && (vip_cfg.in_videoformat.hactive == 1152) && (vip_cfg.out_videoformat.height == 1152)) || //2048x1152 - ((vip_cfg.in_videoformat.vactive == 1920) && (vip_cfg.out_videoformat.width == 1920) - && (vip_cfg.in_videoformat.hactive == 1200) && (vip_cfg.out_videoformat.height == 1200)) || //1920x1200 - ((vip_cfg.in_videoformat.vactive == 1920) && (vip_cfg.out_videoformat.width == 1920) - && (vip_cfg.in_videoformat.hactive == 1080) && (vip_cfg.out_videoformat.height == 1080) + if (((vip_cfg.in_videoformat.hactive == 4096) && (vip_cfg.out_videoformat.width == 4096) + && (vip_cfg.in_videoformat.vactive == 2160) && (vip_cfg.out_videoformat.height == 2160)) || //4096x2160 + ((vip_cfg.in_videoformat.hactive == 3840) && (vip_cfg.out_videoformat.width == 3840) + && (vip_cfg.in_videoformat.vactive == 2160) && (vip_cfg.out_videoformat.height == 2160)) || //3840x2160 + ((vip_cfg.in_videoformat.hactive == 2560) && (vip_cfg.out_videoformat.width == 2560) + && (vip_cfg.in_videoformat.vactive == 1600) && (vip_cfg.out_videoformat.height == 1600)) || //2560x1600 + ((vip_cfg.in_videoformat.hactive == 2560) && (vip_cfg.out_videoformat.width == 2560) + && (vip_cfg.in_videoformat.vactive == 1440) && (vip_cfg.out_videoformat.height == 1440)) || //2560x1440 + ((vip_cfg.in_videoformat.hactive == 2560) && (vip_cfg.out_videoformat.width == 2560) + && (vip_cfg.in_videoformat.vactive == 1080) && (vip_cfg.out_videoformat.height == 1080)) || //2560x1080 + ((vip_cfg.in_videoformat.hactive == 1920) && (vip_cfg.out_videoformat.width == 1920) + && (vip_cfg.in_videoformat.vactive == 1440) && (vip_cfg.out_videoformat.height == 1440)) || //1920x1440 + ((vip_cfg.in_videoformat.hactive == 1856) && (vip_cfg.out_videoformat.width == 1856) + && (vip_cfg.in_videoformat.vactive == 1392) && (vip_cfg.out_videoformat.height == 1392)) || //1856x1392 + ((vip_cfg.in_videoformat.hactive == 1792) && (vip_cfg.out_videoformat.width == 1792) + && (vip_cfg.in_videoformat.vactive == 1344) && (vip_cfg.out_videoformat.height == 1344)) || //1792x1344 + ((vip_cfg.in_videoformat.hactive == 2048) && (vip_cfg.out_videoformat.width == 2048) + && (vip_cfg.in_videoformat.vactive == 1152) && (vip_cfg.out_videoformat.height == 1152)) || //2048x1152 + ((vip_cfg.in_videoformat.hactive == 1920) && (vip_cfg.out_videoformat.width == 1920) + && (vip_cfg.in_videoformat.vactive == 1200) && (vip_cfg.out_videoformat.height == 1200)) || //1920x1200 + ((vip_cfg.in_videoformat.hactive == 1920) && (vip_cfg.out_videoformat.width == 1920) + && (vip_cfg.in_videoformat.vactive == 1080) && (vip_cfg.out_videoformat.height == 1080) && (vip_cfg.in_videoformat.fps == 120))) { - mesg("%s bypass = 1.. in %dx%d out %dx%d\n",__func__,vip_cfg.in_videoformat.vactive, vip_cfg.in_videoformat.hactive,vip_cfg.out_videoformat.width,vip_cfg.out_videoformat.height); + pr_info("bypass = 1.. in %dx%d out %dx%d\n",vip_cfg.in_videoformat.hactive, vip_cfg.in_videoformat.vactive,vip_cfg.out_videoformat.width,vip_cfg.out_videoformat.height); //aver_xilinx_video_bypass(board_v4l2_cxt->aver_xilinx_handle,1); //enable video bypass vip_cfg.video_bypass = 1; } else { - mesg("%s bypass = 0.. in %dx%d out %dx%d\n",__func__,vip_cfg.in_videoformat.vactive,vip_cfg.in_videoformat.hactive,vip_cfg.out_videoformat.width,vip_cfg.out_videoformat.height); + pr_info("bypass = 0.. in %dx%d out %dx%d\n",vip_cfg.in_videoformat.hactive,vip_cfg.in_videoformat.vactive,vip_cfg.out_videoformat.width,vip_cfg.out_videoformat.height); //aver_xilinx_video_bypass(board_v4l2_cxt->aver_xilinx_handle,0); //disable video bypass vip_cfg.video_bypass = 0; } switch(pixfmt->pixfmt_out) { - case AVER_XILINX_FMT_YUYV: - case AVER_XILINX_FMT_UYVY: - case AVER_XILINX_FMT_YVYU: - case AVER_XILINX_FMT_VYUY: + case YUYV: + case YVYU: + case VYUY: vip_cfg.pixel_format=AVER_XILINX_FMT_YUYV; - mesg("%s...vip_cfg.pixel_format_output=AVER_XILINX_FMT_YUYV\n",__func__); + pr_info("vip_cfg.pixel_format_output=AVER_XILINX_FMT_YUYV\n"); + break; + case UYVY: + vip_cfg.pixel_format=AVER_XILINX_FMT_UYVY; + pr_info("vip_cfg.pixel_format_output=AVER_XILINX_FMT_UYVY\n"); break; - case AVER_XILINX_FMT_RGBP: //RGB565 - case AVER_XILINX_FMT_RGBR: //RGB565X - case AVER_XILINX_FMT_RGBO: - case AVER_XILINX_FMT_RGBQ: - case AVER_XILINX_FMT_RGB3: //RGB24 4:4:4 - case AVER_XILINX_FMT_BGR3: - case AVER_XILINX_FMT_RGB4: - case AVER_XILINX_FMT_BGR4: - vip_cfg.pixel_format=AVER_XILINX_FMT_RGB3; - mesg("%s...vip_cfg.pixel_format=AVER_XILINX_FMT_RGB3\n",__func__); + case YVU420: + case YVU420M: //YV12 + vip_cfg.pixel_format=AVER_XILINX_FMT_YVU420; + pr_info("vip_cfg.pixel_format_output=AVER_XILINX_FMT_YVU420\n"); + break; + case NV12: + case NV12M: + vip_cfg.pixel_format=AVER_XILINX_FMT_NV12; + pr_info("vip_cfg.pixel_format_output=AVER_XILINX_FMT_NV12\n"); + break; + case RGBP: //RGB565 + case RGBR: //RGB565X + case RGBO: + case RGBQ: + case RGB3: //RGB24 4:4:4 + case BGR3: + vip_cfg.pixel_format=AVER_XILINX_FMT_BGR3; + pr_info("vip_cfg.pixel_format=AVER_XILINX_FMT_BGR3\n"); + break; + case AR24: //fall through + case BA24: + vip_cfg.pixel_format=AVER_XILINX_FMT_RGB4; + pr_info("vip_cfg.pixel_format=AVER_XILINX_FMT_RGB4\n"); break; default: - vip_cfg.pixel_format=AVER_XILINX_CS_YUV422; + vip_cfg.pixel_format=AVER_XILINX_FMT_YUYV; break; } aver_xilinx_config_video_process(board_v4l2_cxt->aver_xilinx_handle,&vip_cfg); @@ -362,10 +383,10 @@ static void cx511h_stream_on(framegrabber_handle_t handle) //ite6805_set_freerun_screen(ite6805_handle,FALSE); } -static void cx511h_stream_off(framegrabber_handle_t handle) +static void gc573_stream_off(framegrabber_handle_t handle) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //debug_msg(">>>>>>>>>>>%s...\n",__func__); //ite6805_set_freerun_screen(ite6805_handle,TRUE); @@ -373,9 +394,9 @@ static void cx511h_stream_off(framegrabber_handle_t handle) aver_xilinx_enable_video_streaming(board_v4l2_cxt->aver_xilinx_handle,FALSE); } -static int cx511h_flash_dump(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump) // +static int gc573_flash_dump(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_dump) // { - board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); +// board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); //char version[10]; int ret=0; @@ -384,9 +405,9 @@ static int cx511h_flash_dump(framegrabber_handle_t handle,int start_block, int b return ret; } -static int cx511h_flash_update(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_update) +static int gc573_flash_update(framegrabber_handle_t handle,int start_block, int blocks, U8_T *flash_update) { - board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); +// board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); //char version[10]; int ret=0; @@ -395,10 +416,10 @@ static int cx511h_flash_update(framegrabber_handle_t handle,int start_block, int return ret; } -static void cx511h_brightness_read(framegrabber_handle_t handle,int *brightness) +static void gc573_brightness_read(framegrabber_handle_t handle,int *brightness) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle);// - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //ite6805_get_brightness(ite6805_handle,&board_v4l2_cxt->cur_bchs_value); //board_v4l2_cxt->cur_bchs_value = aver_xilinx_get_bright(board_v4l2_cxt->aver_xilinx_handle); @@ -406,12 +427,12 @@ static void cx511h_brightness_read(framegrabber_handle_t handle,int *brightness) //framegrabber_set_data(handle,board_v4l2_cxt); *brightness = board_v4l2_cxt->cur_bchs_value; //handle->fg_bchs_value = *brightness; - debug_msg("%s get brightness=%x\n",__func__,board_v4l2_cxt->cur_bchs_value); + pr_info("brightness=%x\n",board_v4l2_cxt->cur_bchs_value); } -static void cx511h_contrast_read(framegrabber_handle_t handle,int *contrast) +static void gc573_contrast_read(framegrabber_handle_t handle,int *contrast) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //ite6805_get_contrast(ite6805_handle,&board_v4l2_cxt->cur_bchs_value); //board_v4l2_cxt->cur_bchs_value = aver_xilinx_get_contrast(board_v4l2_cxt->aver_xilinx_handle); @@ -419,13 +440,13 @@ static void cx511h_contrast_read(framegrabber_handle_t handle,int *contrast) //framegrabber_set_data(handle,board_v4l2_cxt); *contrast = board_v4l2_cxt->cur_bchs_value; //handle->fg_bchs_value = *contrast; - debug_msg("%s get contrast=%x\n",__func__,board_v4l2_cxt->cur_bchs_value); + pr_info("contrast=%x\n",board_v4l2_cxt->cur_bchs_value); } -static void cx511h_hue_read(framegrabber_handle_t handle,int *hue) +static void gc573_hue_read(framegrabber_handle_t handle,int *hue) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //ite6805_get_hue(ite6805_handle,&board_v4l2_cxt->cur_bchs_value); //board_v4l2_cxt->cur_bchs_value = aver_xilinx_get_hue(board_v4l2_cxt->aver_xilinx_handle); @@ -433,13 +454,13 @@ static void cx511h_hue_read(framegrabber_handle_t handle,int *hue) //framegrabber_set_data(handle,board_v4l2_cxt); *hue = board_v4l2_cxt->cur_bchs_value; //handle->fg_bchs_value = *hue; - debug_msg("%s get hue=%x\n",__func__,board_v4l2_cxt->cur_bchs_value); + pr_info("hue=%x\n",board_v4l2_cxt->cur_bchs_value); } -static void cx511h_saturation_read(framegrabber_handle_t handle,int *saturation) +static void gc573_saturation_read(framegrabber_handle_t handle,int *saturation) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //ite6805_get_saturation(ite6805_handle,&board_v4l2_cxt->cur_bchs_value); //board_v4l2_cxt->cur_bchs_value = aver_xilinx_get_saturation(board_v4l2_cxt->aver_xilinx_handle); @@ -447,13 +468,13 @@ static void cx511h_saturation_read(framegrabber_handle_t handle,int *saturation) //framegrabber_set_data(handle,board_v4l2_cxt); *saturation = board_v4l2_cxt->cur_bchs_value; //handle->fg_bchs_value = *saturation; - debug_msg("%s get saturation=%x\n",__func__,board_v4l2_cxt->cur_bchs_value); + pr_info("saturation=%x\n",board_v4l2_cxt->cur_bchs_value); } -static void cx511h_bchs_write(framegrabber_handle_t handle) +static void gc573_bchs_write(framegrabber_handle_t handle) { // board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; int bchs_value = handle->fg_bchs_value; int bchs_select = handle->fg_bchs_selection; @@ -465,28 +486,28 @@ static void cx511h_bchs_write(framegrabber_handle_t handle) //framegrabber_s_input_bchs(board_v4l2_cxt->fg_handle,board_v4l2_cxt->cur_bchs_value,board_v4l2_cxt->cur_bchs_selection); //ite6805_set_bchs(ite6805_handle,&bchs_value,&bchs_select); //aver_xilinx_set_bchs(board_v4l2_cxt->aver_xilinx_handle,bchs_value,bchs_select); - if (bchs_select ==0) debug_msg("set brightness=%d\n",bchs_value); - if (bchs_select ==1) debug_msg("set contrast=%d\n",bchs_value); - if (bchs_select ==2) debug_msg("set hue=%d\n",bchs_value); - if (bchs_select ==3) debug_msg("set saturation=%d\n",bchs_value); + if (bchs_select ==0) pr_info("set brightness=%d\n",bchs_value); + if (bchs_select ==1) pr_info("set contrast=%d\n",bchs_value); + if (bchs_select ==2) pr_info("set hue=%d\n",bchs_value); + if (bchs_select ==3) pr_info("set saturation=%d\n",bchs_value); } } -static void cx511h_hdcp_state_read(framegrabber_handle_t handle,int *hdcp_state) +static void gc573_hdcp_state_read(framegrabber_handle_t handle,int *hdcp_state) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); aver_xilinx_get_hdcp_state(board_v4l2_cxt->aver_xilinx_handle,hdcp_state); } -static void cx511h_hdcp_state_set(framegrabber_handle_t handle,int hdcp_state) +static void gc573_hdcp_state_set(framegrabber_handle_t handle,int hdcp_state) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); aver_xilinx_set_hdcp_state(board_v4l2_cxt->aver_xilinx_handle, hdcp_state); } -static int cx511h_i2c_read(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit) +static int gc573_i2c_read(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit) { board_v4l2_context_t *board_v4l2_cxt = framegrabber_get_data(handle); i2c_model_handle_t i2c_mgr = board_v4l2_cxt->i2c_model_handle; @@ -495,7 +516,7 @@ static int cx511h_i2c_read(framegrabber_handle_t handle, unsigned char channel, return board_i2c_read(cxt_mgr, channel, slave, sub, data, datalen); } -static int cx511h_i2c_write(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit) +static int gc573_i2c_write(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit) { board_v4l2_context_t *board_v4l2_cxt = framegrabber_get_data(handle); i2c_model_handle_t i2c_mgr = board_v4l2_cxt->i2c_model_handle; @@ -504,7 +525,7 @@ static int cx511h_i2c_write(framegrabber_handle_t handle, unsigned char channel, return board_i2c_write(cxt_mgr, channel, slave, sub, data, datalen); } -static int cx511h_reg_read(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int *data) +static int gc573_reg_read(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int *data) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); int ret = 0; @@ -514,7 +535,7 @@ static int cx511h_reg_read(framegrabber_handle_t handle, unsigned int offset, un return ret; } -static int cx511h_reg_write(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int data) +static int gc573_reg_write(framegrabber_handle_t handle, unsigned int offset, unsigned char n_bytes, unsigned int data) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); int ret = 0; @@ -525,7 +546,7 @@ static int cx511h_reg_write(framegrabber_handle_t handle, unsigned int offset, u { //stop task board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; ite6805_power_off(ite6805_handle); @@ -535,7 +556,7 @@ static int cx511h_reg_write(framegrabber_handle_t handle, unsigned int offset, u { //start task board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; ite6805_power_on(ite6805_handle); @@ -548,7 +569,7 @@ static int cx511h_reg_write(framegrabber_handle_t handle, unsigned int offset, u return ret; } -static void cx511h_video_buffer_done(void *data) +static void gc573_video_buffer_done(void *data) { board_v4l2_context_t *board_v4l2_cxt=data; //mesg("%s board_v4l2_cxt %p\n",__func__,board_v4l2_cxt); @@ -558,45 +579,53 @@ static void cx511h_video_buffer_done(void *data) } } -static void cx511h_v4l2_buffer_prepare(v4l2_model_callback_parameter_t *cb_info) +static void gc573_v4l2_buffer_prepare(v4l2_model_callback_parameter_t *cb_info) { board_v4l2_context_t *board_v4l2_cxt=cb_info->asso_data; v4l2_model_buffer_info_t *buffer_info=cb_info->u.buffer_prepare_info.buffer_info; - //mesg("%s %p buffer_info %p\n",__func__,board_v4l2_cxt,buffer_info); + pr_debug("context %p buffer_info %p\n",board_v4l2_cxt,buffer_info); if(buffer_info) { - int i; + int i, j; v4l2_model_buf_desc_t *desc; - unsigned framebufsize,remain; - int width,height; - unsigned bytesperline; - - framegrabber_g_out_framesize(board_v4l2_cxt->fg_handle,&width,&height); - bytesperline=framegrabber_g_out_bytesperline(board_v4l2_cxt->fg_handle); - framebufsize=bytesperline*height; - //debug_msg("%s %dx%d framesize %u\n",__func__,width,height,framebufsize); - // mesg("buf type %d count %d\n",buffer_info->buf_type,buffer_info->buf_count[0]); - for(i=0,desc=buffer_info->buf_info[0],remain=framebufsize;ibuf_count[0];i++) - { - if(remain >= desc[i].size) - { - aver_xilinx_add_to_cur_desclist(board_v4l2_cxt->aver_xilinx_handle,desc[i].addr,desc[i].size); - remain -= desc[i].size; - }else - { - aver_xilinx_add_to_cur_desclist(board_v4l2_cxt->aver_xilinx_handle,desc[i].addr,remain); - remain =0; - break; + unsigned remain; + unsigned sizes[3]; + unsigned plane_sizes[3]; + + sizes[2] = framegrabber_g_out_planarbuffersize(board_v4l2_cxt->fg_handle, 3); + sizes[1] = framegrabber_g_out_planarbuffersize(board_v4l2_cxt->fg_handle, 2); + sizes[0] = framegrabber_g_out_planarbuffersize(board_v4l2_cxt->fg_handle, 1); + + +// debug_msg("%s %dx%d framesize %u\n",__func__,width,height,framebufsize); + + for(j=0; j < buffer_info->planes; j ++) { + pr_debug("plane %d buf_type %d count %d\n", j, buffer_info->buf_type, buffer_info->buf_count[j]); + for (i = 0, desc = buffer_info->buf_info[j], remain = sizes[j]; i < buffer_info->buf_count[j]; i++) { + if (remain >= desc[i].size) { + aver_xilinx_add_to_cur_desclist(board_v4l2_cxt->aver_xilinx_handle, desc[i].addr, desc[i].size); + remain -= desc[i].size; + } else { + aver_xilinx_add_to_cur_desclist(board_v4l2_cxt->aver_xilinx_handle, desc[i].addr, remain); + remain = 0; + break; + } + + pr_debug("addr %08lx size %lx\n", desc[i].addr, desc[i].size); } - - //mesg("addr %08x size %x\n",desc[i].addr,desc[i].size); } - aver_xilinx_active_current_desclist(board_v4l2_cxt->aver_xilinx_handle,cx511h_video_buffer_done,board_v4l2_cxt); + plane_sizes[2] = framegrabber_g_out_planesize(board_v4l2_cxt->fg_handle, 3); + plane_sizes[1] = framegrabber_g_out_planesize(board_v4l2_cxt->fg_handle, 2); + plane_sizes[0] = framegrabber_g_out_planesize(board_v4l2_cxt->fg_handle, 1); + + aver_xilinx_translate_desclist(board_v4l2_cxt->aver_xilinx_handle, plane_sizes[0], plane_sizes[1], plane_sizes[2]); + + aver_xilinx_active_current_desclist(board_v4l2_cxt->aver_xilinx_handle,gc573_video_buffer_done,board_v4l2_cxt); } } -static void cx511h_v4l2_buffer_init(v4l2_model_callback_parameter_t *cb_info) +static void gc573_v4l2_buffer_init(v4l2_model_callback_parameter_t *cb_info) { // board_v4l2_context_t *board_v4l2_cxt=cb_info->asso_data; v4l2_model_buffer_info_t *buffer_info=cb_info->u.buffer_prepare_info.buffer_info; @@ -608,15 +637,15 @@ static void cx511h_v4l2_buffer_init(v4l2_model_callback_parameter_t *cb_info) //mesg("buf type %d count %d\n",buffer_info->buf_type,buffer_info->buf_count[0]); for(i=0,desc=buffer_info->buf_info[0];ibuf_count[0];i++) { - //mesg("addr %08x size %x\n",desc[i].addr,desc[i].size); + pr_info("addr %08lx size %lx\n",desc[i].addr,desc[i].size); } } } /* -static void cx511h_v4l2_hardware_init(framegrabber_handle_t handle) +static void gc573_v4l2_hardware_init(framegrabber_handle_t handle) { board_v4l2_context_t *board_v4l2_cxt=framegrabber_get_data(handle); - handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; iTE6805_Hardware_Init(ite6805_handle); } @@ -625,7 +654,7 @@ static void check_signal_stable_task(void *data) { board_v4l2_context_t *board_v4l2_cxt=data; //ite6805_frameinfo_t *fe_frameinfo=&board_v4l2_cxt->cur_fe_frameinfo; - //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; //check 20170511 + //handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; //check 20170511 int width,height; int dual_pixel; int dual_pixel_set; @@ -633,9 +662,7 @@ static void check_signal_stable_task(void *data) aver_xilinx_frame_info_t detected_frameinfo; ite6805_frameinfo_t *fe_frameinfo=&board_v4l2_cxt->cur_fe_frameinfo; BOOL_T is_interlace; - - debug_msg("%s\n",__func__); - + //ite6805_get_frameinfo(ite6805_handle,fe_frameinfo); //debug_msg("%s ite6805 detected size %dx%d;framerate %d \n",__func__,fe_frameinfo->width,fe_frameinfo->height,fe_frameinfo->framerate); @@ -650,8 +677,8 @@ static void check_signal_stable_task(void *data) else dual_pixel_set = detected_frameinfo.width; - debug_msg("%s framegrabber size %dx%d\n",__func__,width,height); - debug_msg("%s fpga detected size %dx%d\n",__func__,detected_frameinfo.width,detected_frameinfo.height); + pr_info("framegrabber size %dx%d%c\n",width,height,(fe_frameinfo->is_interlace) ?'i':'p'); + pr_info("fpga detected size %dx%d%c\n",detected_frameinfo.width,detected_frameinfo.height,(detected_frameinfo.is_interlace) ?'i':'p'); if((((detected_frameinfo.width<320 || detected_frameinfo.height<240)) || (width !=/*detected_frameinfo.width*/dual_pixel_set)|| (height !=detected_frameinfo.height)) && (cnt_retry<3)) { cnt_retry++; @@ -659,9 +686,7 @@ static void check_signal_stable_task(void *data) task_model_run_task_after(board_v4l2_cxt->task_model_handle,board_v4l2_cxt->check_signal_task_handle,100000); return; } - - //debug_msg("%s fpga detected size %dx%d\n",__func__,detected_frameinfo.width,detected_frameinfo.height); - + if (fe_frameinfo->is_interlace) { detected_frameinfo.width = fe_frameinfo->width; @@ -696,12 +721,12 @@ static void check_signal_stable_task(void *data) } } -static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) +static void gc573_ite6805_event(void *cxt,ite6805_event_e event) { board_v4l2_context_t *board_v4l2_cxt=cxt; ite6805_frameinfo_t *fe_frameinfo=&board_v4l2_cxt->cur_fe_frameinfo; enum ite6805_audio_sample *fe_audioinfo=&board_v4l2_cxt->cur_fe_audioinfo; - handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + handle_t ite6805_handle=board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; ite6805_out_format_e out_format; unsigned int hdcp_flag; @@ -711,8 +736,8 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) { case ITE6805_LOCK: { - //debug_msg("ITE6805_LOCK\n"); - //aver_xilinx_get_frameinfo(aver_xilinx_handle,&detected_frameinfo,fe_frameinfo->pixel_clock); + pr_info("ITE6805_LOCK\n"); +// aver_xilinx_get_frameinfo(board_v4l2_cxt->aver_xilinx_handle,&detected_frameinfo,fe_frameinfo->pixel_clock); { //aver_xilinx_color_adjust_control(board_v4l2_cxt->aver_xilinx_handle); @@ -720,8 +745,8 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) // aver_xilinx_hdmi_hotplug(board_v4l2_cxt->aver_xilinx_handle); - mesg("%s locked fe %dx%d%c\n",__func__,fe_frameinfo->width,fe_frameinfo->height,(fe_frameinfo->is_interlace)?'i':'p'/*,fe_frameinfo->framerate*/); - //debug_msg("pixclock %d colorspace %d\n",fe_frameinfo->pixel_clock,fe_frameinfo->colorspace); + pr_info("locked fe %dx%d%c %dHz %d\n",fe_frameinfo->width,fe_frameinfo->height,(fe_frameinfo->is_interlace)?'i':'p', fe_frameinfo->framerate, fe_frameinfo->denominator); + pr_info("pixclock %d\n",fe_frameinfo->pixel_clock); //work around for ITE6805 detect issue if ((fe_frameinfo->is_interlace==0) && ((fe_frameinfo->height == 240) || (fe_frameinfo->height == 288))) @@ -735,8 +760,15 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) { //debug_msg("ITE6805 framerate adapter\n"); fe_frameinfo->framerate /= 2; - } + } + ite6805_get_hdcp_level(ite6805_handle, &hdcp_flag); + + U8_T state; + if (gc573_i2c_read(board_v4l2_cxt->fg_handle, 0, 0x70, 0xd0, 1, &state, 1, 0) == 0){ + hdcp_flag = hdcp_flag | (state&1); + } + *fe_audioinfo = aver_xilinx_get_audioinfo(board_v4l2_cxt->aver_xilinx_handle); framegrabber_s_input_audioinfo(board_v4l2_cxt->fg_handle,*fe_audioinfo); @@ -747,7 +779,7 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) framegrabber_s_input_framesize(board_v4l2_cxt->fg_handle,fe_frameinfo->width,fe_frameinfo->height); //tt 0602 framegrabber_s_input_dualmode(board_v4l2_cxt->fg_handle,fe_frameinfo->dual_pixel); //tt 1003 - + framegrabber_s_hdcp_flag(board_v4l2_cxt->fg_handle,hdcp_flag); //aver_xilinx_dual_pixel(board_v4l2_cxt->aver_xilinx_handle,fe_frameinfo->dual_pixel); @@ -768,10 +800,10 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) ite6805_set_out_format(ite6805_handle,out_format); //ite6805_set_out_format(board_v4l2_cxt->i2c_chip_handle[CX511H_I2C_CHIP_ITE6805_1],ITE6805_OUT_FORMAT_SDR_ITU656_24_MODE0); } - //debug_msg("=========== ite6805_set_out_format=%02x\n",out_format); + pr_info("ite6805_set_out_format=%02x\n",out_format); } //sys_msleep(100); - //debug_msg("pixelclock %d detected %dx%d%c\n",fe_frameinfo->pixel_clock,detected_frameinfo.width,detected_frameinfo.height,(detected_frameinfo.is_interlace) ?'i':'p'); + pr_info("pixelclock %d detected %dx%d%c\n",fe_frameinfo->pixel_clock,fe_frameinfo->width,fe_frameinfo->height,(fe_frameinfo->is_interlace) ?'i':'p'); framegrabber_s_input_status(board_v4l2_cxt->fg_handle,FRAMEGRABBER_INPUT_STATUS_OK); framegrabber_mask_s_status(board_v4l2_cxt->fg_handle,FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT,FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT); @@ -779,7 +811,7 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) } break; case ITE6805_UNLOCK: - //debug_msg("ITE6805_UNLOCK\n"); + pr_info("ITE6805_UNLOCK\n"); framegrabber_s_hdcp_flag(board_v4l2_cxt->fg_handle,0); framegrabber_s_input_framesize(board_v4l2_cxt->fg_handle,0,0); //tt 0615 framegrabber_mask_s_status(board_v4l2_cxt->fg_handle,FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT,0); @@ -787,7 +819,7 @@ static void cx511h_ite6805_event(void *cxt,ite6805_event_e event) break; case ITE6805_HDCP: - //debug_msg("ITE6805_HDCP\n"); + pr_info("ITE6805_HDCP\n"); ite6805_get_hdcp_level(ite6805_handle, &hdcp_flag); framegrabber_s_hdcp_flag(board_v4l2_cxt->fg_handle,hdcp_flag); break; @@ -833,7 +865,7 @@ void board_v4l2_init(cxt_mgr_handle_t cxt_mgr, int board_id) break; } - framegrabber_handle = framegrabber_init(cxt_mgr, &cl511h_property, &cx511h_ops); + framegrabber_handle = framegrabber_init(cxt_mgr, &gc573_property, &gc573_ops); if (framegrabber_handle == NULL) { err = BOARD_V4L2_ERROR_FRAMEGRABBER_INIT; @@ -870,9 +902,9 @@ void board_v4l2_init(cxt_mgr_handle_t cxt_mgr, int board_id) break; } board_v4l2_cxt->i2c_model_handle = i2c_mgr; - for(i=0;ii2c_chip_handle[i]=i2c_model_get_nth_driver_handle(i2c_mgr,cl511h_chip_desc[i].name,cl511h_chip_desc[i].index); + board_v4l2_cxt->i2c_chip_handle[i]=i2c_model_get_nth_driver_handle(i2c_mgr,gc573_chip_desc[i].name,gc573_chip_desc[i].index); debug_msg("board_v4l2 i2c_chip_handle[%d] %p\n",i,board_v4l2_cxt->i2c_chip_handle[i]); } task_model_handle=cxt_manager_get_context(cxt_mgr,TASK_MODEL_CXT_ID,0); @@ -894,17 +926,17 @@ void board_v4l2_init(cxt_mgr_handle_t cxt_mgr, int board_id) aver_xilinx_hdmi_hotplug(board_v4l2_cxt->aver_xilinx_handle); - v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_STREAMON ,&cx511h_v4l2_stream_on, board_v4l2_cxt); - v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_STREAMOFF,&cx511h_v4l2_stream_off, board_v4l2_cxt); - v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_BUFFER_PREPARE,&cx511h_v4l2_buffer_prepare, board_v4l2_cxt); - v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_BUFFER_INIT,&cx511h_v4l2_buffer_init, board_v4l2_cxt); + v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_STREAMON ,&gc573_v4l2_stream_on, board_v4l2_cxt); + v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_STREAMOFF,&gc573_v4l2_stream_off, board_v4l2_cxt); + v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_BUFFER_PREPARE,&gc573_v4l2_buffer_prepare, board_v4l2_cxt); + v4l2_model_register_callback(v4l2_handle,V4L2_MODEL_CALLBACK_BUFFER_INIT,&gc573_v4l2_buffer_init, board_v4l2_cxt); - ite6805_register_callback(board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0],cx511h_ite6805_event,board_v4l2_cxt); + ite6805_register_callback(board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0],gc573_ite6805_event,board_v4l2_cxt); framegrabber_start(framegrabber_handle); cxt_manager_ref_context(aver_xilinx_handle); board_v4l2_cxt->board_id = board_id; - //ite6805_get_board_id(board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0],&board_v4l2_cxt->board_id); + //ite6805_get_board_id(board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0],&board_v4l2_cxt->board_id); } while (0); @@ -923,7 +955,7 @@ void board_v4l2_init(cxt_mgr_handle_t cxt_mgr, int board_id) default: break; } - debug_msg("%s err %d\n", __func__, err); + pr_err("err %d\n", err); } } @@ -939,7 +971,7 @@ void board_v4l2_suspend(cxt_mgr_handle_t cxt_mgr) return; } - ite6805_handle = board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + ite6805_handle = board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; if (!ite6805_handle) { debug_msg("Error: cannot get ite6805_handle"); @@ -961,7 +993,7 @@ void board_v4l2_resume(cxt_mgr_handle_t cxt_mgr) return; } - ite6805_handle = board_v4l2_cxt->i2c_chip_handle[CL511H_I2C_CHIP_ITE6805_0]; + ite6805_handle = board_v4l2_cxt->i2c_chip_handle[GC573_I2C_CHIP_ITE6805_0]; if (!ite6805_handle) { debug_msg("Error: cannot get ite6805_handle"); diff --git a/driver/board/cx511h/board_v4l2.h b/driver/board/gc573/board_v4l2.h similarity index 93% rename from driver/board/cx511h/board_v4l2.h rename to driver/board/gc573/board_v4l2.h index 4acaaee..d67f4da 100644 --- a/driver/board/cx511h/board_v4l2.h +++ b/driver/board/gc573/board_v4l2.h @@ -25,7 +25,7 @@ extern "C" { void board_v4l2_init(cxt_mgr_handle_t cxt_mgr, int board_id); void board_v4l2_suspend(cxt_mgr_handle_t cxt_mgr); void board_v4l2_resume(cxt_mgr_handle_t cxt_mgr); -//void cx511h_adv7619_set_bchs(framegrabber_handle_t handle); +//void gc573_adv7619_set_bchs(framegrabber_handle_t handle); #define BOARD_V4L2_CXT_ID fourcc_id('B','V','4','L') #ifdef __cplusplus diff --git a/driver/cxt_mgr.c b/driver/cxt_mgr.c index 34b561e..fc64ac5 100644 --- a/driver/cxt_mgr.c +++ b/driver/cxt_mgr.c @@ -36,7 +36,7 @@ static void cxt_item_unref(cxt_item_t *cxt_item) if (cxt_item->ref_count == 0) { // char *idc=(char *)&cxt_item->cxt_id; - // printk("%s %c%c%c%c\n",__func__,idc[0],idc[1],idc[2],idc[3]); + // pr_info("%s %c%c%c%c\n",__func__,idc[0],idc[1],idc[2],idc[3]); queue_del(&cxt_item->queue); if (cxt_item->release) @@ -93,7 +93,7 @@ void cxt_manager_release(cxt_mgr_handle_t handle) } mem_model_free_buffer(cxt_mgr); - // printk("%s done\n",__func__); + // pr_info("%s done\n",__func__); } void *cxt_manager_add_cxt(cxt_mgr_handle_t handle, U32_T id, cxt_alloc_func_t *alloc_func, cxt_release_func_t *release_func) @@ -167,7 +167,7 @@ void cxt_manager_ref_context(void *context) } if (!cxt_mgr) { - // printk("%s can't get cxt_mgr from context\n",__func__); + // pr_info("%s can't get cxt_mgr from context\n",__func__); } } @@ -181,7 +181,7 @@ void *cxt_manager_get_context(cxt_mgr_handle_t handle, U32_T cxt_id, U8_T index) for_each_queue_entry(pos, &cxt_mgr->cxt_queue, queue) { - //printk("%s %p %x\n",__func__,pos,pos->cxt_id); + //pr_info("%s %p %x\n",__func__,pos,pos->cxt_id); if (pos->cxt_id == cxt_id && pos->index == index) { found = pos; diff --git a/driver/entry.c b/driver/entry.c index 8ec099c..b139d7b 100644 --- a/driver/entry.c +++ b/driver/entry.c @@ -17,10 +17,11 @@ #include #include #include "aver_version.h" +#include "board.h" //#define DRIVER_VER "1.0.0026" -int board_init(void); -void board_exit(void); +//int board_init(void); +//void board_exit(void); static int __init aver_init(void) { int ret=0; @@ -40,7 +41,7 @@ module_exit(aver_fini); MODULE_VERSION(DRIVER_VER); MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Driver for cx511h capture card" " v" DRIVER_VER); +MODULE_DESCRIPTION("Driver for gc573 capture card" " v" DRIVER_VER); MODULE_AUTHOR("AVerMedia Tech. Inc."); diff --git a/driver/include/board.h b/driver/include/board.h index b8cdbd6..9dcba2a 100644 --- a/driver/include/board.h +++ b/driver/include/board.h @@ -24,20 +24,20 @@ extern "C" { typedef enum { - CL511H=0, + GC573=0, SUPPORT_BOARD_NUM, }board_type_e; -enum cl511h_input_e +enum gc573_input_e { - CL511H_HDMI_INPUT=0, - CL511H_INPUT_COUNT, + GC573_HDMI_INPUT=0, + GC573_INPUT_COUNT, }; -enum cl511h_i2c_chip_e +enum gc573_i2c_chip_e { - CL511H_I2C_CHIP_ITE6805_0, - CL511H_I2C_CHIP_COUNT, + GC573_I2C_CHIP_ITE6805_0, + GC573_I2C_CHIP_COUNT, }; typedef struct @@ -46,6 +46,9 @@ typedef struct int index; }board_chip_desc_t; +int board_init(void); +void board_exit(void); + #ifdef __cplusplus } #endif diff --git a/driver/include/ite6805_EDID.h b/driver/include/ite6805_EDID.h deleted file mode 100644 index 6e5f7e1..0000000 --- a/driver/include/ite6805_EDID.h +++ /dev/null @@ -1,80 +0,0 @@ -///***************************************** -// Copyright (C) 2009-2017 -// ITE Tech. Inc. All Rights Reserved -// Proprietary and Confidential -///***************************************** -// @file -// @author Kuro.Chung@ite.com.tw -// @date 2017/12/01 -// @fileversion: iTE6805_MCUSRC_1.10 -//******************************************/ - -#ifndef _ITE6805_EDID_H_ -#define _ITE6805_EDID_H_ - -#include "it6664_typedef.h" - - -#ifndef EDID_SELECT_TABLE -#define EDID_SELECT_TABLE (16) // 8->16 only 3840 EDID -#endif - -// add by AndyNien, 20171209, const -iTE_u8 Default_Edid_Block[256] = { -// AverMedia GC573 EDID // !!!!!!!!!! here we make 6663 & 68051 with same edid !!!!!!!!!// -// refer ite6664_defaultEDID.h add by AndyNien, 20171115 // -////////////////////////////////////////////////////////////////////////////////////////// - -0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x06, 0xd8, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, -0x24, 0x1c, 0x01, 0x03, 0x80, 0xa0, 0x5a, 0x78, 0xea, 0x08, 0xa5, 0xa2, 0x57, 0x4f, 0xa2, 0x28, -0x0f, 0x50, 0x54, 0x25, 0x0b, 0x00, 0xd1, 0xc0, 0x81, 0xc0, 0x81, 0x80, 0x81, 0x00, 0x8b, 0xc0, -0x95, 0x00, 0xb3, 0x00, 0x3b, 0x80, 0x08, 0xe8, 0x00, 0x30, 0xf2, 0x70, 0x5a, 0x80, 0xb0, 0x58, -0x8a, 0x00, 0x6d, 0x55, 0x21, 0x00, 0x00, 0x1e, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, -0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x41, -0x56, 0x54, 0x20, 0x43, 0x4c, 0x35, 0x31, 0x31, 0x2d, 0x48, 0x4e, 0x0a, 0x00, 0x00, 0x00, 0xfd, -0x00, 0x32, 0xf0, 0x1e, 0xde, 0x3c, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x7f, -0x02, 0x03, 0x50, 0x70, 0x5e, 0x61, 0x60, 0x66, 0x65, 0x5f, 0x5e, 0x5d, 0x10, 0x1f, 0x5a, 0x3f, -0x05, 0x14, 0x04, 0x13, 0x12, 0x11, 0x03, 0x02, 0x01, 0x22, 0x21, 0x20, 0x16, 0x15, 0x07, 0x06, -0x62, 0x63, 0x64, 0x23, 0x0f, 0x07, 0x07, 0x83, 0x4f, 0x00, 0x00, 0x6e, 0x03, 0x0c, 0x00, 0x10, -0x00, 0x38, 0x3c, 0x20, 0x00, 0x80, 0x01, 0x02, 0x03, 0x04, 0x67, 0xd8, 0x5d, 0xc4, 0x01, 0x78, -0x80, 0x03, 0xe2, 0x00, 0x4f, 0xe3, 0x05, 0xc0, 0x00, 0xe2, 0x0f, 0x0f, 0xe3, 0x06, 0x05, 0x01, -0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0, 0x29, 0x50, 0x30, 0x20, 0x35, 0x00, 0x55, 0x50, 0x21, 0x00, -0x00, 0x1e, 0xfc, 0x7e, 0x80, 0x88, 0x70, 0x38, 0x12, 0x40, 0x18, 0x20, 0x35, 0x00, 0x20, 0x2f, -0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, -}; - -// this is the fixed edid, cannot be change -// -// -// note: this block is fixed, -// so, if user doing edid restore defauld api, system will copy this block to Default_Edid_Block -// - iTE_u8 Fix_Edid_Block_Number = 2; - iTE_u8 Fix_Edid_Block[256] = { -0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x06, 0xd8, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, -0x24, 0x1c, 0x01, 0x03, 0x80, 0xa0, 0x5a, 0x78, 0xea, 0x08, 0xa5, 0xa2, 0x57, 0x4f, 0xa2, 0x28, -0x0f, 0x50, 0x54, 0x25, 0x0b, 0x00, 0xd1, 0xc0, 0x81, 0xc0, 0x81, 0x80, 0x81, 0x00, 0x8b, 0xc0, -0x95, 0x00, 0xb3, 0x00, 0x3b, 0x80, 0x08, 0xe8, 0x00, 0x30, 0xf2, 0x70, 0x5a, 0x80, 0xb0, 0x58, -0x8a, 0x00, 0x6d, 0x55, 0x21, 0x00, 0x00, 0x1e, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 0x2d, 0x40, -0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x41, -0x56, 0x54, 0x20, 0x43, 0x4c, 0x35, 0x31, 0x31, 0x2d, 0x48, 0x4e, 0x0a, 0x00, 0x00, 0x00, 0xfd, -0x00, 0x32, 0xf0, 0x1e, 0xde, 0x3c, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x7f, -0x02, 0x03, 0x50, 0x70, 0x5e, 0x61, 0x60, 0x66, 0x65, 0x5f, 0x5e, 0x5d, 0x10, 0x1f, 0x5a, 0x3f, -0x05, 0x14, 0x04, 0x13, 0x12, 0x11, 0x03, 0x02, 0x01, 0x22, 0x21, 0x20, 0x16, 0x15, 0x07, 0x06, -0x62, 0x63, 0x64, 0x23, 0x0f, 0x07, 0x07, 0x83, 0x4f, 0x00, 0x00, 0x6e, 0x03, 0x0c, 0x00, 0x10, -0x00, 0x38, 0x3c, 0x20, 0x00, 0x80, 0x01, 0x02, 0x03, 0x04, 0x67, 0xd8, 0x5d, 0xc4, 0x01, 0x78, -0x80, 0x03, 0xe2, 0x00, 0x4f, 0xe3, 0x05, 0xc0, 0x00, 0xe2, 0x0f, 0x0f, 0xe3, 0x06, 0x05, 0x01, -0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0, 0x29, 0x50, 0x30, 0x20, 0x35, 0x00, 0x55, 0x50, 0x21, 0x00, -0x00, 0x1e, 0xfc, 0x7e, 0x80, 0x88, 0x70, 0x38, 0x12, 0x40, 0x18, 0x20, 0x35, 0x00, 0x20, 0x2f, -0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, - -}; - - - -void iTE6805_EDID_RAMInitial(void *ite6805_handle); -void iTE6805_EDID_ParseVSDB_3Dblock(void *ite6805_handle); -iTE_u8 iTE6805_EDID_UpdateRAM(void *ite6805_handle, iTE_u8 *pEDID,iTE_u8 BlockNUM); -iTE_u8 iTE6805_EDID_Find_Phyaddress(iTE_u8 *pEDID); - -#endif // _ITE6805_EDID_H_ diff --git a/driver/lib/AVerScaleVideo.o_shipped b/driver/lib/AVerScaleVideo.o_shipped new file mode 100644 index 0000000..e850e72 Binary files /dev/null and b/driver/lib/AVerScaleVideo.o_shipped differ diff --git a/driver/lib/aver_xilinx.o_shipped b/driver/lib/aver_xilinx.o_shipped new file mode 100644 index 0000000..1ced323 Binary files /dev/null and b/driver/lib/aver_xilinx.o_shipped differ diff --git a/driver/include/AVerScaleVideo.h b/driver/lib/include/AVerScaleVideo.h similarity index 100% rename from driver/include/AVerScaleVideo.h rename to driver/lib/include/AVerScaleVideo.h diff --git a/driver/include/aver_xilinx.h b/driver/lib/include/aver_xilinx.h similarity index 95% rename from driver/include/aver_xilinx.h rename to driver/lib/include/aver_xilinx.h index 8f2f2a8..11a6720 100644 --- a/driver/include/aver_xilinx.h +++ b/driver/lib/include/aver_xilinx.h @@ -314,17 +314,19 @@ typedef enum typedef enum { AVER_XILINX_FMT_YUYV = 0, - AVER_XILINX_FMT_UYVY, - AVER_XILINX_FMT_YVYU, - AVER_XILINX_FMT_VYUY, - AVER_XILINX_FMT_RGBP, - AVER_XILINX_FMT_RGBR, - AVER_XILINX_FMT_RGBO, - AVER_XILINX_FMT_RGBQ, - AVER_XILINX_FMT_RGB3, - AVER_XILINX_FMT_BGR3, - AVER_XILINX_FMT_RGB4, - AVER_XILINX_FMT_BGR4, + AVER_XILINX_FMT_UYVY, //1 + AVER_XILINX_FMT_YVYU, //2, not available + AVER_XILINX_FMT_VYUY, //3, not available + AVER_XILINX_FMT_YVU420, //YV12 + AVER_XILINX_FMT_NV12, //5 + AVER_XILINX_FMT_RGBP, //6, not available + AVER_XILINX_FMT_RGBR, //7, not available + AVER_XILINX_FMT_RGBO, //8, not available + AVER_XILINX_FMT_RGBQ, //9, not available + AVER_XILINX_FMT_RGB3, //0x0a, not available + AVER_XILINX_FMT_BGR3, //0x0b + AVER_XILINX_FMT_RGB4, //0x0c + AVER_XILINX_FMT_BGR4, //0x0d, not available }aver_xilinx_pixfmt_e; typedef enum @@ -450,6 +452,9 @@ void aver_xilinx_set_audio_dma(handle_t aver_xilinx_handle,aver_xilinx_audio_cfg void aver_xilinx_start_audio_streaming(handle_t aver_xilinx_handle,aver_xilinx_audio_cbinfo_t *cb_info); void aver_xilinx_stop_audio_streaming(handle_t aver_xilinx_handle); void aver_xilinx_add_to_cur_desclist(handle_t aver_xilinx_handle,unsigned long phys_addr,unsigned size); +#if 1 //[AVTLD-79]+ +void aver_xilinx_translate_desclist(handle_t aver_xilinx_handle, unsigned int size, unsigned int size_2, unsigned int size_3); +#endif //[AVTLD-79]- void aver_xilinx_active_current_desclist(handle_t aver_xilinx_handle,aver_xilinx_callback_t callback,void *cb_cxt); void aver_xilinx_config_video_process(handle_t aver_xilinx_handle,aver_xilinx_video_process_cfg_t *vip_cfg); void aver_xilinx_get_frameinfo(handle_t aver_xilinx_handle,aver_xilinx_frame_info_t *frameinfo,U32_T pixelclock); diff --git a/driver/include/iTE6805_VM_TABLE.h b/driver/lib/include/iTE6805_VM_TABLE.h similarity index 100% rename from driver/include/iTE6805_VM_TABLE.h rename to driver/lib/include/iTE6805_VM_TABLE.h diff --git a/driver/include/it6664_EDID.h b/driver/lib/include/it6664_EDID.h similarity index 100% rename from driver/include/it6664_EDID.h rename to driver/lib/include/it6664_EDID.h diff --git a/driver/include/it6664_IO.h b/driver/lib/include/it6664_IO.h similarity index 100% rename from driver/include/it6664_IO.h rename to driver/lib/include/it6664_IO.h diff --git a/driver/include/it6664_config.h b/driver/lib/include/it6664_config.h similarity index 97% rename from driver/include/it6664_config.h rename to driver/lib/include/it6664_config.h index 67bf368..7d01172 100644 --- a/driver/include/it6664_config.h +++ b/driver/lib/include/it6664_config.h @@ -12,6 +12,10 @@ #define _IT6664_CONFIG_H_ +#ifndef USING_1to8 + #define USING_1to8 FALSE +#endif + #define IT6663_C 0x01 diff --git a/driver/include/it6664_extern.h b/driver/lib/include/it6664_extern.h similarity index 100% rename from driver/include/it6664_extern.h rename to driver/lib/include/it6664_extern.h diff --git a/driver/include/it6664_hdmi2_rx.h b/driver/lib/include/it6664_hdmi2_rx.h similarity index 100% rename from driver/include/it6664_hdmi2_rx.h rename to driver/lib/include/it6664_hdmi2_rx.h diff --git a/driver/include/it6664_hdmi2_tx.h b/driver/lib/include/it6664_hdmi2_tx.h similarity index 100% rename from driver/include/it6664_hdmi2_tx.h rename to driver/lib/include/it6664_hdmi2_tx.h diff --git a/driver/include/it6664_hdmi2sp.h b/driver/lib/include/it6664_hdmi2sp.h similarity index 100% rename from driver/include/it6664_hdmi2sp.h rename to driver/lib/include/it6664_hdmi2sp.h diff --git a/driver/include/it6664_typedef.h b/driver/lib/include/it6664_typedef.h similarity index 100% rename from driver/include/it6664_typedef.h rename to driver/lib/include/it6664_typedef.h diff --git a/driver/include/ite6664.h b/driver/lib/include/ite6664.h similarity index 99% rename from driver/include/ite6664.h rename to driver/lib/include/ite6664.h index b3783ac..db723a9 100644 --- a/driver/include/ite6664.h +++ b/driver/lib/include/ite6664.h @@ -1,7 +1,6 @@ #ifndef _ITE6664_SRC_H_ #define _ITE6664_SRC_H_ -#include "version.h" #include "typedef.h" #include "cxt_mgr.h" #include "it6664_typedef.h" diff --git a/driver/include/ite6805.h b/driver/lib/include/ite6805.h similarity index 98% rename from driver/include/ite6805.h rename to driver/lib/include/ite6805.h index d047c8d..ae28c24 100644 --- a/driver/include/ite6805.h +++ b/driver/lib/include/ite6805.h @@ -578,15 +578,15 @@ typedef struct iTE_u32 m_PacketVideoLock; iTE_u32 m_PacketActWidth; iTE_u32 m_PacketActHeight; - iTE_u32 m_PacketVIC; + //iTE_u32 m_PacketVIC; iTE_u32 m_PacketInputSamplingMode; // 0: rgb, 1:422, 2:444 - iTE_u32 m_PacketOutputSamplingMode; + //iTE_u32 m_PacketOutputSamplingMode; iTE_u32 m_PacketInterlace; iTE_u32 m_PacketDeepColorBits; iTE_u32 m_PacketOutputColorSpace; //iTE_u32 m_PacketOutputColorSpace; - iTE_u32 m_PacketOutputRGBQuantizationRange; + //iTE_u32 m_PacketOutputRGBQuantizationRange; iTE_u32 m_PacketAudioSamplingFreq; iTE_u32 m_oldPacketAudioSamplingFreq; iTE_u32 m_PacketAudioType; @@ -594,7 +594,7 @@ typedef struct iTE_u32 m_OldPacketAudioChannelCount; iTE_u32 m_PacketAudioSamplingBits; iTE_u32 m_PacketHDCP; - iTE_u32 m_PacketPCLK; + //iTE_u32 m_PacketPCLK; iTE_u32 m_PacketFrameRate; iTE_u32 m_PacketDDRMode; iTE_u32 m_PacketDualPixelMode; @@ -604,11 +604,11 @@ typedef struct iTE_u32 m_InterlaceBitRetryCount; RXITE68051_VIDEO_POS m_VideoPos; - iTE_u8 m_VendorSpecificInfoframe[31]; + //iTE_u8 m_VendorSpecificInfoframe[31]; iTE_u8 m_AVIInfoframe[AVI_INFOFRAME_SIZE]; // add by AndyNien, 20171109 - iTE_u8 m_SPDInfoframe[21]; // size ?? - iTE_u8 m_AudioInfoframe[14]; // size 14 + //iTE_u8 m_SPDInfoframe[21]; // size ?? + //iTE_u8 m_AudioInfoframe[14]; // size 14 iTE_u8 m_DRMInfoframe[DRM_HDR_METADATA_SIZE]; iTE_u8 m_Old_DRMInfoframe[DRM_HDR_METADATA_SIZE]; }ite6805_cxt_t; diff --git a/driver/lib/include/ite6805_EDID.h b/driver/lib/include/ite6805_EDID.h new file mode 100644 index 0000000..e6778c5 --- /dev/null +++ b/driver/lib/include/ite6805_EDID.h @@ -0,0 +1,82 @@ +///***************************************** +// Copyright (C) 2009-2017 +// ITE Tech. Inc. All Rights Reserved +// Proprietary and Confidential +///***************************************** +// @file +// @author Kuro.Chung@ite.com.tw +// @date 2017/12/01 +// @fileversion: iTE6805_MCUSRC_1.10 +//******************************************/ + +#ifndef _ITE6805_EDID_H_ +#define _ITE6805_EDID_H_ + +#include "it6664_typedef.h" + + +#ifndef EDID_SELECT_TABLE +#define EDID_SELECT_TABLE (16) // 8->16 only 3840 EDID +#endif + +// add by AndyNien, 20171209, const +iTE_u8 Default_Edid_Block[256] = { +// AverMedia GC573 EDID // !!!!!!!!!! here we make 6663 & 68051 with same edid !!!!!!!!!// +// refer ite6664_defaultEDID.h add by AndyNien, 20171115 // +////////////////////////////////////////////////////////////////////////////////////////// + + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x06, 0xd8, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x1c, 0x01, 0x03, 0x80, 0xa0, 0x5a, 0x78,0xea, 0x08, 0xa5, 0xa2, 0x57, 0x4f, 0xa2, 0x28, + 0x0f, 0x50, 0x54, 0x25, 0x0b, 0x00, 0xd1, 0xc0, 0x81, 0x40, 0x81, 0x80, 0x81, 0x00, 0x8b, 0xc0, + 0x95, 0x00, 0xb3, 0x00, 0x3b, 0x80, 0x08, 0xe8, 0x00, 0x30, 0xf2, 0x70, 0x5a, 0x80, 0xb0, 0x58, + 0x8a, 0x00, 0x6d, 0x55, 0x21, 0x00, 0x00, 0x1e, 0x0c, 0xdf, 0x80, 0xa0, 0x70, 0x38, 0x40, 0x40, + 0x30, 0x40, 0x35, 0x00, 0x20, 0x2f, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x41, + 0x56, 0x54, 0x20, 0x47, 0x43, 0x35, 0x37, 0x33, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, + 0x00, 0x32, 0xf0, 0x1e, 0xde, 0x3c, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x11, + 0x02, 0x03, 0x44, 0xf1, 0x59, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x10, 0x1f, 0x5a, 0x3f, 0x05, 0x14, + 0x04, 0x13, 0x12, 0x11, 0x03, 0x02, 0x01, 0x22, 0x21, 0x20, 0x16, 0x15, 0x07, 0x06, 0x23, 0x0f, + 0x07, 0x07, 0x83, 0x4f, 0x00, 0x00, 0x67, 0x03, 0x0c, 0x00, 0x10, 0x00, 0x38, 0x3c, 0x67, 0xd8, + 0x5d, 0xc4, 0x01, 0x78, 0x80, 0x03, 0xe2, 0x00, 0xcf, 0xe3, 0x05, 0xc0, 0x00, 0xe2, 0x0f, 0x03, + 0xe3, 0x06, 0x05, 0x01, 0x6f, 0xc2, 0x00, 0xa0, 0xa0, 0xa0, 0x55, 0x50, 0x30, 0x20, 0x35, 0x00, + 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0x9e, 0xe8, 0x00, 0x78, 0xa0, 0xa0, 0x67, 0x50, 0x08, 0x20, + 0x98, 0x04, 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0xfc, 0x7e, 0x80, 0x88, 0x70, 0x38, 0x12, 0x40, + 0x18, 0x20, 0x35, 0x00, 0x20, 0x2f, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff + +}; + +// this is the fixed edid, cannot be change +// +// +// note: this block is fixed, +// so, if user doing edid restore defauld api, system will copy this block to Default_Edid_Block +// + iTE_u8 Fix_Edid_Block_Number = 2; + iTE_u8 Fix_Edid_Block[256] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x06, 0xd8, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x1c, 0x01, 0x03, 0x80, 0xa0, 0x5a, 0x78,0xea, 0x08, 0xa5, 0xa2, 0x57, 0x4f, 0xa2, 0x28, + 0x0f, 0x50, 0x54, 0x25, 0x0b, 0x00, 0xd1, 0xc0, 0x81, 0x40, 0x81, 0x80, 0x81, 0x00, 0x8b, 0xc0, + 0x95, 0x00, 0xb3, 0x00, 0x3b, 0x80, 0x08, 0xe8, 0x00, 0x30, 0xf2, 0x70, 0x5a, 0x80, 0xb0, 0x58, + 0x8a, 0x00, 0x6d, 0x55, 0x21, 0x00, 0x00, 0x1e, 0x0c, 0xdf, 0x80, 0xa0, 0x70, 0x38, 0x40, 0x40, + 0x30, 0x40, 0x35, 0x00, 0x20, 0x2f, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x41, + 0x56, 0x54, 0x20, 0x47, 0x43, 0x35, 0x37, 0x33, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, + 0x00, 0x32, 0xf0, 0x1e, 0xde, 0x3c, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, 0x11, + 0x02, 0x03, 0x44, 0xf1, 0x59, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x10, 0x1f, 0x5a, 0x3f, 0x05, 0x14, + 0x04, 0x13, 0x12, 0x11, 0x03, 0x02, 0x01, 0x22, 0x21, 0x20, 0x16, 0x15, 0x07, 0x06, 0x23, 0x0f, + 0x07, 0x07, 0x83, 0x4f, 0x00, 0x00, 0x67, 0x03, 0x0c, 0x00, 0x10, 0x00, 0x38, 0x3c, 0x67, 0xd8, + 0x5d, 0xc4, 0x01, 0x78, 0x80, 0x03, 0xe2, 0x00, 0xcf, 0xe3, 0x05, 0xc0, 0x00, 0xe2, 0x0f, 0x03, + 0xe3, 0x06, 0x05, 0x01, 0x6f, 0xc2, 0x00, 0xa0, 0xa0, 0xa0, 0x55, 0x50, 0x30, 0x20, 0x35, 0x00, + 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0x9e, 0xe8, 0x00, 0x78, 0xa0, 0xa0, 0x67, 0x50, 0x08, 0x20, + 0x98, 0x04, 0x55, 0x50, 0x21, 0x00, 0x00, 0x1e, 0xfc, 0x7e, 0x80, 0x88, 0x70, 0x38, 0x12, 0x40, + 0x18, 0x20, 0x35, 0x00, 0x20, 0x2f, 0x21, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff + + +}; + + + +void iTE6805_EDID_RAMInitial(void *ite6805_handle); +void iTE6805_EDID_ParseVSDB_3Dblock(void *ite6805_handle); +iTE_u8 iTE6805_EDID_UpdateRAM(void *ite6805_handle, iTE_u8 *pEDID,iTE_u8 BlockNUM); +iTE_u8 iTE6805_EDID_Find_Phyaddress(iTE_u8 *pEDID); + +#endif // _ITE6805_EDID_H_ diff --git a/driver/include/ite6805_EQ.h b/driver/lib/include/ite6805_EQ.h similarity index 100% rename from driver/include/ite6805_EQ.h rename to driver/lib/include/ite6805_EQ.h diff --git a/driver/include/ite6805_config.h b/driver/lib/include/ite6805_config.h similarity index 98% rename from driver/include/ite6805_config.h rename to driver/lib/include/ite6805_config.h index 8139442..25c1589 100644 --- a/driver/include/ite6805_config.h +++ b/driver/lib/include/ite6805_config.h @@ -109,7 +109,7 @@ // for customer can change HDCP state in upper code level, default HDCP is enable // default disable this define #ifndef DYNAMIC_HDCP_ENABLE_DISABLE -#define DYNAMIC_HDCP_ENABLE_DISABLE TRUE // TRUE or FALSE // turn on by AndyNien, 20180105 +#define DYNAMIC_HDCP_ENABLE_DISABLE FALSE // TRUE or FALSE // turn on by AndyNien, 20180105 #endif // DownScale Filter : DownScale Quality setting diff --git a/driver/include/ite6805_csc_table.h b/driver/lib/include/ite6805_csc_table.h similarity index 100% rename from driver/include/ite6805_csc_table.h rename to driver/lib/include/ite6805_csc_table.h diff --git a/driver/include/ite6805_debug.h b/driver/lib/include/ite6805_debug.h similarity index 100% rename from driver/include/ite6805_debug.h rename to driver/lib/include/ite6805_debug.h diff --git a/driver/include/ite6805_dev_define.h b/driver/lib/include/ite6805_dev_define.h similarity index 100% rename from driver/include/ite6805_dev_define.h rename to driver/lib/include/ite6805_dev_define.h diff --git a/driver/include/ite6805_drv.h b/driver/lib/include/ite6805_drv.h similarity index 100% rename from driver/include/ite6805_drv.h rename to driver/lib/include/ite6805_drv.h diff --git a/driver/include/ite6805_sys.h b/driver/lib/include/ite6805_sys.h similarity index 100% rename from driver/include/ite6805_sys.h rename to driver/lib/include/ite6805_sys.h diff --git a/driver/include/pic_bmp.h b/driver/lib/include/pic_bmp.h similarity index 67% rename from driver/include/pic_bmp.h rename to driver/lib/include/pic_bmp.h index b83811a..89de332 100644 --- a/driver/include/pic_bmp.h +++ b/driver/lib/include/pic_bmp.h @@ -12,6 +12,15 @@ typedef void *pic_bmp_handle_t; +typedef enum _pic_bmp_pixfmt_enum_t +{ + PIC_BMP_PIXFMT_YUYV, + PIC_BMP_PIXFMT_YV12, + PIC_BMP_PIXFMT_NV12, + PIC_BMP_PIXFMT_RGB24, + PIC_BMP_PIXFMT_OTHERS, +} pic_bmp_pixfmt_enum_t; + void pic_bmp_init(cxt_mgr_handle_t cxt_mgr , const char *no_signal_filename , const char *out_of_range_filename @@ -19,9 +28,9 @@ void pic_bmp_init(cxt_mgr_handle_t cxt_mgr void pic_bmp_prepare(pic_bmp_handle_t pic_bmp_handle, unsigned long src_width, unsigned long src_height, unsigned long dst_width, unsigned long dst_height); -void load_no_signal_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height); -void load_out_of_range_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height); -void load_copy_protection_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height); +void load_no_signal_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height, pic_bmp_pixfmt_enum_t pixfmt_out); +void load_out_of_range_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height, pic_bmp_pixfmt_enum_t pixfmt_out); +void load_copy_protection_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height, pic_bmp_pixfmt_enum_t pixfmt_out); void load_black_image(pic_bmp_handle_t pic_bmp_handle, unsigned char *dst, int width, int height); #endif /* PIC_INCLUDE_PIC_BMP_H_ */ diff --git a/driver/include/sha204.h b/driver/lib/include/sha204.h similarity index 100% rename from driver/include/sha204.h rename to driver/lib/include/sha204.h diff --git a/driver/include/typedef.h b/driver/lib/include/typedef.h similarity index 100% rename from driver/include/typedef.h rename to driver/lib/include/typedef.h diff --git a/driver/lib/it6664_EDID.o_shipped b/driver/lib/it6664_EDID.o_shipped new file mode 100644 index 0000000..f47e14d Binary files /dev/null and b/driver/lib/it6664_EDID.o_shipped differ diff --git a/driver/lib/it6664_hdmi2_rx.o_shipped b/driver/lib/it6664_hdmi2_rx.o_shipped new file mode 100644 index 0000000..a1cf6c0 Binary files /dev/null and b/driver/lib/it6664_hdmi2_rx.o_shipped differ diff --git a/driver/lib/it6664_hdmi2_tx.o_shipped b/driver/lib/it6664_hdmi2_tx.o_shipped new file mode 100644 index 0000000..6211dce Binary files /dev/null and b/driver/lib/it6664_hdmi2_tx.o_shipped differ diff --git a/driver/lib/it6664_hdmi2sp.o_shipped b/driver/lib/it6664_hdmi2sp.o_shipped new file mode 100644 index 0000000..5f6184c Binary files /dev/null and b/driver/lib/it6664_hdmi2sp.o_shipped differ diff --git a/driver/lib/ite6664.o_shipped b/driver/lib/ite6664.o_shipped new file mode 100644 index 0000000..77dc89a Binary files /dev/null and b/driver/lib/ite6664.o_shipped differ diff --git a/driver/lib/ite6805.o_shipped b/driver/lib/ite6805.o_shipped new file mode 100644 index 0000000..28e4c27 Binary files /dev/null and b/driver/lib/ite6805.o_shipped differ diff --git a/driver/lib/ite6805_EDID.o_shipped b/driver/lib/ite6805_EDID.o_shipped new file mode 100644 index 0000000..986ffe0 Binary files /dev/null and b/driver/lib/ite6805_EDID.o_shipped differ diff --git a/driver/lib/ite6805_EQ.o_shipped b/driver/lib/ite6805_EQ.o_shipped new file mode 100644 index 0000000..f3d70f1 Binary files /dev/null and b/driver/lib/ite6805_EQ.o_shipped differ diff --git a/driver/lib/ite6805_drv.o_shipped b/driver/lib/ite6805_drv.o_shipped new file mode 100644 index 0000000..a7e20d9 Binary files /dev/null and b/driver/lib/ite6805_drv.o_shipped differ diff --git a/driver/lib/ite6805_sys.o_shipped b/driver/lib/ite6805_sys.o_shipped new file mode 100644 index 0000000..15d02cc Binary files /dev/null and b/driver/lib/ite6805_sys.o_shipped differ diff --git a/driver/lib/pic_bmp.o_shipped b/driver/lib/pic_bmp.o_shipped new file mode 100644 index 0000000..d04fe2d Binary files /dev/null and b/driver/lib/pic_bmp.o_shipped differ diff --git a/driver/utils/alsa/alsa.c b/driver/utils/alsa/alsa.c index 07aed61..ecad24f 100644 --- a/driver/utils/alsa/alsa.c +++ b/driver/utils/alsa/alsa.c @@ -9,7 +9,9 @@ * Version: * ================================================================= */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include @@ -78,7 +80,7 @@ static int sagitta_snd_test_stream(void *this) int done_size; bool reset; - printk("%s blob_size = %d\n", __func__, blob_size); + pr_info("%s blob_size = %d\n", __func__, blob_size); for(;;) { @@ -97,7 +99,7 @@ static int sagitta_snd_test_stream(void *this) deliver_size = &_binary_audio_dump_end - audio_head; reset = false; } - printk("%s deliver\n", __func__); + pr_info("%s deliver\n", __func__); #if 1 for(i = 0; i < deliver_size; i++) { if(*(audio_head + i)) { @@ -117,7 +119,7 @@ static int sagitta_snd_test_stream(void *this) } stop: - printk("%s end\n", __func__); + pr_info("%s end\n", __func__); __set_current_state(TASK_RUNNING); @@ -210,8 +212,6 @@ static int snd_sagitta_pcm_open(struct snd_pcm_substream *substream) struct sagitta_snd_dev *sdev = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; - printk("%s\n", __func__); - sdev->substream = substream; runtime->hw = snd_sagitta_hw; snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); @@ -225,8 +225,6 @@ static int snd_sagitta_pcm_close(struct snd_pcm_substream *substream) { struct sagitta_snd_dev *sdev = snd_pcm_substream_chip(substream); - printk("%s\n", __func__); - sdev->substream = NULL; return 0; @@ -235,7 +233,7 @@ static int snd_sagitta_pcm_close(struct snd_pcm_substream *substream) static int snd_sagitta_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - printk("%s() alloc buffer size = %u" + pr_info("%s() alloc buffer size = %u" " periods = %u period_bytes = %u\n", __func__, params_buffer_bytes(hw_params), @@ -253,7 +251,7 @@ static int snd_sagitta_hw_params(struct snd_pcm_substream *substream, static int snd_sagitta_hw_free(struct snd_pcm_substream *substream) { - printk("%s\n", __func__); + pr_info("%s\n", __func__); if(substream->runtime->dma_area) { @@ -269,7 +267,7 @@ static int snd_sagitta_prepare(struct snd_pcm_substream *substream) { struct sagitta_snd_dev *sdev = snd_pcm_substream_chip(substream); - printk("%s\n", __func__); + pr_info("%s\n", __func__); sdev->capture_transfer_done = 0; sdev->hwptr = 0; @@ -285,13 +283,13 @@ static void sagitta_audio_trigger(struct work_struct *work) if(atomic_read(&ssdev->stream_started)) { - printk("%s start\n", __func__); + pr_info("%s start\n", __func__); #if 0 add_timer(&filldata_timer); #endif } else { - printk("%s stop\n", __func__); + pr_info("%s stop\n", __func__); #if 0 del_timer_sync(&filldata_timer); #endif @@ -303,8 +301,6 @@ static int snd_sagitta_card_trigger(struct snd_pcm_substream *substream, { struct sagitta_snd_dev *sdev = snd_pcm_substream_chip(substream); - printk("%s\n", __func__); - switch(cmd) { case SNDRV_PCM_TRIGGER_START: @@ -355,8 +351,6 @@ static int snd_sagitta_pcm(struct sagitta_snd_dev *dev, struct snd_pcm *pcm; int err; - printk("%s\n", __func__); - err = snd_pcm_new(dev->card, name, device_idx, 0, 1, &pcm); if(err < 0) return err; @@ -377,7 +371,6 @@ static struct sagitta_snd_dev *audio_dev_register(struct sagitta_dev *sdev) int err; - printk("%s\n", __func__); #if 0 snd_dev = kmalloc(sizeof(struct sagitta_snd_dev), GFP_KERNEL); if(!snd_dev) { @@ -433,7 +426,7 @@ static struct sagitta_snd_dev *audio_dev_register(struct sagitta_dev *sdev) void audio_dev_deregister(struct sagitta_snd_dev *ssdev) { if(ssdev->card) { - printk("%s snd_card_free\n", __func__); + pr_info("%s snd_card_free\n", __func__); snd_card_free(ssdev->card); ssdev->card = NULL; } @@ -477,7 +470,6 @@ static void alsa_disconnect(struct sagitta_module *module, struct sagitta_dev *s //struct sagitta_snd_dev *ssdev = (struct sagitta_snd_dev *) sagitta_virtdev_getdata(svdev); struct sagitta_snd_dev *ssdev = (struct sagitta_snd_dev *)alsa_mod->context; - printk("%s\n", __func__); //sagitta_trace(module, "%s\n", __func__); @@ -510,7 +502,7 @@ void *alsa_module_get_context(struct sagitta_dev *sdev) if(strncmp(mod->name,ALSA_MODULE_ID_STR,strlen(mod->name))==0) { struct alsa_module *this=(struct alsa_module *)mod; - //printk("%s found context %p\n",__func__,this->context); + //pr_info("%s found context %p\n",__func__,this->context); return this->context; } } diff --git a/driver/utils/alsa/alsa_model.c b/driver/utils/alsa/alsa_model.c index 68c30af..e277bac 100644 --- a/driver/utils/alsa/alsa_model.c +++ b/driver/utils/alsa/alsa_model.c @@ -9,7 +9,9 @@ * Version: * ================================================================= */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include @@ -113,17 +115,17 @@ static void alsa_model_release(void *context) { alsa_model_t *alsa_cxt = context; - printk("%s\n", __func__); + pr_info("%s\n", __func__); if (alsa_cxt) { if (alsa_cxt->card) { snd_card_free(alsa_cxt->card); - printk("%s snd_card_free \n", __func__); + pr_info("%s snd_card_free \n", __func__); } kfree(alsa_cxt); } - printk("%s done\n", __func__); + pr_info("%s done\n", __func__); } #if 1 @@ -168,7 +170,7 @@ static int alsa_model_pcm_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; alsa_cb_info_t *cb_info = NULL; - printk("%s\n", __func__); + pr_info("%s\n", __func__); alsa_cxt->substream = substream; runtime->hw = alsa_cxt->hw_parm; @@ -202,7 +204,7 @@ static int alsa_model_pcm_close(struct snd_pcm_substream *substream) static int alsa_model_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { - printk("%s() alloc buffer size = %u"" periods = %u period_bytes = %u\n", __func__, params_buffer_bytes(hw_params), params_periods(hw_params), params_period_bytes(hw_params)); + pr_info("%s() alloc buffer size = %u"" periods = %u period_bytes = %u\n", __func__, params_buffer_bytes(hw_params), params_periods(hw_params), params_period_bytes(hw_params)); if (substream->runtime->dma_area) { @@ -214,7 +216,7 @@ static int alsa_model_hw_params(struct snd_pcm_substream *substream, struct snd_ static int alsa_model_hw_free(struct snd_pcm_substream *substream) { - printk("%s\n", __func__); + pr_info("%s\n", __func__); if (substream->runtime->dma_area) { @@ -230,7 +232,7 @@ static int alsa_model_prepare(struct snd_pcm_substream *substream) { alsa_model_t *alsa_cxt = snd_pcm_substream_chip(substream); - printk("%s\n", __func__); + pr_info("%s\n", __func__); alsa_cxt->capture_transfer_done = 0; alsa_cxt->hwptr = 0; @@ -243,7 +245,7 @@ static int alsa_model_card_trigger(struct snd_pcm_substream *substream, int cmd) alsa_model_t *alsa_cxt = snd_pcm_substream_chip(substream); alsa_cb_info_t *cb_info = NULL; - printk("%s %p\n", __func__,substream); + pr_info("%s %p\n", __func__,substream); switch (cmd) { @@ -281,7 +283,7 @@ static snd_pcm_uframes_t alsa_model_pointer(struct snd_pcm_substream *substream) spin_lock_irqsave(&alsa_cxt ->slock, flags); hwptr = alsa_cxt ->hwptr; spin_unlock_irqrestore(&alsa_cxt ->slock, flags); -// printk("%s %d\n",__func__,hwptr); +// pr_info("%s %d\n",__func__,hwptr); return hwptr; } @@ -302,33 +304,33 @@ void alsa_model_feed_data(alsa_model_handle_t handle, U8_T *buf, SIZE_T length) bool period_elapsed = false; // int i; - // printk("%s %d: ",__func__,length); + // pr_info("%s %d: ",__func__,length); // for(i=0;i<16;i++) // { - // printk("%02x ",buf[i]); + // pr_info("%02x ",buf[i]); // } - // printk("\n"); + // pr_info("\n"); if (!alsa_cxt->substream) { - // printk("NO substream\n"); + // pr_info("NO substream\n"); return; } if (!length) { - printk("NO length\n"); + pr_info("NO length\n"); return; } if (!alsa_cxt->substream->runtime) { - printk("NO runtime\n"); + pr_info("NO runtime\n"); return; } if (!alsa_cxt->substream->runtime->frame_bits) { - printk("frame_bits 0\n"); + pr_info("frame_bits 0\n"); return; } @@ -340,7 +342,7 @@ void alsa_model_feed_data(alsa_model_handle_t handle, U8_T *buf, SIZE_T length) /* bytes to copy_frames */ remain_frames = length / stride; copy_frames = remain_frames; - //printk("alsa stride:%d remain:%d copy:%d \n", stride, remain_frames, copy_frames); + //pr_info("alsa stride:%d remain:%d copy:%d \n", stride, remain_frames, copy_frames); /* if(oldptr) { @@ -620,8 +622,10 @@ alsa_model_handle_t alsa_model_init(cxt_mgr_handle_t cxt_mgr, alsa_model_setup_t case ALSA_MODEL_REGISTER_SND_CARD_ERROR: case ALSA_MODEL_CREATE_PCM_ERR: snd_card_free(card); + // fall through case ALSA_MODEL_CREATE_SND_CARD_ERROR: cxt_manager_unref_context(alsa_cxt); + // fall through case ALSA_MODEL_ERROR_ALLOC: case ALSA_MODEL_NO_SETUP_INFO: break; diff --git a/driver/utils/gpio/gpio_model.c b/driver/utils/gpio/gpio_model.c index 56dd85f..c98719d 100644 --- a/driver/utils/gpio/gpio_model.c +++ b/driver/utils/gpio/gpio_model.c @@ -9,7 +9,9 @@ * Version: * ================================================================= */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include @@ -63,7 +65,7 @@ static void gpio_model_free_pindesc(pin_desc_t *pin_desc); // struct gpio_module *this=(struct gpio_module *)module; // // this->context=gpio_model_alloc(); -// printk("%s context %p\n",__func__,this->context); +// pr_info("%s context %p\n",__func__,this->context); //} // //static void gpio_module_disconnect(struct sagitta_module *module, struct sagitta_dev *sdev) @@ -205,7 +207,7 @@ static pin_desc_t *gpio_model_find_pin(gpio_ic_t *ic,const char *pin_name) //void gpio_module_init(struct sagitta_module *module) //{ -// printk("%s\n",__func__); +// pr_info("%s\n",__func__); // module->probe = gpio_module_probe; // module->disconnect = gpio_module_disconnect; //} diff --git a/driver/utils/i2c/i2c_model.c b/driver/utils/i2c/i2c_model.c index 419fd4a..9256633 100644 --- a/driver/utils/i2c/i2c_model.c +++ b/driver/utils/i2c/i2c_model.c @@ -1,3 +1,6 @@ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include @@ -91,7 +94,7 @@ static void i2c_model_release(void *context) cxt_manager_unref_context(bus->ref_cxt); } - printk("i2c_del_adapter %p %s\n",&bus->i2c_adap,bus->bus_name); + pr_info("i2c_del_adapter %p %s\n",&bus->i2c_adap,bus->bus_name); i2c_del_adapter(&bus->i2c_adap); mem_model_free_buffer(bus); @@ -338,7 +341,7 @@ int i2c_model_add_bus(i2c_model_handle_t handle,const char *bus_name,void *adap, bus->ref_cxt=ref_cxt; cxt_manager_ref_context(ref_cxt); } - //printk("%s %p %s\n",__func__,bus->adap,bus->bus_name); + //pr_info("%s %p %s\n",__func__,bus->adap,bus->bus_name); }while(0); if(err!=I2C_MODEL_OK) { @@ -398,7 +401,7 @@ i2c_model_error_e i2c_model_bus_attach_device(i2c_model_handle_t handle,const ch { found=pdriver; // SHA204 not ready - printk("I2C_MODEL_BUS pdriver->drv_name ok %s and %s\n",pdriver->drv_name,drv_name); // + pr_info("I2C_MODEL_BUS pdriver->drv_name ok %s and %s\n",pdriver->drv_name,drv_name); // break; } pdriver++; @@ -530,7 +533,7 @@ void *i2c_model_get_nth_driver_handle(i2c_model_handle_t handle,const char *drv_ // { // if(pos->attach) // { -// printk("%s attach\n",pos->drv_name); +// pr_info("%s attach\n",pos->drv_name); // pos->attach(); // } // } @@ -546,7 +549,7 @@ void *i2c_model_get_nth_driver_handle(i2c_model_handle_t handle,const char *drv_ // { // if(pos->detach) // { -// printk("%s detach\n",pos->drv_name); +// pr_info("%s detach\n",pos->drv_name); // pos->detach(); // } // } diff --git a/driver/utils/mem/mem_model.c b/driver/utils/mem/mem_model.c index 3dda6d1..8e20932 100644 --- a/driver/utils/mem/mem_model.c +++ b/driver/utils/mem/mem_model.c @@ -9,13 +9,16 @@ * Version: * ================================================================= */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include #include #include #include +#include #include "cxt_mgr.h" #include "mem_model.h" #include "debug.h" @@ -260,14 +263,14 @@ static mem_model_dma_buffer_t *mem_model_dma_pool_alloc_mem(mem_model_handle_t m if( buffer_item) { - + dma_buffer=&buffer_item->dma_buffer; //dma_buffer->phys_addr=(unsigned long int)dma_addr; dma_buffer->phys_addr=dma_addr; dma_buffer->vaddr=vaddr; dma_buffer->size=dma_pool->cfg.size; queue_add_tail(&buffer_item->queue,&dma_pool->buffer_queue); - debug_msg("%s dma_addr %llx dma_buffer->phys_addr %lx\n",__func__,dma_addr,dma_buffer->phys_addr); + pr_info("dma_addr %llx dma_buffer->phys_addr %lx dma_buffer->size %ld\n",dma_addr,dma_buffer->phys_addr, dma_buffer->size); } } } @@ -414,12 +417,20 @@ void mem_model_release_pool(mem_model_pool_handle_t pool_handle) void *mem_model_new(unsigned int size) { - return vmalloc(size); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) + return kvzalloc(size, GFP_KERNEL); +#else + return kmalloc(size, GFP_KERNEL|__GFP_NORETRY); +#endif } void mem_model_delete(void *buf) { - if (buf) vfree(buf); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) + if (buf) kvfree(buf); +#else + if (buf) kfree(buf); +#endif } static void *mem_model_alloc(void) @@ -446,7 +457,7 @@ static void mem_model_release(void *context) mem_model_dma_buffer_item_t *cur_buffer,*next_buffer; for_each_queue_entry_safe(cur_buffer,next_buffer,&pos->buffer_queue,queue) { - printk("%s %lx size %lx\n",__func__,cur_buffer->dma_buffer.phys_addr,cur_buffer->dma_buffer.size); + pr_info("%s %lx size %lx\n",__func__,cur_buffer->dma_buffer.phys_addr,cur_buffer->dma_buffer.size); mem_model_free_buffer_item(mem_model_cxt,cur_buffer); } } diff --git a/driver/utils/misc/g_queue.c b/driver/utils/misc/g_queue.c index 7363fe4..bf2e23e 100644 --- a/driver/utils/misc/g_queue.c +++ b/driver/utils/misc/g_queue.c @@ -9,10 +9,55 @@ * Version: * ================================================================= */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ #include "g_queue.h" #include "debug.h" +void init_queue(queue_t *item) + { + item->next= item; + item->prev = item; + } + +int queue_empty(queue_t *head) +{ + return (head->next == head); +} + +void __queue_add(queue_t *new,queue_t *prev,queue_t *next) +{ + next->prev = new; + new->next = next; + new->prev = prev; + prev->next= new; + } + + void queue_add_tail(queue_t *new, queue_t *head) + { + __queue_add(new, head->prev, head); + } + + void __queue_del(queue_t * prev, queue_t * next) + { + next->prev = prev; + prev->next= next; + } + +void __queue_del_entry(queue_t *entry) +{ + __queue_del(entry->prev, entry->next); +} + +void queue_del(queue_t *entry) +{ + __queue_del(entry->prev, entry->next); + entry->next = entry; + entry->prev = entry; +} + + void init_g_queue(g_queue_t *head) { init_queue(&head->queue); diff --git a/driver/utils/misc/include/queue.h b/driver/utils/misc/include/queue.h index cdff90e..e765862 100644 --- a/driver/utils/misc/include/queue.h +++ b/driver/utils/misc/include/queue.h @@ -56,47 +56,13 @@ typedef struct queue_item_s { -static inline void init_queue(queue_t *item) - { - item->next= item; - item->prev = item; - } - -static inline int queue_empty(queue_t *head) -{ - return (head->next == head); -} - -static inline void __queue_add(queue_t *new,queue_t *prev,queue_t *next) -{ - next->prev = new; - new->next = next; - new->prev = prev; - prev->next= new; - } - - static inline void queue_add_tail(queue_t *new, queue_t *head) - { - __queue_add(new, head->prev, head); - } - - static inline void __queue_del(queue_t * prev, queue_t * next) - { - next->prev = prev; - prev->next= next; - } - -static inline void __queue_del_entry(queue_t *entry) -{ - __queue_del(entry->prev, entry->next); -} - -static inline void queue_del(queue_t *entry) -{ - __queue_del(entry->prev, entry->next); - entry->next = entry; - entry->prev = entry; -} +void init_queue(queue_t *item); +int queue_empty(queue_t *head); +void __queue_add(queue_t *new,queue_t *prev,queue_t *next); +void queue_add_tail(queue_t *new, queue_t *head); +void __queue_del(queue_t * prev, queue_t * next); +void __queue_del_entry(queue_t *entry); +void queue_del(queue_t *entry); #ifdef __cplusplus diff --git a/driver/utils/misc/sys.c b/driver/utils/misc/sys.c index 5e456c7..e9cfbd4 100644 --- a/driver/utils/misc/sys.c +++ b/driver/utils/misc/sys.c @@ -9,7 +9,10 @@ * Version: * ================================================================= */ - #include "typedef.h" + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + +#include "typedef.h" #include #include #include @@ -87,10 +90,10 @@ int sys_sscanf(const char *buf, const char *fmt, ...) unsigned long long sys_gettimestamp() { - struct timespec ts; + struct timespec64 ts; unsigned long long timestamp; - ktime_get_ts(&ts); + ktime_get_ts64(&ts); timestamp=ts.tv_sec ; timestamp*=1000000000; timestamp+=ts.tv_nsec; @@ -334,17 +337,16 @@ void *sys_fopen(const char *filename, enum sys_fop_flag_e flag) { struct file *fp = NULL; int new_flag = 0; - struct kstat stat; if (!filename) { - printk("Error: NULL pointer"); + pr_err("Error: NULL pointer"); return NULL; } if (flag & ~SYS_FOP_FLAG_BIT_MASK) { - printk("Error: the flag is not supported "); + pr_err("Error: the flag is not supported "); return NULL; } @@ -355,10 +357,6 @@ void *sys_fopen(const char *filename, enum sys_fop_flag_e flag) else if ((flag & SYS_FOP_FLAG_WRITE_BIT)) new_flag = O_WRONLY; - if (0 == vfs_stat(filename, &stat)) - printk("file size:%lld", stat.size); - - fp = filp_open(filename, new_flag, 0); return IS_ERR(fp) ? NULL : fp; @@ -372,22 +370,14 @@ void sys_fclose(void *fp) SIZE_T sys_fread(void *fp, void *buf, SIZE_T size, SIZE_T count, SIZE_T offset) { - mm_segment_t fs; loff_t pos = offset; SIZE_T res; - fs =get_fs(); - set_fs(KERNEL_DS); - -// vfs_read(fp, buf, count, &pos); - res = vfs_read(fp, buf, count, &pos); - if (res > 0) { -// ((struct file*)fp)->f_pos = pos; -// printk("read size:%d", (int)res); + res = kernel_read(fp, buf, count, &pos); + if (res == 0) { + pr_info("kernel read: read zero bytes\n"); } - set_fs(fs); - return res; } diff --git a/driver/utils/pci/pci_model.c b/driver/utils/pci/pci_model.c index 7bb5dc0..d1c44ad 100644 --- a/driver/utils/pci/pci_model.c +++ b/driver/utils/pci/pci_model.c @@ -9,7 +9,9 @@ * Version: * ================================================================= */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include "linux/pci.h" #include "linux/interrupt.h" @@ -129,7 +131,7 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p ERROR_REQUEST_IRQ, }err=NO_ERROR; - printk("pci_model_probe prepare\n"); + pr_info("pci_model_probe prepare\n"); do { if(!pci_model_drv_cxt) @@ -168,11 +170,11 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p if(!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(64))) { - mesg_info("set 64bit DMA mask\n"); + pr_info("set 64bit DMA mask\n"); }else if(!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) { - mesg_info("set 32bit DMA mask\n"); + pr_info("set 32bit DMA mask\n"); }else { @@ -184,7 +186,7 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p { if(!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) { - mesg_info("set 32bit DMA mask\n"); + pr_info("set 32bit DMA mask\n"); }else { @@ -239,10 +241,10 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p bar_info->phys_addr=phys_addr; bar_info->size=size; bar_info->mmio=mmio; - mesg_debug("%s ioremap %08x size %x to %p\n",__func__,phys_addr,size,mmio); + mesg_debug("%s ioremap %08llx size %llx to %p\n",__func__,phys_addr,size,mmio); }else { - mesg_err("%s ioremap %08x size %x error\n",__func__,phys_addr,size); + mesg_err("%s ioremap %08llx size %llx error\n",__func__,phys_addr,size); } pci_cxt->bar_count++; @@ -252,12 +254,12 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p subsystem_id = sub_system; - printk("%s sub_id=%x\n",__func__,sub_system); + pr_info("%s sub_id=%x\n",__func__,sub_system); if(pci_model_drv_cxt->probe_func) { ret=pci_model_drv_cxt->probe_func(dev,driver_data->driver_data); - printk("board_probe=%d\n",ret); + pr_info("board_probe=%d\n",ret); } @@ -265,15 +267,17 @@ static int pci_model_probe(struct pci_dev *pci_dev,const struct pci_device_id *p if(err!=NO_ERROR) { mesg_err("%s error %d\n",__func__,err); - printk("pci_model_probe fail\n"); + pr_err("pci_model_probe fail\n"); switch(err) { case ERROR_REQUEST_REGIONS: pci_clear_master(pci_dev); pci_disable_device(pci_dev); + // fall through case ERROR_ENABLE_PCI_DEV: cxt_manager_unref_context(pci_cxt); pci_cxt=NULL; + // fall through case ERROR_ALLOC_CXT: case NO_CXT_MGR: case NO_DRV_CXT: @@ -597,7 +601,7 @@ void pci_model_register_isr(pci_model_handle_t handle,pci_model_irq_func_t irq_f int pci_model_driver_init(pci_model_driver_setup_t *pcidrv_setup) { int err; - printk("pci_model_driver_init\n"); + pr_info("pci_model_driver_init\n"); if(pci_model_drv_cxt==NULL) { pci_model_drv_cxt=mem_model_alloc_buffer(sizeof(pci_model_driver_cxt_t)); @@ -636,7 +640,7 @@ int pci_model_driver_init(pci_model_driver_setup_t *pcidrv_setup) if(id_setup->device) { id->device=id_setup->device; - printk("id->device=%02x\n",id->device); + pr_info("id->device=%02x\n",id->device); } else id->device=PCI_ANY_ID; @@ -672,11 +676,11 @@ int pci_model_driver_init(pci_model_driver_setup_t *pcidrv_setup) err = pci_register_driver(&pci_model_drv_cxt->driver); if (err ==0) { - printk(">>>pci_register_driver ok\n"); + pr_info(">>>pci_register_driver ok\n"); } else { - printk(">>>pci_register_driver fail\n"); + pr_err(">>>pci_register_driver fail\n"); } //pcidrv_setup->subsystem_id = subsystem_id; diff --git a/driver/utils/thread/include/task_model.h b/driver/utils/thread/include/task_model.h index 3db4e6b..ddbf681 100644 --- a/driver/utils/thread/include/task_model.h +++ b/driver/utils/thread/include/task_model.h @@ -24,7 +24,7 @@ extern "C" { #define TASK_MODEL_CXT_ID fourcc_id('T','A','S','K') - typedef void (*task_work_func_t)(void *data); + typedef void (*task_worker_func_t)(void *data); typedef void (*task_done_callback_func_t)(void *data); typedef void *task_model_handle_t; typedef void *task_handle_t; @@ -33,7 +33,7 @@ extern "C" { task_model_handle_t task_model_init(cxt_mgr_handle_t cxt_mgr); void task_model_stop_task(task_model_handle_t task_model_handle,task_handle_t task_handle); - task_handle_t task_model_create_task(task_model_handle_t task_model_handle,task_work_func_t work_func,void *work_cxt,const char *name); + task_handle_t task_model_create_task(task_model_handle_t task_model_handle,task_worker_func_t work_func,void *work_cxt,const char *name); void task_model_release_task(task_model_handle_t task_model_handle,task_handle_t task_handle); void task_model_run_task(task_model_handle_t task_model_handle,task_handle_t task_handle); void task_model_run_task_after(task_model_handle_t task_model_handle,task_handle_t task_handle,unsigned int us); diff --git a/driver/utils/thread/task_model.c b/driver/utils/thread/task_model.c index adbe55d..5553314 100644 --- a/driver/utils/thread/task_model.c +++ b/driver/utils/thread/task_model.c @@ -14,7 +14,9 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include #include #include @@ -28,7 +30,7 @@ typedef struct { queue_t queue; const char *name; - task_work_func_t work_func; + task_worker_func_t work_func; void *work_cxt; }task_model_task_t; @@ -318,7 +320,7 @@ static void task_model_tasklet_func(unsigned long data) //check atomic_set(&task_model_cxt->need_reschedue_DPC,1); #if 1 //In order to avoid video stop while aging test if(!queue_empty(&task_model_cxt->DPC_queue)) { - printk("interrupt add que Detection\n"); + pr_info("interrupt add que Detection\n"); atomic_set(&task_model_cxt->need_reschedue_DPC,0); tasklet_schedule(&task_model_cxt->tasklet); } @@ -414,7 +416,7 @@ static task_model_task_t *task_model_new_task(task_model_cxt_t *task_model_cxt) -task_handle_t task_model_create_task(task_model_handle_t task_model_handle,task_work_func_t work_func,void *work_cxt,const char *name) +task_handle_t task_model_create_task(task_model_handle_t task_model_handle,task_worker_func_t work_func,void *work_cxt,const char *name) { task_model_task_t *task=NULL; diff --git a/driver/utils/trace/debug.c b/driver/utils/trace/debug.c index 86121f7..8e2a082 100644 --- a/driver/utils/trace/debug.c +++ b/driver/utils/trace/debug.c @@ -14,7 +14,9 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ - + +#define pr_fmt(fmt) KBUILD_MODNAME ": %s, %d: " fmt, __func__, __LINE__ + #include "cxt_mgr.h" #include "trace.h" #include "debug.h" @@ -224,16 +226,23 @@ static unsigned int debug_ctl_store(void *cxt, const char *buf, unsigned int cou { *end=0; end++; - if(start[0]) - kstrtoint(start,10,&lineno); - else - lineno=1; + if(start[0]) { + if (kstrtoint(start, 10, &lineno) != 0) { + lineno = 1; + } + } else { + lineno = 1; + } debug_ctrl.start_line=lineno; - kstrtoint(end,10,&lineno); + if (kstrtoint(end,10,&lineno) != 0) { + lineno = 1; + } debug_ctrl.end_line=lineno; }else { - kstrtoint(start,10,&lineno); + if (kstrtoint(start,10,&lineno) != 0) { + lineno = 1; + } debug_ctrl.start_line=lineno; debug_ctrl.end_line=lineno; } @@ -327,14 +336,24 @@ void uninit_debug() int mesg(const char *fmt,...) { + char *tmp; va_list args; int r; - + + tmp = kzalloc(sizeof (KBUILD_MODNAME ": ") + strlen(fmt), GFP_ATOMIC); + if ( !tmp ) + return -1; + + strcpy(tmp, KBUILD_MODNAME ": "); + strcat(tmp, fmt); + va_start(args, fmt); - r=vprintk(fmt,args); + r= vprintk(tmp,args); va_end(args); - + + kfree(tmp); + return r; } diff --git a/driver/utils/trace/include/debug.h b/driver/utils/trace/include/debug.h index 1036b5f..86bb7c2 100644 --- a/driver/utils/trace/include/debug.h +++ b/driver/utils/trace/include/debug.h @@ -27,29 +27,32 @@ extern "C" { #endif -#define DEBUG 1 + + +#define DEBUG 1 int mesg(const char *fmt,...); + #define mesg_info(fmt, ...) \ - mesg(KERN_INFO fmt, ##__VA_ARGS__) + pr_info(fmt, ##__VA_ARGS__) #define mesg_emerg(fmt, ...) \ - mesg(KERN_EMERG fmt, ##__VA_ARGS__) + pr_emerg(fmt, ##__VA_ARGS__) #define mesg_alert(fmt, ...) \ - mesg(KERN_ALERT fmt, ##__VA_ARGS__) + pr_alert(fmt, ##__VA_ARGS__) #define mesg_crit(fmt, ...) \ - mesg(KERN_CRIT fmt, ##__VA_ARGS__) + pr_crit(fmt, ##__VA_ARGS__) #define mesg_err(fmt, ...) \ - mesg(KERN_ERR fmt, ##__VA_ARGS__) + pr_err(fmt, ##__VA_ARGS__) #define mesg_warning(fmt, ...) \ - mesg(KERN_WARNING fmt, ##__VA_ARGS__) + pr_warning(fmt, ##__VA_ARGS__) #define mesg_notice(fmt, ...) \ - mesg(KERN_NOTICE fmt, ##__VA_ARGS__) + pr_notice(fmt, ##__VA_ARGS__) #if DEBUG #define mesg_debug(fmt, ...) \ debug_msg(KERN_DEBUG fmt, ##__VA_ARGS__) - #else -#define mesg_debug(fmt, ...) +#define mesg_debug(fmt, ...) \ + pr_debug(fmt, ##__VA_ARGS__) #endif typedef enum diff --git a/driver/utils/trace/trace.c b/driver/utils/trace/trace.c index 4e9aa5e..4b5b49e 100644 --- a/driver/utils/trace/trace.c +++ b/driver/utils/trace/trace.c @@ -14,6 +14,8 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ #include #include @@ -156,7 +158,7 @@ void trace_attr_free(trace_attr_handle_t attr_handle) if (attr) { - // printk("%s %s\n",__func__,attr->attr.attr.name); + // pr_info("%s %s\n",__func__,attr->attr.attr.name); if (attr->attr.attr.name) mem_model_free_buffer((void *) attr->attr.attr.name); queue_del(&attr->queue); @@ -171,7 +173,7 @@ static __attribute__((unused)) void trace_free_attr_list(trace_context_t *trace_ for_each_queue_entry_safe(attr, tmp, &trace_cxt->attrs_queue, queue) { - printk("%s %s\n", __func__, attr->attr.attr.name); + pr_info("%s %s\n", __func__, attr->attr.attr.name); queue_del(&attr->queue); //mem_model_free(attr); } @@ -205,12 +207,12 @@ static void trace_update_group(trace_context_t *trace_cxt) i++; } trace_cxt->attrs[i] = NULL; - //printk("%d\n", trace_cxt->attr_count); + //pr_info("%d\n", trace_cxt->attr_count); for (i = 0; i < trace_cxt->attr_count; i++) { if (trace_cxt->attrs[i]) { - //printk("[%d] %s\n", i, trace_cxt->attrs[i]->name); + //pr_info("[%d] %s\n", i, trace_cxt->attrs[i]->name); } } @@ -218,7 +220,7 @@ static void trace_update_group(trace_context_t *trace_cxt) } trace_cxt->attr_group.attrs = trace_cxt->attrs; } - printk("%s done\n", __func__); + pr_info("%s done\n", __func__); } @@ -236,8 +238,6 @@ static void trace_model_release(void *cxt) { trace_context_t *trace_cxt = cxt; - printk("%s\n", __func__); - if (trace_cxt) { uninit_debug(); @@ -341,11 +341,12 @@ void *trace_model_init(void *cxt_mgr) while (0); if (err != NO_ERROR) { - printk("%s err %d\n", __func__, err); + pr_info("%s err %d\n", __func__, err); switch (err) { case ERR_CREATE_GROUP: kobject_put(trace_cxt->kobj); + // fall through case ERR_NO_DEV_KOBJ: cxt_manager_unref_context(trace_cxt); trace_cxt = NULL; diff --git a/driver/utils/v4l2/framegrabber.c b/driver/utils/v4l2/framegrabber.c index 46761c4..653dff9 100644 --- a/driver/utils/v4l2/framegrabber.c +++ b/driver/utils/v4l2/framegrabber.c @@ -9,6 +9,9 @@ * Version: * ================================================================= */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include "typedef.h" #include #include @@ -32,21 +35,24 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "4:2:2, packed, YUYV", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, + .num_planes = 1, .is_yuv = true, .pixfmt_out = YUYV, }, - #if 0 [FRAMEGRABBER_PIXFMT_UYVY]={ //UYVY .name = "4:2:2, packed, UYVY", .fourcc = V4L2_PIX_FMT_UYVY, .depth = 16, + .num_planes = 1, .is_yuv = true, .pixfmt_out = UYVY, }, +#if 0 [FRAMEGRABBER_PIXFMT_YVYU]={ //YVYU .name = "4:2:2, packed, YVYU", .fourcc = V4L2_PIX_FMT_YVYU, .depth = 16, + .num_planes = 1, .is_yuv = true, .pixfmt_out = YVYU, }, @@ -55,6 +61,7 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "4:2:2, packed, VYUY", .fourcc = V4L2_PIX_FMT_VYUY, .depth = 16, + .num_planes = 1, .is_yuv = true, .pixfmt_out = VYUY, }, @@ -63,6 +70,7 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "RGB565 (LE)", .fourcc = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */ .depth = 16, + .num_planes = 1, .is_yuv = false, .pixfmt_out = RGBP, }, @@ -70,6 +78,7 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "RGB565 (BE)", .fourcc = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */ .depth = 16, + .num_planes = 1, .is_yuv = false, .pixfmt_out = RGBR, }, @@ -77,6 +86,7 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "RGB555 (LE)", .fourcc = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */ .depth = 16, + .num_planes = 1, .is_yuv = false, .pixfmt_out = RGBO, }, @@ -84,40 +94,79 @@ static const framegrabber_pixfmt_t support_pixfmts[] = { .name = "RGB555 (BE)", .fourcc = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */ .depth = 16, + .num_planes = 1, .is_yuv = false, .pixfmt_out = RGBQ, }, - #endif [FRAMEGRABBER_PIXFMT_RGB24]={ //RGB3 index=8 .name = "RGB24 (LE)", .fourcc = V4L2_PIX_FMT_RGB24, /* rgb */ .depth = 24, + .num_planes = 1, .is_yuv = false, .pixfmt_out = RGB3, }, - #if 0 - [FRAMEGRABBER_PIXFMT_BGR24]={ //BGR3 - .name = "RGB24 (BE)", - .fourcc = V4L2_PIX_FMT_BGR24, /* bgr */ - .depth = 24, - .is_yuv = false, - .pixfmt_out = BGR3, - }, - [FRAMEGRABBER_PIXFMT_RGB32]={ //RGB4 - .name = "RGB32 (LE)", - .fourcc = V4L2_PIX_FMT_RGB32, /* argb */ - .depth = 32, - .is_yuv = false, - .pixfmt_out = RGB4, - }, - [FRAMEGRABBER_PIXFMT_BGR32]={ //BGR4 +#endif + [FRAMEGRABBER_PIXFMT_BGR24]={ //BGR3 + .name = "RGB24 (BE)", + .fourcc = V4L2_PIX_FMT_BGR24, /* bgr */ + .depth = 24, + .num_planes = 1, + .is_yuv = false, + .pixfmt_out = BGR3, + }, + [FRAMEGRABBER_PIXFMT_RGB32]={ //BA24 + .name = "RGB32 (LE)", + .fourcc = V4L2_PIX_FMT_RGB32, /* argb */ + .depth = 32, + .num_planes = 1, + .is_yuv = false, + .pixfmt_out = BA24, + }, +#if 0 + [FRAMEGRABBER_PIXFMT_BGR32]={ //AR24 .name = "RGB32 (BE)", - .fourcc = V4L2_PIX_FMT_BGR32, /* bgra */ + .fourcc = V4L2_PIX_FMT_ABGR32, /* bgra */ .depth = 32, + .num_planes = 1, .is_yuv = false, - .pixfmt_out = BGR4, + .pixfmt_out = AR24, }, - #endif +#endif +#if 1 //[AVTLD-79]+ + [FRAMEGRABBER_PIXFMT_NV12]={ //NV12 + .name = "NV12", + .fourcc = V4L2_PIX_FMT_NV12, /* NV12M */ + .depth = 12, + .num_planes = 1, + .is_yuv = true, + .pixfmt_out = NV12, + }, + [FRAMEGRABBER_PIXFMT_YV12]={ //YV12 + .name = "YV12", + .fourcc = V4L2_PIX_FMT_YVU420, /* YV12 */ + .depth = 12, + .num_planes = 1, + .is_yuv = true, + .pixfmt_out = YVU420, + }, + [FRAMEGRABBER_PIXFMT_NV12M]={ //NV12 + .name = "NV12M", + .fourcc = V4L2_PIX_FMT_NV12M, /* NV12M */ + .depth = 12, + .num_planes = 2, + .is_yuv = true, + .pixfmt_out = NV12M, + }, + [FRAMEGRABBER_PIXFMT_YV12M]={ //YV12M + .name = "YV12M", + .fourcc = V4L2_PIX_FMT_YVU420M, /* YV12M */ + .depth = 12, + .num_planes = 3, + .is_yuv = true, + .pixfmt_out = YVU420M, + } +#endif //[AVTLD-79]- }; static const framegrabber_frame_size_t framegrabber_support_frame_size[FRAMEGRABBER_SUPPORT_FRAMESIZE_NUM] = { @@ -218,7 +267,7 @@ framegrabber_handle_t framegrabber_init(cxt_mgr_handle_t cxt_mgr,framegrabber_pr { if(fg_cxt->pixfmt_cap & (1<current_out_pixfmt=%d\n",__func__,i); + pr_info("fg_cxt->current_out_pixfmt=%d\n",i); fg_cxt->current_out_pixfmt=i; break; } @@ -358,7 +407,7 @@ void framegrabber_mask_s_status(framegrabber_handle_t handle,framegrabber_status current_status &= ~mask; current_status |= (status & mask); diff=current_status ^ context->current_status; - //printk("%s diff %08x status %08x=>%08x\n",__func__,diff,context->current_status,current_status); + //pr_info("%s diff %08x status %08x=>%08x\n",__func__,diff,context->current_status,current_status); context->current_status=current_status; @@ -370,7 +419,7 @@ void framegrabber_mask_s_status(framegrabber_handle_t handle,framegrabber_status // streaming status changed from STOP to START, so we have to set streaming on if(handle->stream_on) { - printk("%s stream_on\n",__func__); + pr_info("%s stream_on\n",__func__); handle->stream_on(handle); } }else @@ -378,7 +427,7 @@ void framegrabber_mask_s_status(framegrabber_handle_t handle,framegrabber_status // streaming status changed from START to STOP, so we have to set streaming off if(handle->stream_off) { - printk("%s stream_off\n",__func__); + pr_info("%s stream_off\n",__func__); handle->stream_off(handle); } } @@ -391,7 +440,7 @@ void framegrabber_mask_s_status(framegrabber_handle_t handle,framegrabber_status // signal status changed from UNLOCK to LOCK and the current streaming status is START, so we have to set streaming on if(handle->stream_on) { - printk("%s stream_on\n",__func__); + pr_info("%s stream_on\n",__func__); handle->stream_on(handle); } } @@ -403,14 +452,14 @@ void framegrabber_mask_s_status(framegrabber_handle_t handle,framegrabber_status { if(handle->stream_on) { - printk("%s stream_on\n",__func__); + pr_info("%s stream_on\n",__func__); handle->stream_on(handle); } }else { if(handle->stream_off) { - printk("%s stream_off\n",__func__); + pr_info("%s stream_off\n",__func__); handle->stream_off(handle); } } @@ -519,6 +568,134 @@ void framegrabber_s_out_framesize(framegrabber_handle_t handle,int width,int hei context->interface.s_framesize(handle,width,height); } +unsigned framegrabber_g_out_planesize(framegrabber_handle_t handle, int plane) { + framegrabber_context_t *context=framegrabber_getcontext(handle); + const framegrabber_pixfmt_t *pixfmt; + int width, height; + unsigned out_planesize; + + if (!context) + { + pr_err("ERROR: context is NULL"); + return 0; + } + + pixfmt = &support_pixfmts[context->current_out_pixfmt]; + width = context->current_out_framesize.width; + height = context->current_out_framesize.height; + out_planesize=0; + + switch (pixfmt->pixfmt_out) + { + case NV12: + case NV12M: + if (plane == 1) + out_planesize = width * height; + else if (plane == 2) + out_planesize = (width * height) >> 1; + break; + case YVU420: + case YVU420M: //YV12 + if (plane == 1) + out_planesize = width * height; + else if (plane == 2) + out_planesize = ((width >> 1) * (height >> 1)); + else if (plane == 3) + out_planesize = ((width >> 1) * (height >> 1)); + break; + case RGB3: + case BGR3: + if (plane == 1) + out_planesize = width * height * 3; + break; + case AR24: + case BA24: + if (plane == 1) + out_planesize = width * height * 4; + break; + default: + if (plane == 1) + out_planesize = width * height * 2; + break; + } + + return out_planesize; +} + +unsigned framegrabber_g_out_planarbuffersize(framegrabber_handle_t handle, int plane) +{ + framegrabber_context_t *context=framegrabber_getcontext(handle); + const framegrabber_pixfmt_t *pixfmt; + int width, height; + unsigned out_planarbufsize; + + if (!context) + { + pr_err("ERROR: context is NULL"); + return 0; + } + + pixfmt = &support_pixfmts[context->current_out_pixfmt]; + width = context->current_out_framesize.width; + height = context->current_out_framesize.height; + out_planarbufsize=0; + + switch (pixfmt->pixfmt_out) + { + case NV12: + if (plane == 1) + out_planarbufsize = (width * height) + ((width * height) >> 1); +// out_planarbufsize = width * height * 3; + break; + case NV12M: + if (plane == 1) + out_planarbufsize = width * height; + else if (plane == 2) + out_planarbufsize = (width * height) >> 1; + break; + case YVU420: + if (plane == 1 ) + out_planarbufsize = (width * height) + 2*((width >> 1) * (height >> 1)); +// out_planarbufsize = width * height * 3; + break; + case YVU420M: //YV12 + if (plane == 1) + out_planarbufsize = width * height; + else if (plane == 2) + out_planarbufsize = ((width >> 1) * (height >> 1)); + else if (plane == 3) + out_planarbufsize = ((width >> 1) * (height >> 1)); + break; + case RGB3: + case BGR3: + if (plane == 1) + out_planarbufsize = width * height * 3; + break; + case AR24: + case BA24: + if (plane == 1) + out_planarbufsize = width * height * 4; + break; + default: + if (plane == 1) + out_planarbufsize = width * height * 2; + break; + } + + return out_planarbufsize; +} + +unsigned framegrabber_g_out_framebuffersize(framegrabber_handle_t handle) +{ + unsigned out_framebufsize = 0; + + out_framebufsize += framegrabber_g_out_planarbuffersize(handle, 1); + out_framebufsize += framegrabber_g_out_planarbuffersize(handle, 2); + out_framebufsize += framegrabber_g_out_planarbuffersize(handle, 3); + + return out_framebufsize; +} + unsigned framegrabber_g_max_framebuffersize(framegrabber_handle_t handle) { framegrabber_context_t *context=framegrabber_getcontext(handle); @@ -530,30 +707,95 @@ unsigned framegrabber_g_max_framebuffersize(framegrabber_handle_t handle) return max_framebufsize; } -unsigned framegrabber_g_out_bytesperline(framegrabber_handle_t handle) +unsigned framegrabber_g_out_bytesperline(framegrabber_handle_t handle, int plane) { - framegrabber_context_t *context=framegrabber_getcontext(handle); - const framegrabber_pixfmt_t *pixfmt=framegrabber_g_out_pixelfmt(handle); - unsigned bytesperline; + framegrabber_context_t *context=framegrabber_getcontext(handle); + + if (!context) + { + pr_err("ERROR: context is NULL"); + return 0; + } -// if(context->max_supported_width) -// bytesperline=(context->max_supported_width * pixfmt->depth) >> 3; -// else -// { - if(context->current_out_framesize.width) - bytesperline=(context->current_out_framesize.width * pixfmt->depth) >> 3; - else - bytesperline=(context->current_input_framesize.width * pixfmt->depth) >> 3; - //} + int out_bytesperline = 0; + int width; + const framegrabber_pixfmt_t *pixfmt; - return bytesperline; + + if(context->current_out_framesize.width) { + width = context->current_out_framesize.width; + } else { + width = context->current_input_framesize.width; + } + + pixfmt = &support_pixfmts[context->current_out_pixfmt]; + + switch (pixfmt->pixfmt_out) + { + case NV12: + case NV12M: + if (plane == 1) { + out_bytesperline = width; + } + else if (plane == 2) { + out_bytesperline = width; + } + break; + case YVU420: + case YVU420M: //YV12 + if (plane == 1) { + out_bytesperline = width; + } else if (plane == 2) { + out_bytesperline = width/2; + } else if (plane == 3) { + out_bytesperline = width/2; + } + break; + case RGB3: + case BGR3: + if (plane == 1) { + out_bytesperline = width * 3; + } + break; + case AR24: + case BA24: + if (plane == 1) { + out_bytesperline = width * 4; + } + break; + default: + if (plane == 1) { + out_bytesperline = width * 2; + } + break; + } + + return out_bytesperline; } void framegrabber_g_out_framesize(framegrabber_handle_t handle,int *width,int *height) { framegrabber_context_t *context=framegrabber_getcontext(handle); + if (context->current_out_framesize.width == 0 || context->current_out_framesize.height == 0) { + context->current_out_framesize.width = context->current_input_framesize.width; + context->current_out_framesize.height = context->current_input_framesize.height; + + if(context->interface.s_framesize) + context->interface.s_framesize(handle, context->current_out_framesize.width, context->current_out_framesize.height); + } + + if (context->current_out_framesize.width == 0 || context->current_out_framesize.height == 0) { + context->current_out_framesize.width = 1920; + context->current_out_framesize.height = 1080; + + pr_warn("width == 0 or height == 0 => setting width = %d, height = %d\n", context->current_out_framesize.width, context->current_out_framesize.height); + + if(context->interface.s_framesize) + context->interface.s_framesize(handle, context->current_out_framesize.width, context->current_out_framesize.height); + } + *width=context->current_out_framesize.width; *height=context->current_out_framesize.height; @@ -602,14 +844,14 @@ void framegrabber_s_input_dualmode(framegrabber_handle_t handle,int dual_pixel) int framegrabber_g_input_dualmode(framegrabber_handle_t handle) { framegrabber_context_t *context=framegrabber_getcontext(handle); - printk(">>>>>%s ..%d\n",__func__,context->current_dual_pixel); + pr_info(">>>>>%s ..%d\n",__func__,context->current_dual_pixel); return context->current_dual_pixel; } int framegrabber_g_input_framerate(framegrabber_handle_t handle) { framegrabber_context_t *context=framegrabber_getcontext(handle); - //printk(">>>>>%s ..%d\n",__func__,context->current_framerate); + //pr_info(">>>>>%s ..%d\n",__func__,context->current_framerate); return context->current_framerate; } @@ -627,7 +869,7 @@ void framegrabber_s_input_framerate(framegrabber_handle_t handle,int framerate,i context->current_framerate=framerate; context->current_denominator=denominator; - //printk(">>>>>%s ..%d\n",__func__,context->current_framerate); + //pr_info(">>>>>%s ..%d\n",__func__,context->current_framerate); } void framegrabber_s_out_framerate(framegrabber_handle_t handle,int framerate) @@ -636,14 +878,14 @@ void framegrabber_s_out_framerate(framegrabber_handle_t handle,int framerate) context->current_out_framerate=framerate; - //printk(">>>>>>%s ..%d\n",__func__,context->current_out_framerate); + //pr_info(">>>>>>%s ..%d\n",__func__,context->current_out_framerate); } int framegrabber_g_out_framerate(framegrabber_handle_t handle) { framegrabber_context_t *context=framegrabber_getcontext(handle); - //printk(">>>>>>>%s ..%d\n",__func__,context->current_out_framerate); + //pr_info(">>>>>>>%s ..%d\n",__func__,context->current_out_framerate); return context->current_out_framerate; } @@ -654,14 +896,14 @@ void framegrabber_s_input_audioinfo(framegrabber_handle_t handle,enum framegrabb context->current_audioinfo=audioinfo; - //printk(">>>>>%s ..%d\n",__func__,context->current_audioinfo); + //pr_info(">>>>>%s ..%d\n",__func__,context->current_audioinfo); } int framegrabber_g_input_audioinfo(framegrabber_handle_t handle) { framegrabber_context_t *context=framegrabber_getcontext(handle); - //printk(">>>>>>>%s ..%d\n",__func__,context->current_audioinfo); + //pr_info(">>>>>>>%s ..%d\n",__func__,context->current_audioinfo); return context->current_audioinfo; } @@ -674,7 +916,7 @@ int framegrabber_g_input_bchs(framegrabber_handle_t handle,int bchs_select) //context->current_bchs_selection=*bchs_select; - //printk("%s current_bchs_value(%d) = %x\n",__func__,context->current_bchs_selection,context->current_bchs_value); + //pr_info("%s current_bchs_value(%d) = %x\n",__func__,context->current_bchs_selection,context->current_bchs_value); switch (bchs_select) { @@ -682,35 +924,35 @@ int framegrabber_g_input_bchs(framegrabber_handle_t handle,int bchs_select) { handle->brightness_get(handle,&bchs_value); //bchs_value = &handle->fg_bchs_value; - //printk("%s brightness=%d\n",__func__,*bchs_value); + //pr_info("%s brightness=%d\n",__func__,*bchs_value); break; } case 1: //contrast { handle->contrast_get(handle,&bchs_value); //bchs_value = &handle->fg_bchs_value; - //printk("%s contrast=%d\n",__func__,*bchs_value); + //pr_info("%s contrast=%d\n",__func__,*bchs_value); break; } case 2: //hue { handle->hue_get(handle,&bchs_value); //bchs_value = &handle->fg_bchs_value; - //printk("%s hue=%d\n",__func__,*bchs_value); + //pr_info("%s hue=%d\n",__func__,*bchs_value); break; } case 3: //saturation { handle->saturation_get(handle,&bchs_value); //bchs_value = &handle->fg_bchs_value; - //printk("%s saturation=%d\n",__func__,bchs_value); + //pr_info("%s saturation=%d\n",__func__,bchs_value); break; } } //context->current_bchs_value = *bchs_value; - //printk("%s bchs_value(%d) = %d\n",__func__,context->current_bchs_selection,context->current_bchs_value); + //pr_info("%s bchs_value(%d) = %d\n",__func__,context->current_bchs_selection,context->current_bchs_value); return bchs_value; } @@ -731,7 +973,7 @@ void framegrabber_s_input_bchs(framegrabber_handle_t handle,int bchs_value,int b if(handle->bchs_set) handle->bchs_set(handle); - printk("%s current_bchs_value(%d) = %d\n",__func__,bchs_select,context->current_bchs_value); + pr_info("%s current_bchs_value(%d) = %d\n",__func__,bchs_select,context->current_bchs_value); } @@ -743,7 +985,7 @@ int framegrabber_g_hdcp_state(framegrabber_handle_t handle) int state_value=0; handle->hdcp_state_get(handle,&state_value); - printk("%s hdcp state value=%d\n",__func__,state_value); + pr_info("%s hdcp state value=%d\n",__func__,state_value); return state_value; @@ -813,6 +1055,19 @@ int framegrabber_g_supportframesize(framegrabber_handle_t handle,int index,int * return FRAMEGRABBER_ERROR_INVALID_FRAMESIZE; } +int framegrabber_g_support_framesize(framegrabber_handle_t handle,int width,int height) { + int i; + + for(i=0;ihdcp_flag; - //printk("%s hdcp_flag =%u\n",__func__,hdcp_flag); + //pr_info("%s hdcp_flag =%u\n",__func__,hdcp_flag); return hdcp_flag; } @@ -915,7 +1170,7 @@ void framegrabber_s_hdcp_flag(framegrabber_handle_t handle, unsigned int hdcp_fl context->hdcp_flag = hdcp_flag; - //printk("%s hdcp_flag =%u\n",__func__,hdcp_flag); + //pr_info("%s hdcp_flag =%u\n",__func__,hdcp_flag); } int framegrabber_g_i2c(framegrabber_handle_t handle, unsigned char channel, unsigned int slave, unsigned int sub, unsigned char sublen, unsigned char *data, unsigned int datalen, unsigned int is_10bit) @@ -923,13 +1178,13 @@ int framegrabber_g_i2c(framegrabber_handle_t handle, unsigned char channel, unsi framegrabber_context_t *context = framegrabber_getcontext(handle); if(context == NULL) { - printk("param is null!\n"); + pr_info("param is null!\n"); return -1; } if(!context->interface.i2c_read) { - printk("function pointer is null\n"); + pr_info("function pointer is null\n"); return -1; } @@ -941,13 +1196,13 @@ int framegrabber_s_i2c(framegrabber_handle_t handle, unsigned char channel, unsi framegrabber_context_t *context = framegrabber_getcontext(handle); if(context == NULL) { - printk("param is null!\n"); + pr_info("param is null!\n"); return -1; } if(!context->interface.i2c_write) { - printk("function pointer is null\n"); + pr_info("function pointer is null\n"); return -1; } @@ -959,13 +1214,13 @@ int framegrabber_g_reg(framegrabber_handle_t handle, unsigned int offset, unsign framegrabber_context_t *context = framegrabber_getcontext(handle); if(context == NULL) { - printk("param is null!\n"); + pr_info("param is null!\n"); return -1; } if(!context->interface.reg_read) { - printk("function pointer is null\n"); + pr_info("function pointer is null\n"); return -1; } @@ -977,13 +1232,13 @@ int framegrabber_s_reg(framegrabber_handle_t handle, unsigned int offset, unsign framegrabber_context_t *context = framegrabber_getcontext(handle); if(context == NULL) { - printk("param is null!\n"); + pr_info("param is null!\n"); return -1; } if(!context->interface.reg_write) { - printk("function pointer is null\n"); + pr_info("function pointer is null\n"); return -1; } diff --git a/driver/utils/v4l2/include/framegrabber.h b/driver/utils/v4l2/include/framegrabber.h index 7a19329..2c004d2 100644 --- a/driver/utils/v4l2/include/framegrabber.h +++ b/driver/utils/v4l2/include/framegrabber.h @@ -81,42 +81,50 @@ typedef enum typedef enum { FRAMEGRABBER_PIXFMT_YUYV=0, - #if 0 FRAMEGRABBER_PIXFMT_UYVY, +#if 0 FRAMEGRABBER_PIXFMT_YVYU, FRAMEGRABBER_PIXFMT_VYUY, FRAMEGRABBER_PIXFMT_RGB565, FRAMEGRABBER_PIXFMT_RGB565X, FRAMEGRABBER_PIXFMT_RGB555, FRAMEGRABBER_PIXFMT_RGB555X, - #endif FRAMEGRABBER_PIXFMT_RGB24, - #if 0 +#endif FRAMEGRABBER_PIXFMT_BGR24, FRAMEGRABBER_PIXFMT_RGB32, +#if 0 FRAMEGRABBER_PIXFMT_BGR32, - #endif +#endif + FRAMEGRABBER_PIXFMT_NV12, + FRAMEGRABBER_PIXFMT_YV12, + FRAMEGRABBER_PIXFMT_NV12M, + FRAMEGRABBER_PIXFMT_YV12M, FRAMEGRABBER_PIXFMT_MAX, }framegrabber_pixfmt_e; typedef enum { EnumtoBitMask(FRAMEGRABBER_PIXFMT_YUYV), - #if 0 EnumtoBitMask(FRAMEGRABBER_PIXFMT_UYVY), +#if 0 EnumtoBitMask(FRAMEGRABBER_PIXFMT_YVYU), EnumtoBitMask(FRAMEGRABBER_PIXFMT_VYUY), EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB565), EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB565X), EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB555), EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB555X), - #endif EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB24), - #if 0 +#endif EnumtoBitMask(FRAMEGRABBER_PIXFMT_BGR24), - EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB32), - EnumtoBitMask(FRAMEGRABBER_PIXFMT_BGR32), - #endif + EnumtoBitMask(FRAMEGRABBER_PIXFMT_RGB32), +#if 0 + EnumtoBitMask(FRAMEGRABBER_PIXFMT_BGR32), +#endif + EnumtoBitMask(FRAMEGRABBER_PIXFMT_NV12), + EnumtoBitMask(FRAMEGRABBER_PIXFMT_YV12), + EnumtoBitMask(FRAMEGRABBER_PIXFMT_NV12M), + EnumtoBitMask(FRAMEGRABBER_PIXFMT_YV12M), FRAMEGRABBER_PIXFMT_BITMSK = (1< #include @@ -68,34 +71,37 @@ static struct v4l2_file_operations v4l2_model_fops = { static struct v4l2_ioctl_ops v4l2_model_ioctl_ops = { - .vidioc_reqbufs = vb2_ioctl_reqbufs, - .vidioc_create_bufs = vb2_ioctl_create_bufs, - .vidioc_prepare_buf = vb2_ioctl_prepare_buf, - .vidioc_querybuf = vb2_ioctl_querybuf, - .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_streamon = vb2_ioctl_streamon, - .vidioc_streamoff = vb2_ioctl_streamoff, + .vidioc_reqbufs = vb2_ioctl_reqbufs, + .vidioc_create_bufs = vb2_ioctl_create_bufs, + .vidioc_prepare_buf = vb2_ioctl_prepare_buf, + .vidioc_querybuf = vb2_ioctl_querybuf, + .vidioc_qbuf = vb2_ioctl_qbuf, + .vidioc_dqbuf = vb2_ioctl_dqbuf, + .vidioc_streamon = vb2_ioctl_streamon, + .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_querycap = v4l2_model_ioctl_querycap, .vidioc_enum_fmt_vid_cap = v4l2_model_ioctl_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap = v4l2_model_ioctl_g_fmt_vid_cap, - .vidioc_try_fmt_vid_cap = v4l2_model_ioctl_try_fmt_vid_cap, +// .vidioc_g_fmt_vid_cap_mplane = v4l2_model_ioctl_g_fmt_vid_cap_mplane, + .vidioc_try_fmt_vid_cap = v4l2_model_ioctl_try_fmt_vid_cap, +// .vidioc_try_fmt_vid_cap_mplane = v4l2_model_ioctl_try_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_cap = v4l2_model_ioctl_s_fmt_vid_cap, +// .vidioc_s_fmt_vid_cap_mplane = v4l2_model_ioctl_s_fmt_vid_cap_mplane, .vidioc_enum_framesizes = v4l2_model_ioctl_enum_framesizes, .vidioc_enum_input = v4l2_model_ioctl_enum_input, .vidioc_g_input = v4l2_model_ioctl_g_input, .vidioc_s_input = v4l2_model_ioctl_s_input, - .vidioc_enum_frameintervals = v4l2_model_ioctl_enum_frameintervals, + .vidioc_enum_frameintervals = v4l2_model_ioctl_enum_frameintervals, .vidioc_g_parm = v4l2_model_ioctl_g_parm, .vidioc_s_parm = v4l2_model_ioctl_s_parm, .vidioc_g_ctrl = v4l2_model_ioctl_g_ctrl, .vidioc_s_ctrl = v4l2_model_ioctl_s_ctrl, - .vidioc_queryctrl = v4l2_model_ioctl_queryctrl, - //.vidioc_g_edid = v4l2_model_ioctl_g_edid, - //.vidioc_s_edid = v4l2_model_ioctl_s_edid, + .vidioc_queryctrl = v4l2_model_ioctl_queryctrl, + //.vidioc_g_edid = v4l2_model_ioctl_g_edid, + //.vidioc_s_edid = v4l2_model_ioctl_s_edid, - //.vidioc_cropcap = v4l2_model_ioctl_cropcap, + //.vidioc_cropcap = v4l2_model_ioctl_cropcap, //.vidioc_s_dv_timings = v4l2_model_ioctl_s_dv_timings, //.vidioc_g_dv_timings = v4l2_model_ioctl_g_dv_timings, #if 0 @@ -146,7 +152,7 @@ v4l2_model_handle_t v4l2_model_init(cxt_mgr_handle_t cxt_mgr,v4l2_model_device_s switch(context->device_info.type) { case DEVICE_TYPE_GRABBER: - devicetype = VFL_TYPE_GRABBER; + devicetype = VFL_TYPE_VIDEO; break; case DEVICE_TYPE_VBI: devicetype = VFL_TYPE_VBI; @@ -158,7 +164,7 @@ v4l2_model_handle_t v4l2_model_init(cxt_mgr_handle_t cxt_mgr,v4l2_model_device_s devicetype = VFL_TYPE_SUBDEV; break; default: - printk("%s no supported device type 0x%x\n",__func__, context->device_info.type); + pr_info("%s no supported device type 0x%x\n",__func__, context->device_info.type); break; } ret = v4l2_device_register(dev,&context->v4l2_dev); @@ -180,7 +186,10 @@ v4l2_model_handle_t v4l2_model_init(cxt_mgr_handle_t cxt_mgr,v4l2_model_device_s context->pic_bmp_handle = cxt_manager_get_context(cxt_mgr, PCI_BMP_CXT_ID, 0); vdev = &context->vdev; - vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; +#if LINUX_VERSION_CODE > KERNEL_VERSION(4,18,0) +// vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_READWRITE; + vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; +#endif vdev->release = video_device_release_empty; vdev->v4l2_dev = &context->v4l2_dev; vdev->vfl_dir = VFL_DIR_RX; @@ -210,10 +219,13 @@ v4l2_model_handle_t v4l2_model_init(cxt_mgr_handle_t cxt_mgr,v4l2_model_device_s { case V4L2_MODEL_ERROR_REGISTER_VIDEO: v4l2_model_vb2_release(context->vb2_context); + // fall through case V4L2_MODEL_ERROR_VIDEO_BUF: v4l2_device_unregister(&context->v4l2_dev); + // fall through case V4L2_MODEL_ERROR_REGISTER_V4L2: kfree(context); + // fall through case V4L2_MODEL_ERROR_ALLOC: case V4L2_MODEL_ERROR_NO_DEV: break; @@ -249,7 +261,7 @@ static void v4l2_model_release(v4l2_model_handle_t context) if(!v4l2m_context) { return; } - printk("%s\n", __func__); + pr_info("%s\n", __func__); #if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0) for(i=0;iAVER_FLASH_IOCTL_FW_UPDATE\n"); + pr_info("----->AVER_FLASH_IOCTL_FW_UPDATE\n"); ret = v4l2_model_ioctl_s_flash(file,(struct v4l2_dump_flash *)arg); break; case AVER_HDCP_IOCTL_GET_STATE: - printk("AVER_HDCP_IOCTL_GET_STATE\n"); + pr_info("AVER_HDCP_IOCTL_GET_STATE\n"); ret = v4l2_model_ioctl_g_hdcp_state(file, &hdcp_state); - copy_to_user ((unsigned int *)arg, &hdcp_state, sizeof(hdcp_state)); + if (copy_to_user ((unsigned int *)arg, &hdcp_state, sizeof(hdcp_state)) != 0) { + pr_err("AVER_HDCP_IOCTL_GET_STATE copy_to_user() failed\n"); + } break; case AVER_HDCP_IOCTL_SET_STATE: - //printk("hdcp:%x \n", arg); + //pr_info("hdcp:%x \n", arg); //copy_from_user (&hdcp_state,(unsigned int *) arg, sizeof(hdcp_state)); hdcp_state = arg; - printk("----->AVER_HDCP_IOCTL_SET_STATE:%ld \n", arg); + pr_info("----->AVER_HDCP_IOCTL_SET_STATE:%ld \n", arg); ret = v4l2_model_ioctl_s_hdcp_state(file,&hdcp_state); break; case AVER_GET_I2C: - //printk("----->AVER_GET_I2C\n"); + //pr_info("----->AVER_GET_I2C\n"); ret = v4l2_model_ioctl_g_i2c(file, (struct i2c_t *) arg); if (ret) { - printk("AVER_GET_I2C failed...\n"); + pr_info("AVER_GET_I2C failed...\n"); } break; case AVER_SET_I2C: - //printk("----->AVER_SET_I2C\n"); + //pr_info("----->AVER_SET_I2C\n"); ret = v4l2_model_ioctl_s_i2c(file, (struct i2c_t *) arg); if (ret) { - printk("AVER_SET_I2C failed...\n"); + pr_info("AVER_SET_I2C failed...\n"); } break; case AVER_GET_REG: - //printk("----->AVER_GET_REG\n"); + //pr_info("----->AVER_GET_REG\n"); ret = v4l2_model_ioctl_g_reg(file, (struct reg_t *) arg); if (ret) { - printk("AVER_GET_REG failed...\n"); + pr_info("AVER_GET_REG failed...\n"); } break; case AVER_SET_REG: - //printk("----->AVER_SET_REG\n"); + //pr_info("----->AVER_SET_REG\n"); ret = v4l2_model_ioctl_s_reg(file, (struct reg_t *) arg); if (ret) { - printk("AVER_SET_REG failed...\n"); + pr_info("AVER_SET_REG failed...\n"); } break; @@ -621,9 +635,9 @@ static void v4l2_model_notify(struct v4l2_subdev *sd,unsigned int notification, { v4l2_model_context_t *v4l2m_context=container_of(sd->v4l2_dev,v4l2_model_context_t,v4l2_dev); - printk("%s sd name %s owner %s\n",__func__,sd->name,sd->owner->name); + pr_info("%s sd name %s owner %s\n",__func__,sd->name,sd->owner->name); framegrabber_notify(v4l2m_context->framegrabber_handle,sd->name,notification, arg); -// printk("%s %s notification %d \n",__func__,sd->name,notification); +// pr_info("%s %s notification %d \n",__func__,sd->name,notification); // if(notification==2) // { // struct v4l2_dv_timings detected_timings; @@ -631,8 +645,8 @@ static void v4l2_model_notify(struct v4l2_subdev *sd,unsigned int notification, // int status; // v4l2_subdev_call(sd,video, query_dv_timings, &detected_timings); // v4l2_subdev_call(sd,video, g_input_status, &status); -// printk("%s input status %x\n",__func__,status); -// printk("%s detected %dx%d%c\n", __func__,detected_timings.bt.width, detected_timings.bt.height,detected_timings.bt.interlaced == V4L2_DV_INTERLACED ? 'i' : 'p'); +// pr_info("%s input status %x\n",__func__,status); +// pr_info("%s detected %dx%d%c\n", __func__,detected_timings.bt.width, detected_timings.bt.height,detected_timings.bt.interlaced == V4L2_DV_INTERLACED ? 'i' : 'p'); // v4l2_subdev_call(sd,video, s_dv_timings, &detected_timings); // // diff --git a/driver/utils/v4l2/v4l2_model_device.h b/driver/utils/v4l2/v4l2_model_device.h index 02489c6..b10e647 100644 --- a/driver/utils/v4l2/v4l2_model_device.h +++ b/driver/utils/v4l2/v4l2_model_device.h @@ -95,7 +95,7 @@ typedef struct v4l2_model_context_s -#define V4L2_MODEL_DEBUG(fmt, ...) //printk(fmt, ##__VA_ARGS__) +#define V4L2_MODEL_DEBUG(fmt, ...) //pr_info(fmt, ##__VA_ARGS__) #endif /* V4L2_MODEL_DEVICE_H_ */ diff --git a/driver/utils/v4l2/v4l2_model_ioctl.c b/driver/utils/v4l2/v4l2_model_ioctl.c index 260761b..197692b 100644 --- a/driver/utils/v4l2/v4l2_model_ioctl.c +++ b/driver/utils/v4l2/v4l2_model_ioctl.c @@ -9,7 +9,11 @@ * Version: * ================================================================= */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include "typedef.h" +#include #include #include #include @@ -31,7 +35,7 @@ // defaults for ADV7619 #define BrightnessDefault 0x200 #define ContrastDefault 0x100 -#define SaturationDefault 0x100 +#define SaturationDefault 0x80 #define HueDefault 0x00 //static U32_T SharpnessDefault = 0x00; @@ -45,10 +49,10 @@ #define MAX_VAMP_CONTRAST_UNITS 0x1ff #define MIN_VAMP_SATURATION_UNITS 0 -#define MAX_VAMP_SATURATION_UNITS 360 +#define MAX_VAMP_SATURATION_UNITS 0x1ff #define MIN_VAMP_HUE_UNITS 0 -#define MAX_VAMP_HUE_UNITS 0x1ff +#define MAX_VAMP_HUE_UNITS 360 int brightness_tmp=0; @@ -71,9 +75,9 @@ enum v4l2_bchs_type { V4L2_BCHS_TYPE_SATURATION, }; -static struct v4l2_queryctrl g_cx511h_ctrls[] = +static struct v4l2_queryctrl g_gc573_ctrls[] = { - #if 0 + #if 1 { V4L2_CID_BRIGHTNESS, //id V4L2_CTRL_TYPE_INTEGER, //type @@ -148,15 +152,15 @@ static struct v4l2_queryctrl g_cx511h_ctrls[] = #endif }; -#define ARRAY_SIZE_OF_CTRL (sizeof(g_cx511h_ctrls)/sizeof(g_cx511h_ctrls[0])) +#define ARRAY_SIZE_OF_CTRL (sizeof(g_gc573_ctrls)/sizeof(g_gc573_ctrls[0])) static struct v4l2_queryctrl *find_ctrl(unsigned int id) { int i; //scan supported queryctrl table for( i=0; icard, v4l2m_context->device_info.card_name,sizeof(cap->card)); - sprintf(cap->bus_info, "%s", dev_name(v4l2m_context->dev)); + sprintf(cap->bus_info, "PCIe:%s", dev_name(v4l2m_context->dev)); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,18,0) if(v4l2m_context->device_info.capabilities) { - //cap->device_caps = v4l2_model_to_v4l2_caps(v4l2m_context->device_info.capabilities) ; + cap->device_caps = v4l2_model_to_v4l2_caps(v4l2m_context->device_info.capabilities) ; } - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; +#else +// cap->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING; + cap->device_caps = v4l2m_context->vdev.device_caps; +#endif cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; } return 0; @@ -246,164 +254,405 @@ int v4l2_model_ioctl_querycap(struct file *file, void *fh, struct v4l2_capabilit int v4l2_model_ioctl_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { - v4l2_model_context_t *v4l2m_context = video_drvdata(file); - U32_T index = f->index; + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + U32_T index = f->index; - //printk("%s...\n",__func__); - if(f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) - { - printk("%s.\n",__func__); - return -EINVAL; - } + if(f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + { + pr_err("ENUM_FMT with invalid type: %d\n", f->type); + return -EINVAL; + } - if(v4l2m_context) - { - const framegrabber_pixfmt_t *pixfmt; - if(f->index <0) - { - return -EINVAL; - } - if(f->index >= FRAMEGRABBER_PIXFMT_MAX) - { - return -EINVAL; - } - else - { - pixfmt=framegrabber_g_support_pixelfmt_by_index(v4l2m_context->framegrabber_handle,f->index); - //printk("%s..pixfmt=%d.\n",__func__,f->index); - f->index = index; - f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - strlcpy(f->description, pixfmt->name, sizeof(f->description)); - f->pixelformat=pixfmt->fourcc; - } - - - if(pixfmt==NULL) - return -EINVAL; - //printk("%s....pixfmt=%d.\n",__func__,f->index); - strlcpy(f->description, pixfmt->name, sizeof(f->description)); - f->pixelformat=pixfmt->fourcc; - } + if(v4l2m_context) + { + const framegrabber_pixfmt_t *pixfmt; + + if(f->index <0) + { + return -EINVAL; + } + + if(f->index >= FRAMEGRABBER_PIXFMT_MAX) + { + return -EINVAL; + } + + pixfmt=framegrabber_g_support_pixelfmt_by_index(v4l2m_context->framegrabber_handle,f->index); + + if(pixfmt==NULL) + return -EINVAL; + + if ((pixfmt->num_planes > 1) && (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)) { + return -EINVAL; + } + + pr_info("%s pixfmt=%d\n", pixfmt->name, f->index); + f->index = index; + + strlcpy(f->description, pixfmt->name, sizeof(f->description)); + f->pixelformat=pixfmt->fourcc; + } + + return 0; - return 0; - } int v4l2_model_ioctl_g_fmt_vid_cap(struct file *file, void *fh,struct v4l2_format *f) { - v4l2_model_context_t *v4l2m_context = video_drvdata(file); - const framegrabber_pixfmt_t *pixfmt; - BOOL_T interlace_mode; + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + const framegrabber_pixfmt_t *pixfmt; + BOOL_T interlace_mode; - pixfmt=framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); - interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); - if(pixfmt) - { - int width,height; - //unsigned bytesperline; - //printk("%s...\n",__func__); - framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle,&width,&height); - //bytesperline=framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle); - //printk("%s..f->fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); - - f->fmt.pix.width=width; - f->fmt.pix.height=height; - f->fmt.pix.field=V4L2_FIELD_NONE; //Field - f->fmt.pix.pixelformat = pixfmt->fourcc; - - //f->fmt.pix.bytesperline = bytesperline; - f->fmt.pix.bytesperline = (f->fmt.pix.width * pixfmt->depth) >> 3; - f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; - if (pixfmt->is_yuv) - f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; - else - f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { + pr_err("G_FMT with invalid type: %d\n", f->type); + return -EINVAL; + } - - if (interlace_mode) + interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); + pixfmt=framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + + if (!pixfmt || pixfmt->num_planes > 1) { + pr_err("numplanes > 1 while type is single planar\n"); + pixfmt = framegrabber_g_support_pixelfmt_by_index(v4l2m_context->framegrabber_handle,0); + framegrabber_s_out_pixelfmt(v4l2m_context->framegrabber_handle, pixfmt->fourcc); + } + + if(pixfmt) + { + int width,height; + unsigned bytesperline; + unsigned sizeimage; + + framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); + + if(framegrabber_g_support_framesize(v4l2m_context->framegrabber_handle, width, height) != FRAMEGRABBER_OK) { + + framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle, &width, &height); + + if (width == 0 || height == 0) { + width = 1920; + height = 1080; + } + pr_warn("no correct output framesize defined, using %dx%d\n", width, height); + framegrabber_s_out_framesize(v4l2m_context->framegrabber_handle, width, height); + } + + bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, 1); + sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + + pr_info("pixelformat = %s bytesperline = %d and sizeimage = %d\n", pixfmt->name, bytesperline, sizeimage); + + f->fmt.pix.width = width; + f->fmt.pix.height = height; + f->fmt.pix.field = V4L2_FIELD_NONE; //Field + f->fmt.pix.pixelformat = pixfmt->fourcc; + + f->fmt.pix.bytesperline = bytesperline; + f->fmt.pix.sizeimage = sizeimage; + if (pixfmt->is_yuv) { + f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } else { + f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } + + if (interlace_mode) { + //f->fmt.pix.height = height*2; + f->fmt.pix.field = V4L2_FIELD_INTERLACED; + } + + //pr_info("%s....f->fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); + return 0; + } + + return -EINVAL; +} + +int v4l2_model_ioctl_g_fmt_vid_cap_mplane(struct file *file, void *fh,struct v4l2_format *f) { + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + const framegrabber_pixfmt_t *pixfmt; + BOOL_T interlace_mode; + + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + pr_err("G_FMT with invalid type: %d\n", f->type); + return -EINVAL; + } + + interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); + + pixfmt=framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + if (!pixfmt) { + pr_warn("no output pixelformat defined\n"); + pixfmt = framegrabber_g_support_pixelfmt_by_index(v4l2m_context->framegrabber_handle,0); + framegrabber_s_out_pixelfmt(v4l2m_context->framegrabber_handle, pixfmt->fourcc); + } + + if(pixfmt) { + int width, height; + int i; + + framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); + + if(framegrabber_g_support_framesize(v4l2m_context->framegrabber_handle, width, height) != FRAMEGRABBER_OK) { + + framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle, &width, &height); + + if (width == 0 || height == 0) { + width = 1920; + height = 1080; + } + pr_warn("no correct output framesize defined, using %dx%d\n", width, height); + framegrabber_s_out_framesize(v4l2m_context->framegrabber_handle, width, height); + } + + if (pixfmt->num_planes == 1) { + f->fmt.pix.bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, 1); + f->fmt.pix.sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + + if (pixfmt->is_yuv) { + f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } else { + f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } + + if (interlace_mode) { + //f->fmt.pix.height = height*2; + f->fmt.pix.field = V4L2_FIELD_INTERLACED; + } else { + f->fmt.pix.field = V4L2_FIELD_NONE; + } + + f->fmt.pix.priv = 0; + } + + pr_info("pixelformat %s on %d planes with size %dx%d\n", pixfmt->name, pixfmt->num_planes, width, height); + + f->fmt.pix_mp.num_planes = pixfmt->num_planes; + f->fmt.pix_mp.width = width; + f->fmt.pix_mp.height = height; + f->fmt.pix_mp.field = V4L2_FIELD_NONE; //Field + f->fmt.pix_mp.pixelformat = pixfmt->fourcc; + + if (pixfmt->is_yuv) { + f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_709; + f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_709; + } else { + f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_SRGB; + f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_BT2020; + } + + if (interlace_mode) { - //f->fmt.pix.height = height*2; - f->fmt.pix.field=V4L2_FIELD_INTERLACED; - } - //printk("%s....f->fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); - return 0; - } + //f->fmt.pix.height = height*2; + f->fmt.pix_mp.field=V4L2_FIELD_INTERLACED; + } + + for (i=0; i < pixfmt->num_planes; i++) { + f->fmt.pix_mp.plane_fmt[i].bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, i+1); + f->fmt.pix_mp.plane_fmt[i].sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, i+1); + + pr_info("plane[%d]: set bytesperline %d and sizeimage %d\n", i, f->fmt.pix_mp.plane_fmt[i].bytesperline, f->fmt.pix_mp.plane_fmt[i].sizeimage); + } - return -EINVAL; + return 0; + } + + return -EINVAL; } + int v4l2_model_ioctl_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) { - v4l2_model_context_t *v4l2m_context = video_drvdata(file); - const framegrabber_pixfmt_t *fmt; - int width,height; - BOOL_T interlace_mode; - //printk("%s>>f->fmt.pix.width=%d.f->fmt.pix.height=%d.f->fmt.pix.pixelformat=%d\n",__func__,f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.pixelformat); - fmt = framegrabber_g_support_pixelfmt_by_fourcc(v4l2m_context->framegrabber_handle, f->fmt.pix.pixelformat); - - framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle,&width,&height); - - interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); - - if(!fmt) + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + const framegrabber_pixfmt_t *pixfmt; + BOOL_T interlace_mode; + + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { + pr_err("TRY_FMT with invalid type: %d\n", f->type); + return -EINVAL; + } + + //pr_info("%s>>f->fmt.pix.width=%d.f->fmt.pix.height=%d.f->fmt.pix.pixelformat=%d\n",__func__,f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.pixelformat); + pixfmt = framegrabber_g_support_pixelfmt_by_fourcc(v4l2m_context->framegrabber_handle, f->fmt.pix.pixelformat); + if(!pixfmt || pixfmt->num_planes > 1) { - printk("%s..\n",__func__); - return 0; - } + pr_warn("fmt is not valid\n"); + pixfmt = framegrabber_g_support_pixelfmt_by_index(v4l2m_context->framegrabber_handle,0); - //if(width!=0 && height!=0) - { - if ((f->fmt.pix.width <320) || (f->fmt.pix.width >4096) || (f->fmt.pix.height <240) || (f->fmt.pix.height >2160)) - { - if (interlace_mode) - { - f->fmt.pix.width=width; - //f->fmt.pix.height=height*2; - f->fmt.pix.field =V4L2_FIELD_INTERLACED; //field order - //printk("%s>f->fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); - } - else - { - f->fmt.pix.width=width; - f->fmt.pix.height=height; - f->fmt.pix.field = V4L2_FIELD_NONE; - } - } - else - { - if ((f->fmt.pix.height == height) && interlace_mode) - { - //f->fmt.pix.height=height*2; - f->fmt.pix.field =V4L2_FIELD_INTERLACED; - //printk("%s f->fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); - } - else - { - f->fmt.pix.field = V4L2_FIELD_NONE; - } - } - } - if ((f->fmt.pix.width ==0) || (f->fmt.pix.height ==0)) - { - f->fmt.pix.width = 1920; - f->fmt.pix.height = 1080; - } - - - f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; - f->fmt.pix.sizeimage =f->fmt.pix.height * f->fmt.pix.bytesperline; - - if (fmt!=NULL && fmt->is_yuv) - f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709;//V4L2_COLORSPACE_SMPTE170M; - else - f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix.pixelformat = pixfmt->fourcc; + } - f->fmt.pix.priv = 0; - - //printk("%s<fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); - return 0; + interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); + + if(framegrabber_g_support_framesize(v4l2m_context->framegrabber_handle, f->fmt.pix.width, f->fmt.pix.height) != FRAMEGRABBER_OK) { + int width, height; + + pr_warn("framesize %dx%d is not supported\n", f->fmt.pix.width, f->fmt.pix.height); + + framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle, &width, &height); + + if (width == 0 || height == 0) { + width = 1920; + height = 1080; + } + + f->fmt.pix.width = width; + f->fmt.pix.height = height; + } + + unsigned bytesperline; + unsigned sizeimage; + + bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, 1); + sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + + f->fmt.pix.bytesperline = bytesperline; + f->fmt.pix.sizeimage = sizeimage; + + if (pixfmt->is_yuv) { + f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } else { + f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } + + if (interlace_mode) + { + //f->fmt.pix.height = height*2; + f->fmt.pix.field=V4L2_FIELD_INTERLACED; + } else { + f->fmt.pix.field = V4L2_FIELD_NONE; + } + + f->fmt.pix.priv = 0; + + //pr_info("%s<fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); + return 0; +} + +int v4l2_model_ioctl_try_fmt_vid_cap_mplane(struct file *file, void *fh, struct v4l2_format *f) +{ + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + const framegrabber_pixfmt_t *pixfmt; + BOOL_T interlace_mode; + int i; + + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + pr_err("TRY_FMT with invalid type: %d\n", f->type); + return -EINVAL; + } + + pixfmt = framegrabber_g_support_pixelfmt_by_fourcc(v4l2m_context->framegrabber_handle, f->fmt.pix_mp.pixelformat); + if(!pixfmt) + { + pr_warn("fmt is not valid\n"); + pixfmt = framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + + f->fmt.pix_mp.pixelformat = pixfmt->fourcc; + } + + if (f->fmt.pix_mp.num_planes != pixfmt->num_planes) { + pr_warn("wrong number of planes %d\n", f->fmt.pix_mp.num_planes); + f->fmt.pix_mp.num_planes = pixfmt->num_planes; + } + + interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); + + if(framegrabber_g_support_framesize(v4l2m_context->framegrabber_handle, f->fmt.pix_mp.width, f->fmt.pix_mp.height) != FRAMEGRABBER_OK) { + int width,height; + + pr_warn("framesize %dx%d is not supported\n", f->fmt.pix_mp.width, f->fmt.pix_mp.height); + framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle,&width,&height); + + if (width == 0 || height == 0) { + width = 1920; + height = 1080; + } + + if (pixfmt->num_planes == 1) { + f->fmt.pix.width=width; + f->fmt.pix.height=height; + } + + f->fmt.pix_mp.width=width; + f->fmt.pix_mp.height=height; + } + + if (pixfmt->num_planes == 1) { + f->fmt.pix.bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, 1); + f->fmt.pix.sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + + if (pixfmt->is_yuv) { + f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } else { + f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix.quantization = V4L2_QUANTIZATION_DEFAULT; + } + + if (interlace_mode) { + //f->fmt.pix.height = height*2; + f->fmt.pix.field = V4L2_FIELD_INTERLACED; + } else { + f->fmt.pix.field = V4L2_FIELD_NONE; + } + + f->fmt.pix.priv = 0; + } + + f->fmt.pix_mp.num_planes = pixfmt->num_planes; + f->fmt.pix_mp.field = V4L2_FIELD_NONE; //Field + f->fmt.pix_mp.pixelformat = pixfmt->fourcc; + + if (pixfmt->is_yuv) { + f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_REC709; + f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT; + } else { + f->fmt.pix_mp.colorspace = V4L2_COLORSPACE_SRGB; + f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT; + f->fmt.pix_mp.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; + f->fmt.pix_mp.quantization = V4L2_QUANTIZATION_DEFAULT; + } + + if (interlace_mode) + { + //f->fmt.pix.height = height*2; + f->fmt.pix_mp.field=V4L2_FIELD_INTERLACED; + } + + for (i=0; i < pixfmt->num_planes; i++) { + f->fmt.pix_mp.plane_fmt[i].bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, i+1); + f->fmt.pix_mp.plane_fmt[i].sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, i+1); + } + + //pr_info("%s<fmt.pix.width=%d.f->fmt.pix.height=%d.\n",__func__,f->fmt.pix.width,f->fmt.pix.height); + return 0; } int v4l2_model_ioctl_s_fmt_vid_cap(struct file *file, void *fh,struct v4l2_format *f) @@ -414,32 +663,50 @@ int v4l2_model_ioctl_s_fmt_vid_cap(struct file *file, void *fh,struct v4l2_forma int ret = v4l2_model_ioctl_try_fmt_vid_cap(file, fh, f); if (ret < 0) { - printk("%s..\n",__func__); + pr_err("try_vid_cap failed\n"); return ret; } if (vb2_is_busy(&v4l2m_context->queue)) { - printk("%s.\n",__func__); + pr_warn("vb2 is busy\n"); return -EBUSY; } - /* TODO check setting format is supported */ - - //printk("%s...\n",__func__); - - if(framegrabber_g_support_pixelfmt_by_fourcc(v4l2m_context->framegrabber_handle,f->fmt.pix.pixelformat)==NULL) - { - printk("..%s..\n",__func__); - return -EINVAL; - } - if(f->fmt.pix.width==0 || f->fmt.pix.height==0) - { - printk("..%s.\n",__func__); - return -EINVAL; - } - //printk("%s.f->fmt.pix.width=%d..f->fmt.pix.height=%d\n",__func__,f->fmt.pix.width,f->fmt.pix.height); + pr_info("f->fmt.pix.width=%d..f->fmt.pix.height=%d..f->fmt.pix.pixelformat=%d\n",f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.pixelformat); framegrabber_s_out_framesize(v4l2m_context->framegrabber_handle,f->fmt.pix.width,f->fmt.pix.height); - framegrabber_s_out_pixelfmt(v4l2m_context->framegrabber_handle,f->fmt.pix.pixelformat); + framegrabber_s_out_pixelfmt(v4l2m_context->framegrabber_handle,f->fmt.pix.pixelformat); + + unsigned bytesperline = framegrabber_g_out_bytesperline(v4l2m_context->framegrabber_handle, 1); + unsigned sizeimage = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + + f->fmt.pix.bytesperline = bytesperline; + f->fmt.pix.sizeimage = sizeimage; + + pr_info("bytesperline = %d and sizeimage = %d\n", bytesperline, sizeimage); + + return 0; +} + +int v4l2_model_ioctl_s_fmt_vid_cap_mplane(struct file *file, void *fh,struct v4l2_format *f) +{ + + v4l2_model_context_t *v4l2m_context = video_drvdata(file); + + int ret = v4l2_model_ioctl_try_fmt_vid_cap_mplane(file, fh, f); + if (ret < 0) + { + pr_err("try_vid_cap failed\n"); + return ret; + } + + if (vb2_is_busy(&v4l2m_context->queue)) { + pr_info("%s.\n",__func__); + return -EBUSY; + } + + pr_info("f->fmt.pix_mp.width=%d..f->fmt.pix_mp.height=%d pixelformat=%d\n",f->fmt.pix.width,f->fmt.pix.height, f->fmt.pix_mp.pixelformat); + framegrabber_s_out_framesize(v4l2m_context->framegrabber_handle,f->fmt.pix_mp.width,f->fmt.pix_mp.height); + framegrabber_s_out_pixelfmt(v4l2m_context->framegrabber_handle,f->fmt.pix_mp.pixelformat); return 0; } @@ -450,26 +717,24 @@ int v4l2_model_ioctl_enum_framesizes(struct file *file, void *fh, struct v4l2_fr const framegrabber_pixfmt_t *pixfmt; int width=0,height=0; - //printk("%s...\n",__func__); + pixfmt=framegrabber_g_support_pixelfmt_by_fourcc(v4l2m_context->framegrabber_handle,fsize->pixel_format); - //printk("%s %08x %p\n",__func__,fsize->pixel_format,pixfmt); + //pr_info("%s %08x %p\n",__func__,fsize->pixel_format,pixfmt); if(pixfmt==NULL) { - printk("%s..\n",__func__); + pr_info("%s..\n",__func__); return -EINVAL; } - else - { - //printk("%s %08x %x\n",__func__,fsize->pixel_format,pixfmt->fourcc); - } + + //pr_info("%s %08x %x\n",__func__,fsize->pixel_format,pixfmt->fourcc); if(framegrabber_g_supportframesize(v4l2m_context->framegrabber_handle,fsize->index,&width,&height)!=FRAMEGRABBER_OK) { - //printk("%s. invalid framesize\n",__func__); + //pr_info("%s. invalid framesize\n",__func__); return -EINVAL; } - //printk("%s...supportframesize width=%d height=%d..\n",__func__,width,height); //12 + //pr_info("%s...supportframesize width=%d height=%d..\n",__func__,width,height); //12 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; fsize->pixel_format=pixfmt->fourcc; fsize->discrete.width=width; @@ -481,7 +746,7 @@ int v4l2_model_ioctl_enum_framesizes(struct file *file, void *fh, struct v4l2_fr int v4l2_model_ioctl_enum_input(struct file *file, void *fh, struct v4l2_input *inp) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); - printk("%s...\n",__func__); + if (inp->index >= framegrabber_g_input_num(v4l2m_context->framegrabber_handle)) return -EINVAL; inp->type = V4L2_INPUT_TYPE_CAMERA; @@ -491,14 +756,14 @@ int v4l2_model_ioctl_enum_input(struct file *file, void *fh, struct v4l2_input * if(inp->index==framegrabber_g_input(v4l2m_context->framegrabber_handle)) { u32 input_status=framegrabber_g_input_status(v4l2m_context->framegrabber_handle); - //printk("%s..\n",__func__); + //pr_info("%s..\n",__func__); if(input_status == FRAMEGRABBER_INPUT_STATUS_OK) { - //printk("%s.FRAMEGRABBER_INPUT_STATUS_OK\n",__func__); + //pr_info("%s.FRAMEGRABBER_INPUT_STATUS_OK\n",__func__); inp->status=0; }else { - //printk("..%s..\n",__func__); + //pr_info("..%s..\n",__func__); if(input_status & FRAMEGRABBER_INPUT_STATUS_NO_POWER) inp->status |= V4L2_IN_ST_NO_POWER; @@ -510,7 +775,7 @@ int v4l2_model_ioctl_enum_input(struct file *file, void *fh, struct v4l2_input * } }else { - //printk("..%s.\n",__func__); + //pr_info("..%s.\n",__func__); inp->status |= V4L2_IN_ST_NO_POWER; } @@ -521,17 +786,17 @@ int v4l2_model_ioctl_g_input(struct file *file, void *fh, unsigned int *i) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); *i=framegrabber_g_input(v4l2m_context->framegrabber_handle); - //printk("%s..input=%d.\n",__func__,*i); + //pr_info("%s..input=%d.\n",__func__,*i); return 0; } int v4l2_model_ioctl_s_input(struct file *file, void *fh, unsigned int i) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); - //printk("%s...\n",__func__); + if(i < 0 || i > framegrabber_g_input_num(v4l2m_context->framegrabber_handle)) { - printk("..%s..\n",__func__); + pr_info("..%s..\n",__func__); return -EINVAL; } @@ -542,103 +807,102 @@ int v4l2_model_ioctl_s_input(struct file *file, void *fh, unsigned int i) int v4l2_model_ioctl_enum_frameintervals(struct file *file, void *fh, struct v4l2_frmivalenum *fival) { - int frameinterval=0; - v4l2_model_context_t *v4l2m_context = video_drvdata(file); + int fivaldenominator=0; + int fivalnumerator = 1; + v4l2_model_context_t *v4l2m_context = video_drvdata(file); BOOL_T interlace_mode; - - interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); - //printk("%s...\n",__func__); - frameinterval=framegrabber_g_framesize_supportrefreshrate(v4l2m_context->framegrabber_handle,fival->width,fival->height,fival->index); - if(frameinterval) - { - //printk("%s..\n",__func__); - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator=1; - fival->discrete.denominator=frameinterval; - }else - { - //printk("%s.\n",__func__); - if(fival->index==0) - { - //frameinterval = framegrabber_g_out_framerate(v4l2m_context->framegrabber_handle); - //if (frameinterval ==0) - { - frameinterval=framegrabber_g_input_framerate(v4l2m_context->framegrabber_handle); - } - fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; - fival->discrete.numerator=1; - //fival->discrete.numerator=1000; - fival->discrete.denominator=frameinterval; - - }else{ - return -EINVAL; - } - } - - if (interlace_mode) fival->discrete.denominator /=2; - - - //printk("%s.frameinterval =%d.fival->width=%d.fival->height=%d\n",__func__,frameinterval,fival->width,fival->height); - return 0; + interlace_mode = framegrabber_g_input_interlace(v4l2m_context->framegrabber_handle); + + + fivaldenominator=framegrabber_g_framesize_supportrefreshrate(v4l2m_context->framegrabber_handle, fival->width, fival->height, fival->index); + + if(fivaldenominator) + { + pr_info("fivaldenominator = %d\n", fivaldenominator); + fival->type = V4L2_FRMIVAL_TYPE_DISCRETE; + fival->discrete.numerator=fivalnumerator; + fival->discrete.denominator=fivaldenominator; + }else{ + return -EINVAL; + } + + if (interlace_mode) fival->discrete.denominator /=2; + + + //pr_info("%s.fivaldenominator =%d.fival->width=%d.fival->height=%d\n",__func__,fivaldenominator,fival->width,fival->height); + return 0; } int v4l2_model_ioctl_g_parm(struct file *file, void *fh,struct v4l2_streamparm *a) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); - //int current_denominator; - //printk("%s...\n",__func__); - if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + U32_T io_frame_rate; + U32_T in_frame_rate; + + if ((a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) { - printk("%s..\n",__func__); + pr_err("unsupported video buffer type"); return -EINVAL; } + io_frame_rate = framegrabber_g_out_framerate(v4l2m_context->framegrabber_handle); + in_frame_rate = framegrabber_g_input_framerate(v4l2m_context->framegrabber_handle); + a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; - a->parm.capture.capturemode = V4L2_MODE_HIGHQUALITY; - a->parm.capture.timeperframe.numerator = 1; - //printk("%s>>>>>>>>>denominator=%d\n",__func__,a->parm.capture.timeperframe.denominator); + a->parm.capture.readbuffers = 1; - //a->parm.capture.timeperframe.denominator = framegrabber_g_out_framerate(v4l2m_context->framegrabber_handle); - //printk("%s>>>>>>>>>denominator=%d\n",__func__,a->parm.capture.timeperframe.denominator); - if ((a->parm.capture.timeperframe.denominator ==0) || (a->parm.capture.timeperframe.denominator >60)) + a->parm.capture.timeperframe.numerator = 1; + a->parm.capture.timeperframe.denominator = io_frame_rate; + + if ((a->parm.capture.timeperframe.denominator ==0) || (a->parm.capture.timeperframe.denominator >144)) { - a->parm.capture.timeperframe.denominator = framegrabber_g_input_framerate(v4l2m_context->framegrabber_handle); - //printk("%s..io_framerate=%d\n",__func__,a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator); - }else - {// - //framegrabbe_s_out_framerate(v4l2m_context->framegrabber_handle,a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator); - - //printk("%s..in_framerate=%d\n",__func__,a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator); - } - - return 0; + if (in_frame_rate != 0) { + a->parm.capture.timeperframe.denominator = in_frame_rate; + } else { + //If there is no input framerate and no output framerate is set, default to 60 + a->parm.capture.timeperframe.denominator = REFRESHRATE_60; + } + + //If output framerate is not valid, set it to the read value + framegrabber_s_out_framerate(v4l2m_context->framegrabber_handle,a->parm.capture.timeperframe.denominator); + } + + pr_info("a->parm.capture.timeperframe.denominator=%d a->parm.capture.timeperframe.numerator=%d\n",a->parm.capture.timeperframe.denominator, a->parm.capture.timeperframe.numerator); + + return 0; } int v4l2_model_ioctl_s_parm(struct file *file, void *fh,struct v4l2_streamparm *a) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); - U32_T io_frame_rate; - U32_T in_frame_rate; - //printk("%s...a->parm.capture.timeperframe.denominator=%d\n",__func__,a->parm.capture.timeperframe.denominator); - io_frame_rate = a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator; - in_frame_rate = framegrabber_g_input_framerate(v4l2m_context->framegrabber_handle); - if ((io_frame_rate !=0) /*&& (io_frame_rate <=85)*/) + U32_T io_frame_rate = 0; + U32_T in_frame_rate = 0; + pr_info("a->parm.capture.timeperframe.denominator=%d a->parm.capture.timeperframe.numerator=%d\n",a->parm.capture.timeperframe.denominator, a->parm.capture.timeperframe.numerator); + + if (a->parm.capture.timeperframe.numerator > 0) + io_frame_rate = a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator; + in_frame_rate = framegrabber_g_input_framerate(v4l2m_context->framegrabber_handle); + if ((io_frame_rate > 0) && (io_frame_rate <= 144)) { framegrabber_s_out_framerate(v4l2m_context->framegrabber_handle,io_frame_rate); //a->parm.capture.timeperframe.denominator = io_frame_rate; - printk("%s set io_framerate= %u\n", __func__, io_frame_rate); + pr_info("set framerate to io_framerate= %u\n", io_frame_rate); } - else + else if (in_frame_rate != 0) { framegrabber_s_out_framerate(v4l2m_context->framegrabber_handle,in_frame_rate); - printk("%s set in_framerate= %u\n", __func__, in_frame_rate); - } - - + pr_info("set framerate to in_framerate= %u\n", in_frame_rate); + } else { + framegrabber_s_out_framerate(v4l2m_context->framegrabber_handle,REFRESHRATE_60); + pr_info("set framerate to 60 Hz\n"); + } + + a->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; + //framegrabber_s_input_framerate(v4l2m_context->framegrabber_handle,a->parm.capture.timeperframe.denominator/a->parm.capture.timeperframe.numerator,a->parm.capture.timeperframe.denominator); //for test - //printk("%s..%d %d\n",__func__,a->parm.capture.timeperframe.denominator,a->parm.capture.timeperframe.numerator); + //pr_info("%s..%d %d\n",__func__,a->parm.capture.timeperframe.denominator,a->parm.capture.timeperframe.numerator); return 0; } @@ -652,7 +916,7 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ //int BCHSinfo; int bchs_select=0; - //printk("%s...ctrl->id=%x\n",__func__,ctrl->id); + //pr_info("%s...ctrl->id=%x\n",__func__,ctrl->id); //bchs_select = ADV7619_BCHS_DISABLE; @@ -662,14 +926,14 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ bchs_select = V4L2_BCHS_TYPE_BRIGHTNESS; //adv7619_get_bchs(v4l2m_context->adv7619_handle,&BCHSinfo,bchs_select); ctrl->value = framegrabber_g_input_bchs(v4l2m_context->framegrabber_handle,bchs_select); - printk("%s...brightness(%d)\n",__func__,ctrl->value); + pr_info("brightness(%d)\n",ctrl->value); ret = 0; break; case V4L2_CID_CONTRAST: bchs_select = V4L2_BCHS_TYPE_CONTRAST; - printk("%s...contrast(%d)\n",__func__,bchs_select); + pr_info("contrast(%d)\n",bchs_select); ctrl->value = framegrabber_g_input_bchs(v4l2m_context->framegrabber_handle,bchs_select); ret = 0; break; @@ -677,7 +941,7 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ case V4L2_CID_SATURATION: bchs_select = V4L2_BCHS_TYPE_SATURATION; - printk("%s...saturation(%d)\n",__func__,bchs_select); + pr_info("saturation(%d)\n",bchs_select); ctrl->value = framegrabber_g_input_bchs(v4l2m_context->framegrabber_handle,bchs_select); ret = 0; break; @@ -685,7 +949,7 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ case V4L2_CID_HUE: bchs_select = V4L2_BCHS_TYPE_HUE; - printk("%s...hue(%d)\n",__func__,bchs_select); + pr_info("hue(%d)\n",bchs_select); ctrl->value = framegrabber_g_input_bchs(v4l2m_context->framegrabber_handle,bchs_select); ret = 0; break; // @@ -704,7 +968,7 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ else ctrl->value = 96000; - printk("%s...audio(%d)\n",__func__,ctrl->value); + pr_info("%s...audio(%d)\n",__func__,ctrl->value); break; #endif #if 0 @@ -715,12 +979,12 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ ctrl->value =framegrabber_g_hdcp_state(v4l2m_context->framegrabber_handle); - printk("%s...hdcp flag(%d)\n",__func__,ctrl->value); + pr_info("%s...hdcp flag(%d)\n",__func__,ctrl->value); break; #endif default: ctrl->value =0; - printk("control id %d not handled\n", ctrl->id); + pr_info("control id %d not handled\n", ctrl->id); break; } @@ -730,7 +994,7 @@ int v4l2_model_ioctl_g_ctrl(struct file *file, void *fh,struct v4l2_control *a)/ ctrl->value = framegrabber_g_input_bchs(v4l2m_context->framegrabber_handle,&bchs_select); } #endif - //printk("%s...ctrl->value(%d)=%x\n",__func__,bchs_select,ctrl->value); + //pr_info("%s...ctrl->value(%d)=%x\n",__func__,bchs_select,ctrl->value); return ret; } @@ -745,7 +1009,7 @@ int v4l2_model_ioctl_s_ctrl(struct file *file, void *fh,struct v4l2_control *a) // int io_bchs_value=0; // int io_bchs_select=0; - //printk("%s...\n",__func__); + if( found_ctrl ) { switch( found_ctrl->type ) { @@ -772,7 +1036,7 @@ int v4l2_model_ioctl_s_ctrl(struct file *file, void *fh,struct v4l2_control *a) break; case V4L2_CID_AUTOGAIN: //framegrabber_s_hdcp_state(v4l2m_context->framegrabber_handle, ctrl->value); - printk("%s...hdcp state(%d)\n",__func__,ctrl->value); + pr_info("%s...hdcp state(%d)\n",__func__,ctrl->value); break; default: @@ -785,7 +1049,7 @@ int v4l2_model_ioctl_s_ctrl(struct file *file, void *fh,struct v4l2_control *a) ret = 0; } else { //error - printk("control %s out of range\n", found_ctrl->name); + pr_info("control %s out of range\n", found_ctrl->name); } break; #if 0 @@ -797,7 +1061,7 @@ int v4l2_model_ioctl_s_ctrl(struct file *file, void *fh,struct v4l2_control *a) #endif default: //error - printk("control type %d not handled\n", found_ctrl->type); + pr_info("control type %d not handled\n", found_ctrl->type); } } @@ -818,7 +1082,7 @@ int v4l2_model_ioctl_queryctrl(struct file *file, void *fh,struct v4l2_queryctrl ctrl->flags = V4L2_CTRL_FLAG_DISABLED; } else { *ctrl = *found_ctrl; - printk("control %s\n", found_ctrl->name); + pr_info("control %s\n", found_ctrl->name); ret = 0; } @@ -833,7 +1097,7 @@ int v4l2_model_ioctl_cropcap(struct file *file, void *fh,struct v4l2_cropcap *a) if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { - printk("%s..\n",__func__); + pr_info("%s..\n",__func__); return -EINVAL; } @@ -867,7 +1131,7 @@ int v4l2_model_ioctl_s_hdcp_state(struct file *file,unsigned int *arg) { v4l2_model_context_t *v4l2m_context = video_drvdata(file); int ret=0; - printk("ioctl set hdcp state:%d \n", *arg); + pr_info("ioctl set hdcp state:%d \n", *arg); framegrabber_s_hdcp_state(v4l2m_context->framegrabber_handle, *arg); return ret; } @@ -878,7 +1142,7 @@ int v4l2_model_ioctl_g_flash(struct file *file,struct v4l2_dump_flash *flash_dum v4l2_model_context_t *v4l2m_context = video_drvdata(file); int ret=0; - printk("%s pad=%d, sb=%d, bs=%d\n", __func__, + pr_info("%s pad=%d, sb=%d, bs=%d\n", __func__, flash_dump->pad, flash_dump->start_block, flash_dump->blocks); ret = framegrabber_g_flash(v4l2m_context->framegrabber_handle, flash_dump->start_block, flash_dump->blocks, flash_dump->flash); @@ -891,7 +1155,7 @@ int v4l2_model_ioctl_s_flash(struct file *file,struct v4l2_dump_flash *flash_upd v4l2_model_context_t *v4l2m_context = video_drvdata(file); int ret=0; - printk("%s pad=%d, sb=%d, bs=%d\n", __func__, + pr_info("%s pad=%d, sb=%d, bs=%d\n", __func__, flash_update->pad, flash_update->start_block, flash_update->blocks); #if 1 ret = framegrabber_s_flash(v4l2m_context->framegrabber_handle, flash_update->start_block, @@ -904,7 +1168,7 @@ int v4l2_model_ioctl_s_flash(struct file *file,struct v4l2_dump_flash *flash_upd int v4l2_model_ioctl_s_dv_timings(struct file *file, void *fd, struct v4l2_dv_timings *timings) { - printk("%s...\n", __func__); + pr_info("%s...\n", __func__); return 0; } @@ -912,49 +1176,49 @@ int v4l2_model_ioctl_s_dv_timings(struct file *file, void *fd, int v4l2_model_ioctl_g_dv_timings(struct file *file, void *fd, struct v4l2_dv_timings *timings) { - printk("%s...\n", __func__); + pr_info("%s...\n", __func__); return 0; } int v4l2_model_ioctl_enum_std(struct file *file, void *fd, struct v4l2_standard *std) { - printk("%s...\n",__func__); + return -EINVAL; } int v4l2_model_ioctl_s_std(struct file *file, void *fd, v4l2_std_id std) { - printk("%s...\n",__func__); + return 0; } int v4l2_model_ioctl_g_std(struct file *file, void *fd, v4l2_std_id *std) { - printk("%s...\n",__func__); + return 0; } int v4l2_model_ioctl_querystd(struct file *file, void *fd, v4l2_std_id *std) { - printk("%s...\n",__func__); + return 0; } int v4l2_model_g_tuner(struct file *file, void *fd, struct v4l2_tuner *tuner) { - printk("%s...\n",__func__); + return 0; } int v4l2_model_s_tuner(struct file *file, void *fd, const struct v4l2_tuner *tuner) { - printk("%s...\n",__func__); + return 0; } diff --git a/driver/utils/v4l2/v4l2_model_ioctl.h b/driver/utils/v4l2/v4l2_model_ioctl.h index 3e2d9a6..4eb292b 100644 --- a/driver/utils/v4l2/v4l2_model_ioctl.h +++ b/driver/utils/v4l2/v4l2_model_ioctl.h @@ -22,8 +22,11 @@ int v4l2_model_ioctl_querycap(struct file *file, void *fh, struct v4l2_capability *cap); int v4l2_model_ioctl_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f); int v4l2_model_ioctl_g_fmt_vid_cap(struct file *file, void *fh,struct v4l2_format *f); +int v4l2_model_ioctl_g_fmt_vid_cap_mplane(struct file *file, void *fh,struct v4l2_format *f); int v4l2_model_ioctl_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f); +int v4l2_model_ioctl_try_fmt_vid_cap_mplane(struct file *file, void *fh, struct v4l2_format *f); int v4l2_model_ioctl_s_fmt_vid_cap(struct file *file, void *fh,struct v4l2_format *f); +int v4l2_model_ioctl_s_fmt_vid_cap_mplane(struct file *file, void *fh,struct v4l2_format *f); int v4l2_model_ioctl_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize); int v4l2_model_ioctl_enum_input(struct file *file, void *fh, struct v4l2_input *inp); int v4l2_model_ioctl_g_input(struct file *file, void *fh, unsigned int *i); diff --git a/driver/utils/v4l2/v4l2_model_table.c b/driver/utils/v4l2/v4l2_model_table.c index 7c0c3a1..9a384e6 100644 --- a/driver/utils/v4l2/v4l2_model_table.c +++ b/driver/utils/v4l2/v4l2_model_table.c @@ -9,6 +9,9 @@ * Version: * ================================================================= */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include "typedef.h" #include #include diff --git a/driver/utils/v4l2/v4l2_model_videobuf2.c b/driver/utils/v4l2/v4l2_model_videobuf2.c index d62832b..036fa0f 100644 --- a/driver/utils/v4l2/v4l2_model_videobuf2.c +++ b/driver/utils/v4l2/v4l2_model_videobuf2.c @@ -9,10 +9,14 @@ * Version: * ================================================================= */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " "%s, %d: " fmt, __func__, __LINE__ + #include "typedef.h" #include #include #include +#include #include #include #include @@ -98,78 +102,70 @@ static int v4l2_model_qops_queue_setup(struct vb2_queue *q, (v4l2_model_vb2_context_t *) v4l2m_context->vb2_context; v4l2_model_callback_item_t *callback_item = &v4l2m_context->callbacks[V4L2_MODEL_CALLBACK_QUEUE_SETUP]; -// const framegrabber_pixfmt_t *pixfmt; - unsigned framebufsize; int width, height; - unsigned bytesperline; - -// pixfmt = framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); -// if (width == 0 || height == 0) -// { -// return -EINVAL; -// } - framebufsize = - framegrabber_g_max_framebuffersize(v4l2m_context-> - framegrabber_handle); - framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); //test - printk("%s framebufsize %u, width %d, height %d\n", __func__, - framebufsize, width, height); - //if (framebufsize == 0) - { - //int width, height; - //unsigned bytesperline; - - //framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, - // &width, &height); - bytesperline = - framegrabber_g_out_bytesperline(v4l2m_context-> - framegrabber_handle); - framebufsize = bytesperline * height; - printk("%s >>> framebufsize %u, width %d, height %d\n", - __func__, framebufsize, width, height); - } - - if (width ==0) - { - width = 1920; - height = 1080; - - framebufsize = - framegrabber_g_max_framebuffersize(v4l2m_context-> - framegrabber_handle); - printk("===============================================\n"); - printk("debug framebufsize %u, width %d, height %d\n", - framebufsize, width, height); - } - - //printk("%s framebufsize %u, width %d, height %d\n", __func__, - // framebufsize, width, height); - - if (v4l2m_context->pic_bmp_handle) - { - if (vb2_context->image_data) - { - vfree(vb2_context->image_data); - vb2_context->image_data = NULL; - } - vb2_context->image_data = vmalloc(framebufsize); + const framegrabber_pixfmt_t *pixfmt; + framegrabber_pixfmt_enum_t pixfmt_out; + + framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); //test + + pixfmt = framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + pixfmt_out = pixfmt->pixfmt_out; + pr_info("pixelformat %s\n", pixfmt->name); + + *num_planes = pixfmt->num_planes; + + switch (*num_planes) { + case 3: + if (vb2_context->alloc_ctx) + alloc_ctxs[2] = vb2_context->alloc_ctx; + sizes[2] = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 3); + pr_info("size of plane 3 %d\n", sizes[2]); + // fall through + case 2: + if (vb2_context->alloc_ctx) + alloc_ctxs[1] = vb2_context->alloc_ctx; + sizes[1] = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 2); + pr_info("size of plane 2 %d\n", sizes[1]); + // fall through + case 1: + if (vb2_context->alloc_ctx) + alloc_ctxs[0] = vb2_context->alloc_ctx; + sizes[0] = framegrabber_g_out_planarbuffersize(v4l2m_context->framegrabber_handle, 1); + pr_info("size of plane 1 %d\n", sizes[0]); + } + pr_info("number of requested planes %d\n", *num_planes); + pr_info("number of requested buffers %d\n", *num_buffers); - pic_bmp_prepare(v4l2m_context->pic_bmp_handle, 640, 480, width, height); - load_no_signal_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height); - vb2_context->image_type = V4L2_MODEL_VB2_IMAGE_NO_SIGNAL; - } + if (v4l2m_context->pic_bmp_handle) + { + if (vb2_context->image_data) + { + vfree(vb2_context->image_data); + vb2_context->image_data = NULL; + } + /*allocate full framebuffer size (i.e. size of all planes) even in multiplanar architecture */ + vb2_context->image_data = vmalloc(framegrabber_g_out_framebuffersize(v4l2m_context->framegrabber_handle)); + + pic_bmp_prepare(v4l2m_context->pic_bmp_handle, 640, 480, width, height); + load_no_signal_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height + , (pixfmt_out == YUYV) ? PIC_BMP_PIXFMT_YUYV + : (pixfmt_out == YVU420 || pixfmt_out == YVU420M) ? PIC_BMP_PIXFMT_YV12 + : (pixfmt_out == NV12 || pixfmt_out == NV12M) ? PIC_BMP_PIXFMT_NV12 + : (pixfmt_out == BGR3) ? PIC_BMP_PIXFMT_RGB24 + : PIC_BMP_PIXFMT_OTHERS); + vb2_context->image_type = V4L2_MODEL_VB2_IMAGE_NO_SIGNAL; + } - sizes[0] = framebufsize; - *num_planes = 1; - if (vb2_context->alloc_ctx) - alloc_ctxs[0] = vb2_context->alloc_ctx; + + v4l2m_context->inibuffer_create = 0; + v4l2m_context->inibuffer_index = 0; if (callback_item->callback) { callback_item->data.u.queue_setup_info.buffer_num = *num_buffers; callback_item->callback(&callback_item->data); } - printk("%s >>>>>\n", __func__); + return 0; } @@ -187,14 +183,33 @@ static void v4l2_model_qops_wait_finish(struct vb2_queue *q) static int v4l2_model_qops_buf_init(struct vb2_buffer *vb) { + int i; v4l2_model_context_t *v4l2m_context = vb2b_to_v4l2context(vb); v4l2_model_callback_item_t *callback_item = &v4l2m_context->callbacks[V4L2_MODEL_CALLBACK_BUFFER_INIT]; - + +#if LINUX_VERSION_CODE >=KERNEL_VERSION(4,4,0) + v4l2_model_vb2_buffer_t *v4l2_buf = + container_of(to_vb2_v4l2_buffer(vb), v4l2_model_vb2_buffer_t, vb); +#else + v4l2_model_vb2_buffer_t *v4l2_buf = + container_of(vb, v4l2_model_vb2_buffer_t, vb); +#endif + v4l2_model_buffer_info_t *buffer_info = &v4l2_buf->buffer_info; + v4l2m_context->inibuffer_create++; - - //printk("==%s vb %p ; buffer create++=%d\n", __func__, vb, v4l2m_context->inibuffer_create); - + + for (i=0; i < vb->num_planes; i++) { + struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, i); + + buffer_info->buf_count[i] = sgt->nents; + + v4l2_buf->buf_descs[i] = + kzalloc(sizeof(v4l2_model_buf_desc_t) * buffer_info->buf_count[i], GFP_KERNEL); + pr_info("v4l2_buf %p, v4l2_buf->buffer_info %p plane %d buf_descs[%d] %p\n", v4l2_buf, &v4l2_buf->buffer_info, i, i, v4l2_buf->buf_descs[i]); + } + + if (callback_item->callback) { v4l2_model_callback_parameter_t *parm = &callback_item->data; callback_item->callback(parm); @@ -219,106 +234,91 @@ static int v4l2_model_qops_buf_prepare(struct vb2_buffer *vb) v4l2_model_vb2_buffer_t *v4l2_buf = container_of(vb, v4l2_model_vb2_buffer_t, vb); #endif + const framegrabber_pixfmt_t *pixfmt; int width, height; int buffer_size = 0; -// printk("%s >>>>>\n",__func__); - framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, - &height); - pixfmt = - framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); +// pr_info("%s >>>>>\n",__func__); + framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); + pixfmt = framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + + pr_debug("framesize %dx%d %dbit\n", width, height, pixfmt->depth); + pr_debug("numberofplanes = %d\n", vb->num_planes); - v4l2_buf->buffer_info.planes = vb->num_planes; + + v4l2_buf->buffer_info.planes = vb->num_planes; v4l2_buf->buffer_info.buf_type = vb2_cxt->queue_type; for (i = 0; i < vb->num_planes; i++) { v4l2_model_buffer_info_t *buffer_info = &v4l2_buf->buffer_info; switch (vb2_cxt->queue_type) { case V4L2_MODEL_BUF_TYPE_VMALLOC: -// printk("%s >>>>> V4L2_MODEL_BUF_TYPE_VMALLOC\n",__func__); buffer_info->buf_count[i] = 1; v4l2_buf->buf_descs[i] = - kzalloc(sizeof(v4l2_model_buf_desc_t) * - buffer_info->buf_count[i], GFP_KERNEL); + kzalloc(sizeof(v4l2_model_buf_desc_t) * buffer_info->buf_count[i], GFP_KERNEL); if (v4l2_buf->buf_descs[i]) { - v4l2_model_buf_desc_t *buf_descs = - v4l2_buf->buf_descs[i]; - buf_descs[0].addr = - (unsigned long)vb2_plane_vaddr(vb, i); - buf_descs[0].size = vb2_plane_size(vb, i); - } + v4l2_model_buf_desc_t *buf_descs = v4l2_buf->buf_descs[i]; + buf_descs[i].addr = (unsigned long)vb2_plane_vaddr(vb, i); + buf_descs[i].size = vb2_plane_size(vb, i); + buffer_size = buf_descs[i].size; + } buffer_info->buf_info[i] = v4l2_buf->buf_descs[i]; break; case V4L2_MODEL_BUF_TYPE_DMA_SG: { - struct sg_table *sgt = - vb2_dma_sg_plane_desc(vb, i); + struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, i); struct scatterlist *sg; int j; -// printk("%s >>>>> V4L2_MODEL_BUF_TYPE_DMA_SG\n",__func__); - buffer_info->buf_count[i] = sgt->nents; - - if (v4l2m_context->inibuffer_index != 0) - { - printk("%s >>>>>\n",__func__); - v4l2_buf->buf_descs[i] = - kzalloc(sizeof(v4l2_model_buf_desc_t) * - buffer_info->buf_count[i],GFP_KERNEL); - v4l2m_context->inibuffer_index--; - } + if (v4l2_buf->buf_descs[i]) { #if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) if (!dma_map_sg (v4l2m_context->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE)) - printk("error dma_map_sg\n"); + pr_err("error dma_map_sg\n"); #endif - + pr_debug("plane[%d]: number of sg buffers %d\n", i, sgt->nents); for_each_sg(sgt->sgl, sg, sgt->nents, j) { - v4l2_model_buf_desc_t *buf_descs - = v4l2_buf->buf_descs[i]; + v4l2_model_buf_desc_t *buf_descs = v4l2_buf->buf_descs[i]; - buf_descs[j].addr = - sg_dma_address(sg); - buf_descs[j].size = - sg_dma_len(sg); + buf_descs[j].addr = sg_dma_address(sg); + buf_descs[j].size = sg_dma_len(sg); buffer_size += buf_descs[j].size; + + pr_debug("plane[%d]: sg_buffer %lx sg_buffer_size %ld\n", i, buf_descs[j].addr, buf_descs[j].size); } - buffer_info->buf_info[i] = - v4l2_buf->buf_descs[i]; + buffer_info->buf_info[i] = v4l2_buf->buf_descs[i]; } } break; case V4L2_MODEL_BUF_TYPE_DMA_CONT: -// printk("%s >>>>> V4L2_MODEL_BUF_TYPE_DMA_CONT\n",__func__); - v4l2_buf->buffer_info.buf_count[i] = 1; - v4l2_buf->buf_descs[i] = - kzalloc(sizeof(v4l2_model_buf_desc_t) * - buffer_info->buf_count[i], GFP_KERNEL); - if (v4l2_buf->buf_descs[i]) { - v4l2_model_buf_desc_t *buf_descs = - v4l2_buf->buf_descs[i]; - buf_descs[0].addr = - vb2_dma_contig_plane_dma_addr(vb, i); - buf_descs[0].size = vb2_plane_size(vb, i); - } - buffer_info->buf_info[i] = v4l2_buf->buf_descs[i]; - - break; - } + { + int j; + v4l2_buf->buffer_info.buf_count[i] = 1; + v4l2_buf->buf_descs[i] = kzalloc(sizeof(v4l2_model_buf_desc_t) * + buffer_info->buf_count[i], GFP_KERNEL); + if (v4l2_buf->buf_descs[i]) { + v4l2_model_buf_desc_t *buf_descs = v4l2_buf->buf_descs[i]; + for (j = 0; j < buffer_info->buf_count[i]; j++) { + buf_descs[j].addr = vb2_dma_contig_plane_dma_addr(vb, i); + buf_descs[j].size = vb2_plane_size(vb, i); + buffer_size += buf_descs[j].size; + } + } + buffer_info->buf_info[i] = v4l2_buf->buf_descs[i]; + } + break; + } /* set vb2 plane bytesused size */ - vb2_set_plane_payload(vb, i, - width * height * (pixfmt->depth >> 3)); - v4l2_buf->length += vb2_plane_size(vb, i); + vb2_set_plane_payload(vb, i,vb2_plane_size(vb, i)); + v4l2_buf->length += vb2_plane_size(vb, i); + pr_debug("plane[%d]: buffer_size = %d plane_size = %ld\n", i, buffer_size, vb2_plane_size(vb, i)); } -// printk("%s >>>>> %dx%d %dbit\n", __func__, width, height, pixfmt->depth); -// printk("%s >>>>> buffer size = %d\n", __func__, buffer_size); - if (callback_item->callback) { v4l2_model_callback_parameter_t *parm = &callback_item->data; parm->u.buffer_prepare_info.buffer_info = @@ -342,7 +342,7 @@ static void v4l2_model_qops_buf_cleanup(struct vb2_buffer *vb) container_of(vb, v4l2_model_vb2_buffer_t, vb); #endif int i; - printk("=====================%s vb %p \n", __func__, vb); + pr_info("===================== vb %p \n", vb); //return; //rr3 @@ -386,7 +386,7 @@ static void v4l2_model_qops_buf_finish(struct vb2_buffer *vb) //v4l2_model_vb2_context_t *vb2_context=(v4l2_model_vb2_context_t *)v4l2m_context->vb2_context; v4l2_model_callback_item_t *callback_item = &v4l2m_context->callbacks[V4L2_MODEL_CALLBACK_BUFFER_FINISH]; - //printk("%s vb %p \n", __func__, vb); + //pr_info("%s vb %p \n", __func__, vb); if (callback_item->callback) { callback_item->callback(&callback_item->data); @@ -406,7 +406,7 @@ static int v4l2_model_qops_start_streaming(struct vb2_queue *q, (v4l2_model_vb2_context_t *) v4l2m_context->vb2_context; v4l2_model_callback_item_t *callback_item = &v4l2m_context->callbacks[V4L2_MODEL_CALLBACK_STREAMON]; - printk("%s...\n", __func__); + pr_info("%s...\n", __func__); if (callback_item->callback) { callback_item->callback(&callback_item->data); } @@ -415,7 +415,7 @@ static int v4l2_model_qops_start_streaming(struct vb2_queue *q, //v4l2m_context->current_framebuf_info.rcv_size=0; v4l2_model_reset_video_data(v4l2m_context); - v4l2m_context->inibuffer_index =v4l2m_context->inibuffer_create; + v4l2m_context->inibuffer_index =v4l2m_context->inibuffer_create; return 0; } @@ -438,11 +438,11 @@ static void v4l2_model_qops_stop_streaming(struct vb2_queue *q) callback_item->callback(&callback_item->data); } if (list_empty(&vb2_context->buffer_list)) { - printk("%s vb2_context->buffer_list empty\n", __func__); + pr_info("%s vb2_context->buffer_list empty\n", __func__); } else { v4l2_model_queue_cancel(v4l2m_context); - printk("%s...\n", __func__); + pr_info("%s...\n", __func__); } // v4l2m_context->current_framebuf_info.vbuf_info=NULL; // v4l2m_context->current_framebuf_info.rcv_size=0; @@ -476,7 +476,7 @@ static void v4l2_model_qops_buf_queue(struct vb2_buffer *vb) #endif v4l2_model_vb2_context_t *vb2_context = v4l2m_context->vb2_context; - //printk("%s vb %p\n",__func__,vb); + //pr_info("%s vb %p\n",__func__,vb); spin_lock_irqsave(&vb2_context->queuelock, flags); list_add_tail(&v4l2_model_buffer->list, &vb2_context->buffer_list); spin_unlock_irqrestore(&vb2_context->queuelock, flags); @@ -560,7 +560,7 @@ void *v4l2_model_vb2_init(struct vb2_queue *q, v4l2_model_devicetype_t dev_type, vb2_context->alloc_ctx = vb2_dma_contig_init_ctx(dev); if (!vb2_context->alloc_ctx) { - printk("vb2_dma_contig_init_ctx fail\n"); + pr_err("vb2_dma_contig_init_ctx fail\n"); kfree(vb2_context); return NULL; } @@ -577,7 +577,7 @@ void *v4l2_model_vb2_init(struct vb2_queue *q, v4l2_model_devicetype_t dev_type, vb2_context->alloc_ctx = vb2_dma_sg_init_ctx(dev); if (!vb2_context->alloc_ctx) { - printk("vb2_dma_sg_init_ctx fail\n"); + pr_err("vb2_dma_sg_init_ctx fail\n"); kfree(vb2_context); return NULL; } @@ -594,7 +594,7 @@ void *v4l2_model_vb2_init(struct vb2_queue *q, v4l2_model_devicetype_t dev_type, rc = vb2_queue_init(q); if (rc) { - printk("%s vb2 queue init failed\n", __func__); + pr_err("%s vb2 queue init failed\n", __func__); kfree(vb2_context); return NULL; } @@ -614,7 +614,7 @@ void v4l2_model_vb2_release(void *context) switch (vb2_context->queue_type) { case V4L2_MODEL_BUF_TYPE_VMALLOC: - printk("%s vmalloc should not have alloc_cxt \n", __func__); + pr_info("%s vmalloc should not have alloc_cxt \n", __func__); break; case V4L2_MODEL_BUF_TYPE_DMA_CONT: vb2_dma_contig_cleanup_ctx(vb2_context->alloc_ctx); @@ -641,7 +641,7 @@ void v4l2_model_queue_cancel(void *context) (v4l2_model_vb2_context_t *) v4l2m_context->vb2_context; v4l2_model_vb2_buffer_t *buf; framegrabber_status_bitmask_e framegrabber_status; - printk("%s\n", __func__); + pr_info("%s\n", __func__); //spin_lock_irqsave(&vb2_context->queuelock, flags); while (!list_empty(&vb2_context->buffer_list)) { struct vb2_buffer *vb; @@ -654,7 +654,7 @@ void v4l2_model_queue_cancel(void *context) #else vb = &buf->vb; #endif - //printk("%s vb %p done\n",__func__,vb); + //pr_info("%s vb %p done\n",__func__,vb); list_del_init(&buf->list); framegrabber_status = framegrabber_g_status(v4l2m_context->framegrabber_handle); @@ -667,14 +667,14 @@ void v4l2_model_queue_cancel(void *context) vb2_buffer_done(vb, VB2_BUF_STATE_DONE); } else { - printk("%s framegrabber_status %08x\n", __func__, + pr_info("%s framegrabber_status %08x\n", __func__, framegrabber_status); vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); } } //spin_unlock_irqrestore(&vb2_context->queuelock, flags); - printk("%s done\n", __func__); + pr_info("%s done\n", __func__); } void v4l2_model_next_buffer(v4l2_model_handle_t context, @@ -689,7 +689,7 @@ void v4l2_model_next_buffer(v4l2_model_handle_t context, spin_lock_irqsave(&vb2_context->queuelock, flags); if (list_empty(&vb2_context->buffer_list)) { - //printk("%s vb2 queue is empty\n", __func__); + pr_info("vb2 queue is empty\n"); *buffer_info = NULL; spin_unlock_irqrestore(&vb2_context->queuelock, flags); return; @@ -701,7 +701,7 @@ void v4l2_model_next_buffer(v4l2_model_handle_t context, spin_unlock_irqrestore(&vb2_context->queuelock, flags); //vb= &next_buffer->vb; - //printk("%s vb %p\n",__func__,vb); + //pr_info("%s vb %p\n",__func__,vb); *buffer_info = &next_buffer->buffer_info; } @@ -716,10 +716,6 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) (v4l2_model_vb2_context_t *) v4l2m_context->vb2_context; v4l2_model_vb2_buffer_t *buf; framegrabber_status_bitmask_e framegrabber_status; - //int width, height; - //const framegrabber_pixfmt_t *pixfmt=framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); - //framegrabber_g_input_framesize(v4l2m_context->framegrabber_handle, - // &width, &height); /* get next v4l2_model_buffer from vb2 context buffer_list */ spin_lock_irqsave(&vb2_context->queuelock, flags); @@ -733,7 +729,7 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) spin_unlock_irqrestore(&vb2_context->queuelock, flags); if (!buf) { - printk("%s no buffer to serve\n", __func__); + pr_err("no buffer to serve\n"); return; } #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,5,0) @@ -761,18 +757,29 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) } #endif #endif - if (1) + if (v4l2m_context->pic_bmp_handle) { u32 input_status, hdcp_flag; u8 *ptr = NULL; + const framegrabber_pixfmt_t *pixfmt = framegrabber_g_out_pixelfmt(v4l2m_context->framegrabber_handle); + framegrabber_pixfmt_enum_t pixfmt_out = pixfmt->pixfmt_out; input_status = framegrabber_g_input_status(v4l2m_context->framegrabber_handle); hdcp_flag = framegrabber_g_hdcp_flag(v4l2m_context->framegrabber_handle); + if (input_status != FRAMEGRABBER_INPUT_STATUS_OK || hdcp_flag) { - v4l2_model_vb2_image_type_e type = - (input_status == FRAMEGRABBER_INPUT_STATUS_NO_SIGNAL) ? V4L2_MODEL_VB2_IMAGE_NO_SIGNAL - : (hdcp_flag) ? V4L2_MODEL_VB2_IMAGE_COPY_PROTECTION - : V4L2_MODEL_VB2_IMAGE_NO_SIGNAL; + pr_debug("framegrabber input status not ok"); + v4l2_model_vb2_image_type_e type = V4L2_MODEL_VB2_IMAGE_NO_SIGNAL; + if (input_status == FRAMEGRABBER_INPUT_STATUS_NO_SIGNAL || input_status == FRAMEGRABBER_INPUT_STATUS_NO_POWER) { + type = V4L2_MODEL_VB2_IMAGE_NO_SIGNAL; + } + else if (input_status == FRAMEGRABBER_INPUT_STATUS_NO_SYNC) { + type = V4L2_MODEL_VB2_IMAGE_OUT_OF_RANGE; + } else { + if (hdcp_flag) { + type = V4L2_MODEL_VB2_IMAGE_COPY_PROTECTION; + } + } if (type != vb2_context->image_type) { @@ -780,21 +787,42 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) { int width, height; framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); - load_no_signal_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height); - printk("load no signal done\n"); + load_no_signal_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height + , (pixfmt_out == YUYV) ? PIC_BMP_PIXFMT_YUYV + : (pixfmt_out == YVU420 || pixfmt_out == YVU420M) ? PIC_BMP_PIXFMT_YV12 + : (pixfmt_out == NV12 || pixfmt_out == NV12M) ? PIC_BMP_PIXFMT_NV12 + : (pixfmt_out == BGR3) ? PIC_BMP_PIXFMT_RGB24 + : PIC_BMP_PIXFMT_OTHERS); + pr_debug("load no signal done\n"); } else if (type == V4L2_MODEL_VB2_IMAGE_COPY_PROTECTION) { int width, height; framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); - load_copy_protection_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height); - printk("load copy protection done\n"); + load_copy_protection_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height + , (pixfmt_out == YUYV) ? PIC_BMP_PIXFMT_YUYV + : (pixfmt_out == YVU420 || pixfmt_out == YVU420M) ? PIC_BMP_PIXFMT_YV12 + : (pixfmt_out == NV12 || pixfmt_out == NV12M) ? PIC_BMP_PIXFMT_NV12 + : (pixfmt_out == BGR3) ? PIC_BMP_PIXFMT_RGB24 + : PIC_BMP_PIXFMT_OTHERS); + pr_debug("load copy protection done\n"); + } + else if (type == V4L2_MODEL_VB2_IMAGE_OUT_OF_RANGE) + { + int width, height; + framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); + load_out_of_range_image(v4l2m_context->pic_bmp_handle, vb2_context->image_data, width, height + , (pixfmt_out == YUYV) ? PIC_BMP_PIXFMT_YUYV + : (pixfmt_out == YVU420 || pixfmt_out == YVU420M) ? PIC_BMP_PIXFMT_YV12 + : (pixfmt_out == NV12 || pixfmt_out == NV12M) ? PIC_BMP_PIXFMT_NV12 + : (pixfmt_out == BGR3) ? PIC_BMP_PIXFMT_RGB24 + : PIC_BMP_PIXFMT_OTHERS); + pr_debug("load out of range done\n"); } vb2_context->image_type = type; } ptr = vb2_context->image_data; - //printk(".\n"); } if (ptr) @@ -805,11 +833,17 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) break; case V4L2_MODEL_BUF_TYPE_DMA_SG: { - struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); - int width, height; - framegrabber_g_out_framesize(v4l2m_context->framegrabber_handle, &width, &height); + int i; + u8 *srcBuffer = ptr; + for (i =0; i < vb->num_planes; i++) { + struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, i); + unsigned planesize = vb2_plane_size(vb, i); + + size_t bytes_copied = sg_copy_from_buffer(sgt->sgl, sg_nents_for_len(sgt->sgl, planesize), srcBuffer, planesize); + pr_debug("copied %zd bytes from %p to sg_buffer in plane %d\n", bytes_copied, srcBuffer, i); - sg_copy_from_buffer(sgt->sgl, sgt->nents, ptr, width * height * 2); + srcBuffer+=planesize; + } } break; case V4L2_MODEL_BUF_TYPE_DMA_CONT: @@ -822,15 +856,14 @@ void v4l2_model_buffer_done(v4l2_model_handle_t context) framegrabber_g_status(v4l2m_context->framegrabber_handle); if ((framegrabber_status & - (FRAMEGRABBER_STATUS_V4L_START_STREAMING_BIT | - FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT)) == - (FRAMEGRABBER_STATUS_V4L_START_STREAMING_BIT | - FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT)) { - vb2_buffer_done(vb, VB2_BUF_STATE_DONE); - } else { - //printk("%s framegrabber_status %08x\n", __func__, framegrabber_status); - vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); - } + (FRAMEGRABBER_STATUS_V4L_START_STREAMING_BIT | + FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT)) != (FRAMEGRABBER_STATUS_V4L_START_STREAMING_BIT | + FRAMEGRABBER_STATUS_SIGNAL_LOCKED_BIT)) { + pr_debug("no input detected\n"); + } + + vb2_buffer_done(vb, VB2_BUF_STATE_DONE); +// vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); } void v4l2_model_reset_video_data(v4l2_model_handle_t context) @@ -848,14 +881,14 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ framebuffer_info_t *pframebuf_info; //unsigned line; int width, height; - //printk("%s %p %p size %ld\n",__func__,context,buffer,size); + //pr_info("%s %p %p size %ld\n",__func__,context,buffer,size); if (v4l2m_cxt) { pframebuf_info = &v4l2m_cxt->current_framebuf_info; if (!pframebuf_info->vbuf_info) { v4l2_model_next_buffer(v4l2m_cxt, &pframebuf_info->vbuf_info); - //printk("framebuf change to %p\n",pframebuf_info->vbuf_info->plane_vaddr[0]); + //pr_info("framebuf change to %p\n",pframebuf_info->vbuf_info->plane_vaddr[0]); } framegrabber_g_input_framesize(v4l2m_cxt->framegrabber_handle, @@ -890,14 +923,14 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ memcpy(lb,b,s);\ }else \ { \ - printk("copy may out of framebuf size %u offset %lu size %lu !\n",framebuf_size,(unsigned long)(lb-framebuf),(unsigned long)s) ;\ + pr_warn("copy may out of framebuf size %u offset %lu size %lu !\n",framebuf_size,(unsigned long)(lb-framebuf),(unsigned long)s) ;\ }\ } framemode = framegrabber_g_input_framemode(v4l2m_cxt-> framegrabber_handle); - bytesperline = framegrabber_g_out_bytesperline(v4l2m_cxt->framegrabber_handle); + bytesperline = framegrabber_g_out_bytesperline(v4l2m_cxt->framegrabber_handle, 1); //bytesperline = width*pix_size; framegrabber_g_out_framesize(v4l2m_cxt->framegrabber_handle, &width, &height); @@ -920,7 +953,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ if (framemode == FRAMEGRABBER_FRAMEMODE_PROGRESS) { - //printk("Progress line %d offset %d\n",line,line_stride*line); + //pr_info("Progress line %d offset %d\n",line,line_stride*line); linebuf = &framebuf[line_stride * line]; } else if (framemode == FRAMEGRABBER_FRAMEMODE_INTERLACED) { @@ -936,10 +969,10 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ line]; } - //printk("Interlace line %d offset %d\n",line,bytesperline+line_stride*line); + //pr_info("Interlace line %d offset %d\n",line,bytesperline+line_stride*line); } - //printk("%dx%dx%d rcv_size %d line %d offset %d line_stride %d bytesperline %d\n",width,height,pix_size,pframebuf_info->rcv_size,line,offset,line_stride,bytesperline); + //pr_info("%dx%dx%d rcv_size %d line %d offset %d line_stride %d bytesperline %d\n",width,height,pix_size,pframebuf_info->rcv_size,line,offset,line_stride,bytesperline); frame_remain_size = (width * height * pix_size) - pframebuf_info->rcv_size; @@ -949,7 +982,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ copy_size = remain_size; copy_to_framebuffer(&linebuf[offset], buf, copy_size); - //printk("memcpy offset %d size %d\n",offset,copy_size); + //pr_info("memcpy offset %d size %d\n",offset,copy_size); buf += copy_size; frame_remain_size -= copy_size; remain_size -= copy_size; @@ -957,12 +990,12 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ linebuf += line_stride; } do { - //printk("remain_size %d frame_remain_size %d\n",remain_size,frame_remain_size); + //pr_info("remain_size %d frame_remain_size %d\n",remain_size,frame_remain_size); if (frame_remain_size > remain_size) { copy_size = (width * pix_size); while (remain_size >= copy_size) { - //printk("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,copy_size); + //pr_info("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,copy_size); copy_to_framebuffer (linebuf, buf, copy_size); @@ -992,7 +1025,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ } if (remain_size) { - //printk("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,remain_size); + //pr_info("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,remain_size); copy_to_framebuffer (linebuf, buf, remain_size); @@ -1008,7 +1041,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ frame_remain_size; while (frame_remain_size >= copy_size) { - //printk("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,copy_size); + //pr_info("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,copy_size); copy_to_framebuffer (linebuf, buf, copy_size); @@ -1038,7 +1071,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ } if (frame_remain_size) { - //printk("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,remain_size); + //pr_info("%d memcpy %ld(%d) size %d\n",__LINE__,linebuf-framebuf,(linebuf-framebuf)/bytesperline,remain_size); copy_to_framebuffer (linebuf, buf, remain_size); @@ -1060,7 +1093,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ vbuf_info); if (pframebuf_info-> vbuf_info == NULL) { - printk + pr_info ("No video buffer to receive\n"); break; } else { @@ -1073,7 +1106,7 @@ void v4l2_model_feed_video_data(v4l2_model_handle_t context, void *buffer, SIZE_ vbuf_info-> buf_info [0]->addr; - //printk("framebuf change to %p\n",framebuf); + //pr_info("framebuf change to %p\n",framebuf); linebuf = framebuf; frame_remain_size @@ -1099,7 +1132,7 @@ void v4l2_model_streamoff(v4l2_model_handle_t context) { v4l2_model_context_t *v4l2m_context = (v4l2_model_context_t *) context; - printk("%s\n", __func__); + pr_info("%s\n", __func__); vb2_streamoff(&v4l2m_context->queue, V4L2_BUF_TYPE_VIDEO_CAPTURE); diff --git a/insmod.sh b/insmod.sh index 2610fa0..e310e3b 100755 --- a/insmod.sh +++ b/insmod.sh @@ -1,10 +1,12 @@ -#!/bin/sh +#!/bin/bash + +SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) + modprobe snd modprobe snd-pcm -modprobe videobuf2-core modprobe videobuf2-dma-contig modprobe videobuf2-dma-sg modprobe videobuf2-v4l2 modprobe videobuf2-vmalloc modprobe videodev -insmod cx511h.ko +insmod driver/gc573.ko no_signal_pic="$SCRIPT_DIR/driver/aver_custom_no_signal.bmp" copy_protection_pic="$SCRIPT_DIR/driver/aver_custom_copy_protection.bmp" out_of_range_pic="$SCRIPT_DIR/driver/aver_custom_out_of_range.bmp" diff --git a/install.sh b/install.sh index e4ce1c0..5c08bcb 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,14 @@ #echo "Please boot to correct kernel version then install again. Thanks" #exit #fi + MODULE_INSTALL_DIR=/lib/modules/`uname -r`/kernel/drivers/media/avermedia install -d $MODULE_INSTALL_DIR -install -m 644 cx511h.ko $MODULE_INSTALL_DIR +install -m 644 driver/gc573.ko $MODULE_INSTALL_DIR +install -m 644 driver/aver_custom_copy_protection.bmp $MODULE_INSTALL_DIR +install -m 644 driver/aver_custom_no_signal.bmp $MODULE_INSTALL_DIR +install -m 644 driver/aver_custom_out_of_range.bmp $MODULE_INSTALL_DIR + +echo "options gc573 no_signal_pic=\"$MODULE_INSTALL_DIR/aver_custom_no_signal.bmp\" out_of_range_pic=\"$MODULE_INSTALL_DIR/aver_custom_out_of_range.bmp\" copy_protection_pic=\"$MODULE_INSTALL_DIR/aver_custom_copy_protection.bmp\"" > /etc/modprobe.d/gc573.conf + /sbin/depmod -a