This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM3894 insert vpss.ko fail

Other Parts Discussed in Thread: AM3894, TVP7002

AM3894 insert vpss.ko fail

==============================

EZSDK: ti-ezsdk_dm816x-evm_5_04_00_11

PSP:   linux-2.6.37-psp04.04.00.01

setenv bootargs 'console=ttyO0,115200n8 root=/dev/nfs nfsroot=192.168.1.102:/home/yulq/targetfs/ init=/linuxrc mem=256M ip=192.168.1.205 eth0 VRAM=50M notifyk.vpssm3_sva=0xA0000000'

 [root@shineway/]# insmod /home/root/syslink.ko                                 

SysLink version : 2.10.02.17                                                   

SysLink module created on Date:Sep 12 2012 Time:22:21:41                       

[root@shineway/]#                                                                                                              

[root@shineway/]# /usr/bin/firmware_loader 2 /usr/share/ti/ti-media-controller-utils/dm816x_hdvpss.xem3 start -i2c 0                                           

FIRMWARE: Memory map bin file not passed                                       

Usage : firmware_loader <Processor Id> <Location of Firmware> <start|stop> [-mma

p <memory_map_file>] [-i2c <0|1>]                                              

===Mandatory arguments===                                                      

<Processor Id>         0: DSP, 1: Video-M3, 2: Vpss-M3                         

<Location of Firmware> firmware binary file                                    

<start|stop>           to start/stop the firmware                              

===Optional arguments===                                                       

-mmap                  input memory map bin file name                          

-i2c                   0: i2c init not done by M3, 1(default): i2c init done by M3                                                                             

FIRMWARE: isI2cInitRequiredOnM3: 0                                              

FIRMWARE: Default memory configuration is used                                 

MemCfg: DCMM (Dynamically Configurable Memory Map) Version :  2.1.2.1          

FIRMWARE: Memory Configuration status : In Progress                             

FIRMWARE: 2 start Successful                                                   

[root@shineway/]#                                                            

[root@shineway/]# insmod /lib/modules/2.6.37/kernel/drivers/video/ti81xx/vpss/vpss.ko debug=1 sbufaddr=0xBFB00000 clksrc=dvo2:aclk mode=dvo2:800x480@60        

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                   

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                            

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                   

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                            

notify_send_event failed! status = 0xfffffff0                                  

notify_shm_drv_sendevent failed! status = 0xfffffff0                           

notify_send_event failed! status = 0xfffffff0                                   

VPSS_CORE : Failed to init fvid2 interface,                                    

vpss: probe of vpss failed with error -22                                      

VPSS_CORE : failed to register ti81xx-vpss driver                              

insmod: error inserting '/lib/modules/2.6.37/kernel/drivers/video/ti81xx/vpss/vpss.ko': -1 No such device                                                      

[root@shineway/]#             

 

How to solve this problem and what reason cause it ?

 

Thanks.

  • Hello,


    Please try to change the bootargs.

    Instead of:

    notifyk.vpssm3_sva=0xA0000000


    try:

    notifyk.vpssm3_sva=0xBF900000


    BR

    Vladimir

  • Ok, changing

    notifyk.vpssm3_sva=0xBF900000, the problem is been solved. Thanks for your advice.

    In TI81xx_VPSS_Video_Driver_User_Guide, the given value is

    notifyk.vpssm3_sva=0xA0000000, maybe there is someting wrong.

  • Hi,

    Value is correct if you load binary provided with PSP. Value changes based on memory map and there is change in memory map between PSP and the ESDK. Thats why i told simply replacing binary provided by PSP with EZSDK binary will not make it work, you need to change bootargs to what is given in EZSDK.

  • Hi Hardik Shah,

    I'm using TI DM8168 processor in our platform, ADV7182 as a decoder instead of TVP7002 decoder. I changed ti81xx_vpss.c file and ti81xxvin_main.c file for ADV7182, attached the same.

    I'm running below sequence of commands before running saLoopBack application to capture input data.

    setenv bootargs 'notifyk.vpssm3_sva=0xA0000000'

    #: insmod /lib/modules/2.6.37/kernel/drivers/dsp/syslink.ko
    #: ./slaveloader startup VPSS-M3 ti816x_hdvpss.xem3
    #: insmod /lib/modules/2.6.37/kernel/drivers/video/ti81xx/vpss/vpss.ko sbufaddr=0xA0200000 sbufsize=2048K
    #: insmod /lib/modules/2.6.37/kernel/drivers/video/ti81xx/ti81xxfb/ti81xxfb.ko
    #: insmod /lib/modules/2.6.37/kernel/drivers/media/video/ti81xx/ti81xxvo.ko

    #: insmod /lib/modules/2.6.37/kernel/drivers/media/video/adv7182.ko
    #: insmod /lib/modules/2.6.37/kernel/drivers/media/video/ti81xx/ti81xxvin.ko

    #: /etc/init.d/pvr-init stop
    #: /etc/init.d/matrix-gui-e stop
    #: /etc/init.d/load-hd-firmware.sh stop

    saLoopBack.c file I changed to capture input data into a file. Attached the same

    When I run saloopback appliaction I'm able to capture data into file but when I run this file using vooya player I'm getting only green color, when I checked this file using "od - x file.yuv" command only 0s are there. Can you tell me what may be the problem, what wrong I'm doing.

    /* saLoopBack.c
     *
     * Copyright (C) 2011 TI
     * Author: Hardik Shah <hardik.shah@ti.com>
     *
     * This is a sample for loopback application. This application captures through
     * V4L2 capture driver on TVP7002 input and displays the captured content
     * on the V4L2 display driver. Application uses userpointer mechanism for
     * both capture and display drivers. Buffers for the userpointer are taken from
     * framebuffer driver (fbdev).
     *
     * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
    */
    
    /*
     * Header File Inclusion
     */
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <sys/mman.h>
    #include <sys/time.h>
    #include <errno.h>
    #include <string.h>
    #include <linux/videodev2.h>
    #include <linux/fb.h>
    #include <linux/ti81xxfb.h>
    #include <linux/ti81xxhdmi.h>
    #include <linux/ti81xxvin.h>
    
    /* Number of buffers required for application. Less that this may cause
     * considerable frame drops
     */
    //#define MAX_BUFFER			8
    #define MAX_BUFFER			4
    
    
    /* device node to be used for capture */
    #define CAPTURE_DEVICE		"/dev/video0"
    #define CAPTURE_NAME		"Capture"
    /* device node to be used for display */
    #define DISPLAY_DEVICE		"/dev/video1"
    #define DISPLAY_NAME		"Display"
    /* number of frames to be captured and displayed
     * Increase this for long runs
     */
    #define MAXLOOPCOUNT		100
    
    /* Pixel format for capture and display. Capture supports
     * V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV16, V4L2_PIX_FMT_RGB24 but display
     * supports only V4L2_PIX_FMT_YUYV. So this has to be V4L2_PIX_FMT_YUYV
     */
    #define DEF_PIX_FMT		V4L2_PIX_FMT_YUYV
    
    /* Application name */
    #define APP_NAME		"saLoopBack"
    
    /* Define below #def for debug information enable */
    #undef SALOOPBACK_DEBUG
    
    #define WIDTH 720
    #define HEIGHT 480
    
    
    v4l2_std_id g_current_std = V4L2_STD_NTSC;
    /* Structure for storing buffer information */
    struct buf_info {
    	int index;
    	unsigned int length;
    	char *start;
    };
    
    /* Structure for storing application data like file pointers, format etc. */
    struct app_obj {
    	int fd;
    	struct v4l2_capability cap;
    	struct v4l2_format fmt;
    	struct v4l2_dv_preset dv_preset;
    	struct v4l2_input input;
    	struct v4l2_requestbuffers reqbuf;
    	int numbuffers;
    	struct v4l2_buffer buf;
    	struct ti81xxvin_overflow_status over_flow;
    };
    
    /* Globals for capture and display application objects */
    struct app_obj disp, capt;
    
    /* File pointer for fbdev. fbdev is only used to get buffers
     */
    static int fbdev_fd;
    
    /* Pointers for storing buffer addresses */
    unsigned char *buffer_addr[MAX_BUFFER];
    
    static struct buf_info capture_buff_info[MAX_BUFFER];
    
    /* Utility function for printing format */
    static void printFormat(char *string, struct v4l2_format *fmt)
    {
    	printf("=============================================================\n");
    	printf("%s Format:\n", string);
    	printf("=============================================================\n");
    	printf("fmt.type\t\t = %d\n", fmt->type);
    	printf("fmt.width\t\t = %d\n", fmt->fmt.pix.width);
    	printf("fmt.height\t\t = %d\n", fmt->fmt.pix.height);
    	printf("fmt.pixelformat\t = %d\n", fmt->fmt.pix.pixelformat);
    	printf("fmt.bytesperline\t = %d\n", fmt->fmt.pix.bytesperline);
    	printf("fmt.sizeimage\t = %d\n", fmt->fmt.pix.sizeimage);
    	printf("=============================================================\n");
    }
    /* Open and query dv preset for capture driver*/
    static int initCapture(void)
    {
    	int mode = O_RDWR;
            int input_index = 0;
    	/* Open capture driver */
    	capt.fd = open((const char *)CAPTURE_DEVICE, mode);
    	if (capt.fd == -1) {
    		printf("failed to open capture device\n");
    		return -1;
    	}
    	
    #if 1 /* Add for TVP5150 Testing */
    	/* Get any active input */
    	if (ioctl(capt.fd, VIDIOC_G_INPUT, &input_index) < 0) {
    		printf("VIDIOC_G_INPUT");
    		return -1;
    	}
    
    	/* Enumerate input to get the name of the input detected */
    	memset(&capt.input, 0, sizeof(capt.input));
    	capt.input.index = input_index;
    	if (ioctl(capt.fd, VIDIOC_ENUMINPUT, &capt.input) < 0) {
    		printf("VIDIOC_ENUMINPUT");
    		return -1;
    	}
    
    	printf("%s: Current Input: %s\n", CAPTURE_NAME, capt.input.name);
    #if 0
    	v4l2_std_id std;
    	struct v4l2_standard standard;
    	/* Detect the standard in the input detected */
    	if (ioctl(capt.fd, VIDIOC_QUERYSTD, &std) < 0) {
    		perror("VIDIOC_QUERYSTD");
    		return -1;
    	}
    
    	while (1) 
    	{
    		standard.index = i;
    		ret = ioctl(capt.fd, VIDIOC_ENUMSTD, &standard);
    		if(ret < 0)
    			break;
    
    		if (standard.id & std) 
    		{
    		    printf("%s: Standard Detected = %s\n",
    			   CAPTURE_NAME, standard.name);
    		    break;
    		}
    		i++;
    	}
    #endif
    	v4l2_std_id current_std;
    	if (ioctl(capt.fd, VIDIOC_G_STD, &current_std) < 0) {
    		printf("VIDIOC_G_STD");
    		//return -1;
    	}
    
    	const v4l2_std_id std = V4L2_STD_NTSC;
    	/* Detect the standard in the input detected */
    	if (ioctl(capt.fd, VIDIOC_S_STD, &std) < 0) {
    		printf("VIDIOC_S_STD");
    		//return -1;
    	}
    
    	if (ioctl(capt.fd, VIDIOC_G_STD, &current_std) < 0) {
    		printf("VIDIOC_G_STD");
    		//return -1;
    	}
    
    	if(current_std != V4L2_STD_NTSC)
    		printf("NTSC Standard was not set!\n");
    #endif
            if(ioctl(capt.fd, VIDIOC_S_INPUT, &input_index)) {
                    printf("VIDIOC_S_INPUT failed\n");
                    exit(2);
            }
    	/* Query for capabilities */
    	memset(&capt.cap, 0, sizeof(capt.cap));
    	if (ioctl(capt.fd, VIDIOC_QUERYCAP, &capt.cap)) {
    		printf("Query capability failed\n");
    		exit(2);
    	} else 	{
    		printf("Driver Name: %s\n", capt.cap.driver);
    		printf("Driver bus info: %s\n", capt.cap.bus_info);
    		if (capt.cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)
    			printf("Driver is capable of doing capture\n");
    		if (capt.cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
    			printf("Driver is capabled of scaling and cropping\n");
    
    	}
    #if 0
    	system("echo 0 > /sys/devices/platform/vpss/display0/enabled");
    	/* Query the preset. Set it to invalid and query for it */
    	capt.dv_preset.preset = 0x0;
    	if (ioctl(capt.fd, VIDIOC_QUERY_DV_PRESET, &capt.dv_preset)) {
    		printf("Querying DV Preset failed\n");
    		exit(2);
    	}
    	switch (capt.dv_preset.preset) {
    	case V4L2_DV_720P60:
    		printf("%s:\n Mode set is 720P60\n", APP_NAME);
    		system ("echo 720p-60 > /sys/devices/platform/vpss/display0/mode");
    		break;
    	case V4L2_DV_1080I60:
    		printf("%s:\n Mode set is 1080I60\n", APP_NAME);
    		system ("echo 1080i-60 > /sys/devices/platform/vpss/display0/mode");
    		break;
    	case V4L2_DV_1080P60:
    		printf("%s:\n Mode set is 1080P60\n", APP_NAME);
    		system ("echo 1080p-60 > /sys/devices/platform/vpss/display0/mode");
    		break;
    	case V4L2_DV_1080P30:
    		printf("%s:\n Mode set is 1080P30\n", APP_NAME);
    		system ("echo 1080p-30 > /sys/devices/platform/vpss/display0/mode");
    		break;
    	default:
    		printf("%s:\n Mode set is %d\n", APP_NAME, capt.dv_preset.preset);
    	}
    	if (ioctl(capt.fd, VIDIOC_S_DV_PRESET, &capt.dv_preset)) {
    		printf("Setting DV Preset failed\n");
    		exit(2);
    	}
    	system("echo 1 > /sys/devices/platform/vpss/display0/enabled");i
    #endif
    	return 0;
    }
    /* Open display driver and set format according to resolution on capture */
    static int initDisplay(void)
    {
    	int mode = O_RDWR;
    	struct v4l2_capability cap;
    
    	/* Open display driver */
    	disp.fd = open((const char *)DISPLAY_DEVICE, mode);
    	if (disp.fd == -1) {
    		printf("failed to open display device\n");
    		return -1;
    	}
    	/* Query driver capability */
    	if (ioctl(disp.fd, VIDIOC_QUERYCAP, &disp.cap)) {
    		printf("Query capability failed for display\n");
    		exit(2);
    	}  else {
    		printf("Driver Name: %s\n", cap.driver);
    		printf("Driver bus info: %s\n", cap.bus_info);
    		if (cap.capabilities & V4L2_CAP_VIDEO_OUTPUT)
    			printf("Driver is capable of doing capture\n");
    		if (cap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
    			printf("Driver is capabled of scaling and cropping\n");
    
    	}
    	return 0;
    }
    /* Setup capture driver */
    int setupCapture(void)
    {
    	int ret;
    
    	/* Get current format */
    	capt.fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    #if 0
    	ret = ioctl(capt.fd, VIDIOC_G_FMT, &capt.fmt);
    	if (ret < 0) {
    		printf("Set Format failed\n");
    		return -1;
    	}
    	/* Set format according to mode detected */
    	if (capt.dv_preset.preset == V4L2_DV_720P60) {
    		capt.fmt.fmt.pix.width = 1280;
    		capt.fmt.fmt.pix.height = 720;
    	} else if (capt.dv_preset.preset == V4L2_DV_1080P60) {
    		capt.fmt.fmt.pix.width = 1920;
    		capt.fmt.fmt.pix.height = 1080;
    	}  else {
    		capt.fmt.fmt.pix.width = 1920;
    		capt.fmt.fmt.pix.height = 1080;
    	}
    #endif
    	capt.fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
            capt.fmt.fmt.pix.width = 720 ;
    	capt.fmt.fmt.pix.height = 480;
    	capt.fmt.fmt.pix.bytesperline = capt.fmt.fmt.pix.width * 2;
    	capt.fmt.fmt.pix.sizeimage = capt.fmt.fmt.pix.bytesperline *
    		capt.fmt.fmt.pix.height;
    	capt.fmt.fmt.pix.colorspace = V4L2_COLORSPACE_REC709;
    	capt.fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
    	ret = ioctl(capt.fd, VIDIOC_S_FMT, &capt.fmt);
    	if (ret < 0) {
    		printf("Set Format failed\n");
    		return -1;
    	}
    	/* Get format again and print it on console */
    	capt.fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	ret = ioctl(capt.fd, VIDIOC_G_FMT, &capt.fmt);
    	if (ret < 0) {
    		printf("Set Format failed\n");
    		return -1;
    	}
    	printFormat("Capture", &capt.fmt);
    
    	/* Request buffers. We are operating in userPtr mode */
    	capt.reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    	capt.reqbuf.count = MAX_BUFFER;
    	capt.reqbuf.memory = V4L2_MEMORY_USERPTR;
    	//capt.reqbuf.memory = V4L2_MEMORY_MMAP;
    	ret = ioctl(capt.fd, VIDIOC_REQBUFS, &capt.reqbuf);
    	if (ret < 0) {
    		printf("Could not allocate the buffers\n");
    		return -1;
    	}
            printf("\n capt.reqbuf.count = %d\n",capt.reqbuf.count);
    	return 0;
    }
    
    /* Setup display driver */
    int setupDisplay(void)
    {
    	int ret;
    
    	/* Get format */
    	disp.fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    	ret = ioctl(disp.fd, VIDIOC_G_FMT, &disp.fmt);
    	if (ret < 0) {
    		printf("Get Format failed\n");
    		return -1;
    	}
    	/* Set format according to display mode */
    	if (capt.dv_preset.preset == V4L2_DV_720P60) {
    		disp.fmt.fmt.pix.width = 1280;
    		disp.fmt.fmt.pix.height = 720;
    	} else if (capt.dv_preset.preset == V4L2_DV_1080P60) {
    		disp.fmt.fmt.pix.width = 1920;
    		disp.fmt.fmt.pix.height = 1080;
    	}  else {
    		disp.fmt.fmt.pix.width = 1920;
    		disp.fmt.fmt.pix.height = 1080;
    	}
    	disp.fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
    	disp.fmt.fmt.pix.bytesperline = disp.fmt.fmt.pix.width * 2;
    	disp.fmt.fmt.pix.sizeimage = disp.fmt.fmt.pix.bytesperline *
    		disp.fmt.fmt.pix.height;
    	ret = ioctl(disp.fd, VIDIOC_S_FMT, &disp.fmt);
    	if (ret < 0) {
    		printf("Set Format failed\n");
    		return -1;
    	}
    	/* Get format again and display it on console */
    	disp.fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    	ret = ioctl(disp.fd, VIDIOC_G_FMT, &disp.fmt);
    	if (ret < 0) {
    		printf("Get Format failed for display\n");
    		return -1;
    	}
    	printFormat("Display", &disp.fmt);
    	/* Requests buffers, we are operating in userPtr mode */
    	disp.reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    	disp.reqbuf.count = MAX_BUFFER;
    	disp.reqbuf.memory = V4L2_MEMORY_USERPTR;
    	ret = ioctl(disp.fd, VIDIOC_REQBUFS, &disp.reqbuf);
    	if (ret < 0) {
    		perror("Could not allocate the buffers\n");
    		return -1;
    	}
    	return 0;
    }
    /* Stop capture */
    static int stopCapture(void)
    {
    
    	/* Stop capture */
    	int a = V4L2_BUF_TYPE_VIDEO_CAPTURE, ret;
    	ret = ioctl(capt.fd, VIDIOC_STREAMOFF, &a);
    	if (ret < 0) {
    		perror("VIDIOC_STREAMOFF\n");
    		return -1;
    	}
    	return 0;
    }
    /* Stop display */
    static int stopDisplay(void)
    {
    	int a = V4L2_BUF_TYPE_VIDEO_OUTPUT, ret;
    	ret = ioctl(disp.fd, VIDIOC_STREAMOFF, &a);
    	if (ret < 0) {
    		perror("VIDIOC_STREAMOFF\n");
    		return -1;
    	}
    	return 0;
    }
    /* Start display */
    static int startDisplay(void)
    {
    	int a = V4L2_BUF_TYPE_VIDEO_OUTPUT, ret;
    	ret = ioctl(disp.fd, VIDIOC_STREAMON, &a);
    	if (ret < 0) {
    		perror("VIDIOC_STREAMON\n");
    		return -1;
    	}
    	return 0;
    }
    /* Start capture */
    static int startCapture(void)
    {
    	int a = V4L2_BUF_TYPE_VIDEO_CAPTURE, ret;
    	ret = ioctl(capt.fd, VIDIOC_STREAMON, &a);
    	if (ret < 0) {
    		perror("VIDIOC_STREAMON\n");
    		printf("******************* VIDIOC_STREAMON\n");
    		return -1;
    	}
    	return 0;
    }
    /* Start display */
    static int deInitCapture(void)
    {
    	if (close(capt.fd))
    		return -1;
    	return 0;
    }
    
    /* Close display */
    static int deInitDisplay(void)
    {
    	if (close(disp.fd))
    		return -1;
    	return 0;
    }
    
    /* Get fix screeninfo on fbdev */
    static int get_fixinfo(struct fb_fix_screeninfo *fixinfo)
    {
    	int ret;
    	ret = ioctl(fbdev_fd, FBIOGET_FSCREENINFO, fixinfo);
    	if (ret < 0) {
    		perror("Error reading fixed information.\n");
    		return ret;
    	}
    #ifdef SALOOPBACK_DEBUG
    	printf("\nFix Screen Info:\n");
    	printf("----------------\n");
    	printf("Line Length - %d\n", fixinfo->line_length);
    	printf("Physical Address = %lx\n", fixinfo->smem_start);
    	printf("Buffer Length = %d\n", fixinfo->smem_len);
    #endif
    	return 0;
    }
    /* Get variable screeninfo on FBDEV */
    static int get_varinfo(struct fb_var_screeninfo *varinfo)
    {
    	int ret;
    
    	ret = ioctl(fbdev_fd, FBIOGET_VSCREENINFO, varinfo);
    	if (ret < 0) {
    		perror("Error reading variable information.\n");
    		return ret;
    	}
    #ifdef SALOOPBACK_DEBUG
    	printf("\nVar Screen Info:\n");
    	printf("----------------\n");
    	printf("Xres - %d\n", varinfo->xres);
    	printf("Yres - %d\n", varinfo->yres);
    	printf("Xres Virtual - %d\n", varinfo->xres_virtual);
    	printf("Yres Virtual - %d\n", varinfo->yres_virtual);
    	printf("nonstd       - %d\n", varinfo->nonstd);
    	printf("Bits Per Pixel - %d\n", varinfo->bits_per_pixel);
    	printf("blue lenth %d msb %d offset %d\n",
    			varinfo->blue.length,
    			varinfo->blue.msb_right,
    			varinfo->blue.offset);
    	printf("red lenth %d msb %d offset %d\n",
    			varinfo->red.length,
    			varinfo->red.msb_right,
    			varinfo->red.offset);
    	printf("green lenth %d msb %d offset %d\n",
    			varinfo->green.length,
    			varinfo->green.msb_right,
    			varinfo->green.offset);
    	printf("trans lenth %d msb %d offset %d\n",
    			varinfo->transp.length,
    			varinfo->transp.msb_right,
    			varinfo->transp.offset);
    #endif
    	return 0;
    
    }
    /* We derive buffers from fbdev for userpointer operation.
     * We have to setupBuffers
     * fbdev to get enough number of buffers and with enough size
     *
     */
    static int setupBuffers(void)
    {
    	struct fb_fix_screeninfo fixinfo;
    	struct fb_var_screeninfo varinfo, org_varinfo;
    	int ret;
    	int buffersize;
    	int i;
    
    	/*Open FB device*/
    	capt.fd = open("/dev/fb0", O_RDWR);
    	if (fbdev_fd <= 0) {
    		perror("Could not open fb device\n");
    		return -1;
    	}
    	/* Get fix screen information. Fix screen information gives
    	 * fix information like panning step for horizontal and vertical
    	 * direction, line length, memory mapped start address and length etc.
    	 */
    	if (get_fixinfo(&fixinfo)) {
    		perror("Could not get fixed screen info\n");
    		return -1;
    	}
    	/* Get variable screen information. Variable screen information
    	 * gives informtion like size of the image, bites per pixel,
    	 * virtual size of the image etc. */
    	if (get_varinfo(&varinfo)) {
    		perror("getting variable screen info failed\n");
    		return -1;
    	}
    	/*store the original information*/
    	memcpy(&org_varinfo, &varinfo, sizeof(varinfo));
    
    	/*
    	 * Set the resolution which read before again to prove the
    	 * FBIOPUT_VSCREENINFO ioctl, except virtual part which is required for
    	 * panning.
    	 */
    	varinfo.xres = 720;//disp.fmt.fmt.pix.width;
    	varinfo.yres = 480;//disp.fmt.fmt.pix.height;
    	varinfo.xres_virtual = varinfo.xres;
    	varinfo.yres_virtual = varinfo.yres * MAX_BUFFER;
    	varinfo.bits_per_pixel = 16;
    	varinfo.transp.offset = 0;
    	varinfo.transp.length = 0;
    	varinfo.transp.msb_right = 0;
    	varinfo.red.offset = 16;
    	varinfo.red.length = 5;
    	varinfo.blue.offset = 0;
    	varinfo.blue.length = 5;
    	varinfo.green.offset = 8;
    	varinfo.green.length = 6;
    
    	ret = ioctl(capt.fd, FBIOPUT_VSCREENINFO, &varinfo);
    	if (ret < 0) {
    		perror("Error writing variable information.\n");
    		return -1;
    	}
    	if (get_varinfo(&varinfo)) {
    		perror("Error getting variable screen information\n");
    		return -1;
    	}
    	/* It is better to get fix screen information again. its because
    	 * changing variable screen info may also change fix screen info. */
    	ret = ioctl(capt.fd, FBIOGET_FSCREENINFO, &fixinfo);
    	if (ret < 0) {
    		perror("Error reading fixed information.\n");
    		return -1;
    	}
    
    	/* Get fix screen information. Fix screen information gives
    	 * fix information like panning step for horizontal and vertical
    	 * direction, line length, memory mapped start address and length etc.
    	 */
    	if (get_fixinfo(&fixinfo)) {
    		perror("Getting fixed screen info failed\n");
    		return -1;
    	}
    	/* Mmap the driver buffers in application space so that application
    	 * can write on to them. Driver allocates contiguous memory for
    	 * three buffers. These buffers can be displayed one by one. */
    	buffersize = fixinfo.line_length * varinfo.yres;
    	buffer_addr[0] = (unsigned char *)mmap(0,
    			buffersize *  MAX_BUFFER,
    			(PROT_READ | PROT_WRITE),
    			MAP_SHARED, capt.fd, 0);
    	for (i = 1; i < MAX_BUFFER; i++)
    		buffer_addr[i] = buffer_addr[i-1] + buffersize;
    
    	memset(buffer_addr[0], 0xFF, buffersize * MAX_BUFFER);
    	return 0;
    }
    /* Prime capture buffers */
    static int queueCaptureBuffers(void)
    {
            int ret, i;
    	for (i = 0; i < MAX_BUFFER; i++) {
                    buffer_addr[i] = malloc(sizeof(char) * capt.fmt.fmt.pix.sizeimage);
    		capt.buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		capt.buf.memory = V4L2_MEMORY_USERPTR;
    		capt.buf.index = i;
    		capt.buf.m.userptr = (unsigned long)buffer_addr[capt.buf.index];
    		capt.buf.length = capt.fmt.fmt.pix.sizeimage;
    		ret = ioctl(capt.fd, VIDIOC_QBUF, &capt.buf);
    		if (ret < 0) {
    			perror("VIDIOC_QBUF\n");
    			return -1;
    		}
    	}
    #if 0
    	int ret, i;
            struct v4l2_buffer buf;
            for (i = 0; i < MAX_BUFFER; i++) {
    		buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		buf.index = i;
    		buf.memory = V4L2_MEMORY_MMAP;
    		ret = ioctl(capt.fd, VIDIOC_QUERYBUF, &buf);
    		if (ret < 0) {
    			printf("\nVIDIOC_QUERYCAP");
    			return -1;
    		}
    #if 1        
                    printf("\n buf.length = %d\n",buf.length);
                    printf("\n index = %d\n",i); 
                    printf("\n Offset = %x\n",buf.m.offset);
    #endif
                    capture_buff_info[i].length = buf.length;
    		capture_buff_info[i].index = i;
    		capture_buff_info[i].start = mmap(NULL, buf.length,
    				PROT_READ |
    				PROT_WRITE,
    				MAP_SHARED,
    				capt.fd,
    				buf.m.offset);
    
    		if (capture_buff_info[i].start < 0) {
    			printf("Cannot mmap = %d \n", i);
    			return -1;
    		}
    
    		//memset((void *) capture_buff_info[i].start, 0x00,
    		//		capture_buff_info[i].length);
    
    		//capt.buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    		//capt.buf.memory = V4L2_MEMORY_MMAP;
    		//capt.buf.index = i;
    		//capt.buf.length = capt.fmt.fmt.pix.sizeimage;
    		ret = ioctl(capt.fd, VIDIOC_QBUF, &buf);
    		if (ret < 0) {
    			perror("VIDIOC_QBUF\n");
    			return -1;
    		}
    	}
    #endif
    	return ret;
    }
    /* Prime display buffers */
    static int queueDisplayBuffers(void)
    {
    	int ret, i;
    	for (i = (MAX_BUFFER / 2); i < MAX_BUFFER; i++) {
    		disp.buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    		disp.buf.memory = V4L2_MEMORY_USERPTR;
    		disp.buf.index = i - (MAX_BUFFER / 2);
    		disp.buf.m.userptr = (unsigned long)buffer_addr[i];
    		disp.buf.length = capt.fmt.fmt.pix.sizeimage;
    		ret = ioctl(disp.fd, VIDIOC_QBUF, &disp.buf);
    		if (ret < 0) {
    			perror("VIDIOC_QBUF\n");
    			return -1;
    		}
    	}
    	return 0;
    }
    /* This is a utility function to calculate time  between start and stop. This
     * is used to calculate FPS
     */
    static int calc_result_time(struct timeval *result, struct timeval *after,
    		struct timeval *before)
    {
    	/* Perform the carry for the later subtraction by updating "before" */
    	if (after->tv_usec < before->tv_usec) {
    		int nsec = (before->tv_usec - after->tv_usec) / 1000000 + 1;
    		before->tv_usec -= 1000000 * nsec;
    		before->tv_sec += nsec;
    	}
    	if (after->tv_usec - before->tv_usec > 1000000) {
    		int nsec = (after->tv_usec - before->tv_usec) / 1000000;
    
    		before->tv_usec += 1000000 * nsec;
    		before->tv_sec -= nsec;
    	}
    	/* Compute the time remaining to wait, tv_usec is certainly positive.
    	 * */
    	result->tv_sec = after->tv_sec - before->tv_sec;
    	result->tv_usec = after->tv_usec - before->tv_usec;
    	/* Return 1 if result is negative. */
    	return after->tv_sec < before->tv_sec;
    }
    /* Main function */
    int main(int argc, char *argv[])
    {
    	int i = 0, ret = 0;
    	struct v4l2_buffer temp_buf;
    	struct timeval before, after, result;
    #if 1
            FILE *fptr = NULL;
    
    	if ((fptr = fopen("file.yuv", "w")) < 0){
                    printf("Unable to create y frame recording file\n");
                    return -1;
                    }
    #endif
    	/* Divert fbdev to dvo2 so that it does  not do blending with display*/
    	//system ("echo 1:dvo2 > /sys/devices/platform/vpss/graphics0/nodes");
    	/* Open the capture driver. Query the resolution from the capture driver
    	 */
    	ret = initCapture();
    	if (ret < 0) {
    		printf("Error in opening capture device for channel 0\n");
    		return ret;
    	}
    #if 0
    	/* Open the Display driver. */
    	ret = initDisplay();
    	if (ret < 0) {
    		printf("Error in opening display device for channel 0\n");
    		return ret;
    	}
    #endif
    restart:
    	/* Setup the capture driver Step includes
    	 * Set the format according to the resolution queried.
    	 * request for buffer descriptors for userpointer buffers
    	 */
    	ret = setupCapture();
    	if (ret < 0) {
    		printf("Error in setting up of capture\n");
    		return ret;
    	}
    
    	/* Setup the display driver Step includes
    	 * Set the format according to the resolution queried by capture.
    	 * request for buffer descriptors for userpointer buffers
    	 */
    #if 0
    	ret = setupDisplay();
    	if (ret < 0) {
    		printf("Error in setting up of Display\n");
    		return ret;
    	}
    #endif
    	/* As application works on userPointer, Buffers for both capture and
    	 * display driver are allocated using the fbdev, buffers. Below functionality
    	 * setups the fbdev to mmap the buffers and later capture and display
    	 * will use those buffers
    	 */
    #if 0
    	ret = setupBuffers();
    	if (ret < 0) {
    		printf("Error in setting up of Buffers\n");
    		return ret;
    	}
    #endif
    	/* Total 8 buffers are allocated using fbdev, 4 buffers are primed to
    	 * capture driver.
    	 */
    	ret = queueCaptureBuffers();
    	if (ret < 0) {
    		printf("Error in queuing capture buffers\n");
    		return ret;
    	}
    
    //v4l2_std_id id;
    
    /*	 if (ioctl(capt.fd, VIDIOC_G_STD, &id) < 0)
             {
                    printf("VIDIOC_G_STD failed\n");
                    return -1;
             }*/
    	printf("-----------g_current_std 1------- %d\r\n",g_current_std);
    	g_current_std = V4L2_STD_NTSC;
            printf("-----------g_current_std 2------- %d\r\n",g_current_std);	
    	if (ioctl(capt.fd, VIDIOC_S_STD, &g_current_std) < 0)
            {
                    printf("VIDIOC_S_STD failed err:%d\n",errno);
                    return -1;
            }
    	/* Total 8 buffers are allocated using fbdev, 4 buffers are primed to
    	 * display driver.
    	 */
    #if 0
    	ret = queueDisplayBuffers();
    	if (ret < 0) {
    		printf("Error in queuing display buffers\n");
    		return ret;
    	}
    	/* Start display driver always first. This is because display driver
    	 * takes 2 frames to come out of start. If capture is started first
    	 * frame drops will be seen, since capture will already complete two
    	 * frame by time display starts
    	 */
    	ret = startDisplay();
    	if (ret < 0) {
    		printf("Error starring capture \n");
    		return ret;
    	}
    #endif
    #if 1
    	/* Start capture driver after display driver */
    	ret = startCapture();
    	if (ret < 0) {
    		printf("Error starting capture \n");
    		return ret;
    	}
    	/* Get time of day to calculate FPS */
    	gettimeofday(&before, NULL);
    	/* Start the steady state loop. Following steps are followed
    	 * 1 dequeue buffer from capture
    	 * 2 dequeue buffer from display
    	 * 3 exchange capture and display buffer pointers
    	 * 4 queue dislay buffer pointer to capture
    	 * 5 queue capture buffer pointer to display
    	 */
            printf("VIDIOC_DQBUF----------------------before\r\n");	
             for (i = 0; i < MAXLOOPCOUNT; i++)
             //for (i = 0; i < 2; i++)
             {
    	        printf("VIDIOC_DQBUF-------- inside for loop\r\n");	
    		/* Dq capture buffer */
    		ret = ioctl(capt.fd, VIDIOC_DQBUF, &capt.buf);
    		if (ret < 0) {
    			perror("VIDIOC_DQBUF\n");
    			return -1;
    		}
    			printf("-------------- &&&&&&&&&&&&&& VIDIOC_DQBUF\r\n");
    		/* Because of IP bugs, capture hardware gets locked up once in
    		 * a while. In that case DQbuf will return  V4L2_BUF_FLAG_ERROR
    		 * in flags.
    		 */
    		fwrite(buffer_addr[capt.buf.index], capt.fmt.fmt.pix.sizeimage,1, fptr); /* capture frames into a file  */      
                    if (ioctl (capt.fd, VIDIOC_QBUF, &capt.buf) < 0) {
                             perror("\nVIDIOC_QBUF failed\n");
                             break;
                        }
             }
    #if 0		
                    if (capt.buf.flags & V4L2_BUF_FLAG_ERROR) {
    			/* If DQbuf returned error check for the hardware lockup
    			 */
    			ret = ioctl(capt.fd, TICAPT_CHECK_OVERFLOW, &capt.over_flow);
    			if (ret < 0) {
    				perror("TICAPT_CHECK_OVERFLOW\n");
    				return -1;
    			} else {
    				/* If hardware locked up, restart display and
    				 * capture driver
    				 */
    				if (capt.over_flow.porta_overflow) {
    					printf("Port a overflowed\n\n\n\n\n\n\n");
    					stopCapture();
    					stopDisplay();
    					goto restart;
    
    				}
    				if (capt.over_flow.portb_overflow) {
    					printf("Port b overflowed\n\n\n\n\n\n\n");
    					stopCapture();
    					stopDisplay();
    					goto restart;
    				}
    			}
    		}
    		/* DQ display buffer */
    		ret = ioctl(disp.fd, VIDIOC_DQBUF, &disp.buf);
    		if (ret < 0) {
    			perror("VIDIOC_DQBUF Display\n");
    			return -1;
    		}
    		/* Exchange display and capture buffer pointers */
    		temp_buf.m.userptr = capt.buf.m.userptr;
    		capt.buf.m.userptr = disp.buf.m.userptr;
    		disp.buf.m.userptr = temp_buf.m.userptr;
    		/* Queue the capture buffer with updated address */
    		ret = ioctl(capt.fd, VIDIOC_QBUF, &capt.buf);
    		if (ret < 0) {
    			perror("VIDIOC_QBUF\n");
    			return -1;
    		}
    		disp.buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    		disp.buf.memory = V4L2_MEMORY_USERPTR;
    		disp.buf.length = capt.fmt.fmt.pix.sizeimage;
    		/* Queue the display buffer back with updated address */
    		ret = ioctl(disp.fd, VIDIOC_QBUF, &disp.buf);
    		if (ret < 0) {
    			perror("VIDIOC_QBUF Display\n");
    			return -1;
    		}
    		if ((i % 1000) == 0)
    			printf("Count=%d\n", i);
    #endif
    	/* Get end time to calculate FPS */
    	gettimeofday(&after, NULL);
    	/* Calculate FPS */
    	calc_result_time(&result, &after, &before);
    	printf("Result tv sec = %d\r\n", result.tv_sec);
    	printf("Frame rate = %lu\r\n", MAXLOOPCOUNT/result.tv_sec);
    	/* Stop capture driver */
    	ret = stopCapture();
    	if (ret < 0) {
    		printf("Error in stopping capture ::errno: %d\n",errno);
    		return ret;
    	}
    #if 0
    	/* Stop display driver */
    	ret = stopDisplay();
    	if (ret < 0) {
    		printf("Error in stopping display\n");
    		return ret;
    	}
    #endif
    #endif
    	/* Deinit capture driver */
    	ret = deInitCapture();
    	if (ret < 0) {
    		printf("Error in capture deInit\n");
    		return ret;
    	}
    #if 0
    	/* Deinit display driver */
    	ret = deInitDisplay();
    	if (ret < 0) {
    		printf("Error in display deInit\n");
    		return ret;
    	}
    #endif
    	//close(fbdev_fd);
    	//system("echo 0 > /sys/devices/platform/vpss/display0/enabled");
    	//system ("echo 1080p-60 > /sys/devices/platform/vpss/display0/mode");
    	//system("echo 0 > /sys/devices/platform/vpss/graphics0/enabled");
    	//system("echo 1 > /sys/devices/platform/vpss/display0/enabled");
    	//system("echo 1:hdmi > /sys/devices/platform/vpss/graphics0/nodes");
    	return 0;
    }
    
    

    0572.ti81xxvin_main.c

    /*
     nsmod /lib/modules/2.6.37/kernel/drivers/media/video/ti81xx/ti81xxvin.ko*
     * Framebuffer device registration for TI TI816x platforms
     *
     * Copyright (C) 2009 Texas Instruments Inc.
     * Author: Yihe Hu <yihehu@ti.com>
     *
     * Some code and ideas taken from TI OMAP2 Platforms
     * by Tomi Valkeinen.
     *
     * This program is free software; you can redistribute it and/or modify it
     * under the terms of the GNU General Public License as published by the
     * Free Software Foundation; either version 2 of the License, or (at your
     * option) any later version.
     *
     * This program is distributed in the hope that it will be useful, but
     * WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     * General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License along
     * with this program; if not, write to the Free Software Foundation, Inc.,
     * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     */
    #include <linux/module.h>
    #include <linux/kernel.h>
    #include <linux/mm.h>
    #include <linux/init.h>
    #include <linux/platform_device.h>
    #include <linux/bootmem.h>
    #include <linux/io.h>
    #include <linux/vps_capture.h>
    #include <linux/ti81xxfb.h>
    #include <linux/ti81xx.h>
    #include <mach/hardware.h>
    #include <mach/board-ti814x.h>
    #include <mach/board-ti816x.h>
    #include <asm/mach/map.h>
    
    //#define	CONFIG_BEL_TI8168		1
    
    #if defined(CONFIG_TI81XX_VPSS) || defined(CONFIG_TI81XX_VPSS_MODULE)
    
    static u64 ti81xx_dma_mask = ~(u32)0;
    static struct platform_device vpss_device = {
    	.name = "vpss",
    	.id = -1,
    	.dev = {
    		.platform_data = NULL,
    	},
    };
    static struct vps_platform_data vps_pdata;
    
    
    static int __init ti81xx_vpss_init(void)
    {
    	/*FIXME add platform data here*/
    	int r;
    	if (cpu_is_ti816x() || cpu_is_dm385()) {
    		if (cpu_is_dm385())
    			vps_pdata.cpu = CPU_DM813X;
    		else
    			vps_pdata.cpu = CPU_DM816X;
    		vps_pdata.numvencs = 4;
    		vps_pdata.vencmask = (1 << VPS_DC_MAX_VENC) - 1;
    	} else if (cpu_is_ti814x()) {
    		vps_pdata.cpu = CPU_DM814X;
    		vps_pdata.numvencs = 3;
    		vps_pdata.vencmask = (1 << VPS_DC_MAX_VENC) - 1 \
    					- VPS_DC_VENC_HDCOMP;
    	}
    
    	vpss_device.dev.platform_data = &vps_pdata;
    	r = platform_device_register(&vpss_device);
    	if (r)
    		printk(KERN_ERR "unable to register ti81xx_vpss device\n");
    	else
    		printk(KERN_INFO "registered ti81xx_vpss device\n");
    	return r;
    }
    
    #if defined(CONFIG_TI81XX_HDMI_MODULE) || defined(CONFIG_TI81XX_HDMI)
    
    static struct platform_device ti81xx_hdmi_plat_device = {
    	.name = "TI81XX_HDMI",
    	.id = -1,
    	.num_resources = 0,
    	.dev = {
    		/*.release = ti81xx_hdmi_platform_release,*/
    		.platform_data = NULL,
    	}
    };
    
    static int __init ti81xx_hdmi_init(void)
    {
    	int r;
    	/*FIXME add platform data here*/
    	r = platform_device_register(&ti81xx_hdmi_plat_device);
    	if (r)
    		printk(KERN_ERR "Unable to register ti81xx onchip-HDMI device\n");
    	else
    		printk(KERN_INFO "registered ti81xx on-chip HDMI device\n");
    	return r;
    }
    #else
    static int __init ti81xx_hdmi_init(void)
    {
    	return 0;
    }
    #endif
    
    #if defined(CONFIG_VIDEO_TI81XX_VIDIN_MODULE) || \
    		defined(CONFIG_VIDEO_TI81XX_VIDIN)
    
    #define HDVPSS_CAPTURE_INST0_BASE	0x48105500
    #define HDVPSS_CAPTURE_INST0_SIZE	1024u
    
    #define HDVPSS_CAPTURE_INST2_BASE	0x48105A00
    #define HDVPSS_CAPTURE_INST2_SIZE	1024u
    u8 ti81xx_card_name[] = "TI81xx_catalogue";
    #ifdef CONFIG_BEL_TI8168
    struct ti81xxvin_interface adv7182_pdata = {
        .clk_polarity = 0,
        .hs_polarity = 0,
        .vs_polarity = 1,
        .fid_polarity = 0,
        .sog_polarity = 0,
    
    };
    #else
    struct ti81xxvin_interface tvp7002_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 0,
    	.vs_polarity = 1,
    	.fid_polarity = 0,
    	.sog_polarity = 0,
    
    };
    #endif
    static struct ti81xxvin_subdev_info hdvpss_capture_sdev_info[] = {
    #ifdef CONFIG_BEL_TI8168
    #if 1
    	{
    		.name	= ADV7182_INST0,
    		.board_info = {
    			I2C_BOARD_INFO("adv7182", 0x21),
    			.platform_data = &adv7182_pdata,
    		},
    		.vip_port_cfg = {
    			//.ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_15_8,
    			.ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_7_0,
    			.ancChSel8b = VPS_VIP_ANC_CH_SEL_DONT_CARE,
    			.pixClkEdgePol = VPS_VIP_PIX_CLK_EDGE_POL_RISING,
    			.invertFidPol = 0,
    			.embConfig = {
    				.errCorrEnable = 1,
    				.srcNumPos = VPS_VIP_SRC_NUM_POS_DONT_CARE,
    				.isMaxChan3Bits = 0,
    			},
    			.disConfig = {
    				.fidSkewPostCnt = 0,
    				.fidSkewPreCnt = 0,
    				.lineCaptureStyle =
    					VPS_VIP_LINE_CAPTURE_STYLE_DONT_CARE,
    				.fidDetectMode =
    					VPS_VIP_FID_DETECT_MODE_DONT_CARE,
    				.actvidPol = VPS_VIP_POLARITY_DONT_CARE,
    				.vsyncPol =  VPS_VIP_POLARITY_DONT_CARE,
    				.hsyncPol = VPS_VIP_POLARITY_DONT_CARE,
    			}
    		},
    		.video_capture_mode =
    		   VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC,
    	//	.video_capture_mode =
    	//	   VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_DISCRETE_SYNC_HSYNC_VSYNC,
    		.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_16BIT,
    		//.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_8BIT,
    		.input_data_format = FVID2_DF_YUV422P,
    		//.input_data_format = FVID2_DF_RGB24_888,
    		//.input_data_format = FVID2_DF_YUV422I_YUYV,
    	},
    #endif
    #if 0
    	{
                    .name   = ADV7182_INST0,
                    .board_info = {
                            I2C_BOARD_INFO("adv7182", 0x21),
                            .platform_data = &adv7182_pdata,
                    },
    	{
                .ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_7_0,
                .ancChSel8b = VPS_VIP_ANC_CH_SEL_DONT_CARE,
                //.pixClkEdgePol =  VPS_VIP_PIX_CLK_EDGE_POL_FALLING,
    	    .pixClkEdgePol = VPS_VIP_PIX_CLK_EDGE_POL_RISING,
                .invertFidPol = 0,
                .embConfig = {
                    .errCorrEnable = 0,
                    .srcNumPos = VPS_VIP_SRC_NUM_POS_DONT_CARE,
                    .isMaxChan3Bits = 0,
                },
                .disConfig = {
                    .fidSkewPostCnt = 0,
                    .fidSkewPreCnt = 0,
                    .lineCaptureStyle =
                        VPS_VIP_LINE_CAPTURE_STYLE_ACTVID,
                    .fidDetectMode =
                        VPS_VIP_FID_DETECT_MODE_PIN,
                    .actvidPol = VPS_VIP_POLARITY_HIGH,
                    .vsyncPol =  VPS_VIP_POLARITY_LOW,
                    .hsyncPol = VPS_VIP_POLARITY_LOW,
                }
            },
            .video_capture_mode =
               VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_DISCRETE_SYNC_ACTVID_VSYNC,
            .video_if_mode = VPS_CAPT_VIDEO_IF_MODE_16BIT,
            .input_data_format = FVID2_DF_YUV422P,
    	},
    #endif
    	{
    		.name	= ADV7182_INST1,
    		.board_info = {
    			I2C_BOARD_INFO("adv7182", 0x20),
    			.platform_data = &adv7182_pdata,
    		},
    		.vip_port_cfg = {
    			.ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_15_8,
    			.ancChSel8b = VPS_VIP_ANC_CH_SEL_DONT_CARE,
    			.pixClkEdgePol = VPS_VIP_PIX_CLK_EDGE_POL_RISING,
    			.invertFidPol = 0,
    			.embConfig = {
    				.errCorrEnable = 1,
    				.srcNumPos = VPS_VIP_SRC_NUM_POS_DONT_CARE,
    				.isMaxChan3Bits = 0,
    			},
    			.disConfig = {
    				.fidSkewPostCnt = 0,
    				.fidSkewPreCnt = 0,
    				.lineCaptureStyle =
    					VPS_VIP_LINE_CAPTURE_STYLE_DONT_CARE,
    				.fidDetectMode =
    					VPS_VIP_FID_DETECT_MODE_DONT_CARE,
    				.actvidPol = VPS_VIP_POLARITY_DONT_CARE,
    				.vsyncPol =  VPS_VIP_POLARITY_DONT_CARE,
    				.hsyncPol = VPS_VIP_POLARITY_DONT_CARE,
    			}
    		},
    		.video_capture_mode =
    		   VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC,
    		//.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_16BIT,
    		.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_8BIT,
    		.input_data_format = FVID2_DF_YUV422P,
    		//.input_data_format = FVID2_DF_YUV422I_YUYV,
    	},
    
    #else	
    	{
    		.name	= TVP7002_INST0,
    		.board_info = {
    			/* TODO Find the correct address
    				of the TVP7002 connected */
    			I2C_BOARD_INFO("tvp7002", 0x40),
    			.platform_data = &tvp7002_pdata,
    		},
    		.vip_port_cfg = {
    			.ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_15_8,
    			.ancChSel8b = VPS_VIP_ANC_CH_SEL_DONT_CARE,
    			.pixClkEdgePol = VPS_VIP_PIX_CLK_EDGE_POL_RISING,
    			.invertFidPol = 0,
    			.embConfig = {
    				.errCorrEnable = 1,
    				.srcNumPos = VPS_VIP_SRC_NUM_POS_DONT_CARE,
    				.isMaxChan3Bits = 0,
    			},
    			.disConfig = {
    				.fidSkewPostCnt = 0,
    				.fidSkewPreCnt = 0,
    				.lineCaptureStyle =
    					VPS_VIP_LINE_CAPTURE_STYLE_DONT_CARE,
    				.fidDetectMode =
    					VPS_VIP_FID_DETECT_MODE_DONT_CARE,
    				.actvidPol = VPS_VIP_POLARITY_DONT_CARE,
    				.vsyncPol =  VPS_VIP_POLARITY_DONT_CARE,
    				.hsyncPol = VPS_VIP_POLARITY_DONT_CARE,
    			}
    		},
    		.video_capture_mode =
    		   VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC,
    		.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_16BIT,
    		.input_data_format = FVID2_DF_YUV422P,
    	},
    	{
    		.name	= TVP7002_INST1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp7002", 0x42),
    			.platform_data = &tvp7002_pdata,
    		},
    		.vip_port_cfg = {
    			.ctrlChanSel = VPS_VIP_CTRL_CHAN_SEL_15_8,
    			.ancChSel8b = VPS_VIP_ANC_CH_SEL_DONT_CARE,
    			.pixClkEdgePol = VPS_VIP_PIX_CLK_EDGE_POL_RISING,
    			.invertFidPol = 0,
    			.embConfig = {
    				.errCorrEnable = 1,
    				.srcNumPos = VPS_VIP_SRC_NUM_POS_DONT_CARE,
    				.isMaxChan3Bits = 0,
    			},
    			.disConfig = {
    				.fidSkewPostCnt = 0,
    				.fidSkewPreCnt = 0,
    				.lineCaptureStyle =
    					VPS_VIP_LINE_CAPTURE_STYLE_DONT_CARE,
    				.fidDetectMode =
    					VPS_VIP_FID_DETECT_MODE_DONT_CARE,
    				.actvidPol = VPS_VIP_POLARITY_DONT_CARE,
    				.vsyncPol =  VPS_VIP_POLARITY_DONT_CARE,
    				.hsyncPol = VPS_VIP_POLARITY_DONT_CARE,
    			}
    		},
    		.video_capture_mode =
    		   VPS_CAPT_VIDEO_CAPTURE_MODE_SINGLE_CH_NON_MUX_EMBEDDED_SYNC,
    		.video_if_mode = VPS_CAPT_VIDEO_IF_MODE_16BIT,
    		.input_data_format = FVID2_DF_YUV422P,
    	},
    #endif
    };
    
    static const struct v4l2_dv_preset hdvpss_inst0_inp0_presets[] = {
    	{
    		.preset = V4L2_DV_720P60,
    	},
    	{
    		.preset = V4L2_DV_1080I60,
    	},
    	{
    		.preset = V4L2_DV_1080P60,
    	},
    	{
    		.preset = V4L2_DV_1080P30,
    	},
    };
    
    static const struct v4l2_dv_preset hdvpss_inst2_inp0_presets[] = {
    	{
    		.preset = V4L2_DV_720P60,
    	},
    	{
    		.preset = V4L2_DV_1080I60,
    	},
    	{
    		.preset = V4L2_DV_1080P60,
    	},
    	{
    		.preset = V4L2_DV_1080P30,
    	},
    };
    
    static const struct ti81xxvin_input hdvpss_inst0_inputs[] = {
    	{
    		.input = {
    			.index		= 0,
    			.name		= "Component",
    			.type		= V4L2_INPUT_TYPE_CAMERA,
    			.std		= V4L2_STD_UNKNOWN,
    			.capabilities	= V4L2_OUT_CAP_PRESETS,
    		},
    #ifdef CONFIG_BEL_TI8168
    		.subdev_name	= ADV7182_INST0,
    #else
    		.subdev_name    = TVP7002_INST0,
    #endif
    		.dv_presets	= hdvpss_inst0_inp0_presets,
    		.num_dv_presets	= ARRAY_SIZE(hdvpss_inst0_inp0_presets),
    	},
    };
    
    static const struct ti81xxvin_input hdvpss_inst1_inputs[] = {
    	{
    		.input = {
    			.index		= 0,
    			.name		= "Component",
    			.type		= V4L2_INPUT_TYPE_CAMERA,
    			.std		= V4L2_STD_UNKNOWN,
    			.capabilities	= V4L2_OUT_CAP_PRESETS,
    		},
    #ifdef CONFIG_BEL_TI8168
            .subdev_name    = ADV7182_INST1,
    #else
    		.subdev_name	= TVP7002_INST1,
    #endif
    		.dv_presets	= hdvpss_inst2_inp0_presets,
    		.num_dv_presets	= ARRAY_SIZE(hdvpss_inst2_inp0_presets),
    	},
    };
    
    /* 16 bit decoders are present on the Port A of VIP0 and VIP1 instances. Which
    represents the VIP0 and VIP2 instances in software. While Port B of VIP0 and
    VIP1 are represented by VIP1 and VIP3 instances. On these two instances no
    decoders are present.
    */
    static struct ti81xxvin_config ti81xx_hsvpss_capture_cfg = {
    	.subdev_info = hdvpss_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(hdvpss_capture_sdev_info),
    	.card_name = ti81xx_card_name,
    	.inst_config[0] = {
    		.inputs = hdvpss_inst0_inputs,
    		.input_count = ARRAY_SIZE(hdvpss_inst0_inputs),
    	},
    	.inst_config[1] = {
    		.inputs = hdvpss_inst0_inputs,
    		.input_count = 0,
    	},
    	.inst_config[2] = {
    		.inputs = hdvpss_inst1_inputs,
    		.input_count = ARRAY_SIZE(hdvpss_inst1_inputs),
    	},
    	.inst_config[3] = {
    		.inputs = hdvpss_inst1_inputs,
    		.input_count = 0,
    	},
    
    };
    
    static struct resource ti81xx_hdvpss_capture_resource[] = {
    	[0] = {
    		.start = HDVPSS_CAPTURE_INST0_BASE,
    		.end   = (HDVPSS_CAPTURE_INST0_BASE +
    				HDVPSS_CAPTURE_INST0_SIZE - 1),
    		.flags = IORESOURCE_MEM,
    	},
    	[1] = {
    		.start = HDVPSS_CAPTURE_INST2_BASE,
    		.end   = (HDVPSS_CAPTURE_INST2_BASE +
    				HDVPSS_CAPTURE_INST2_SIZE - 1),
    		.flags = IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device hdvpss_capture_dev = {
    	.name		= "ti81xxvin",
    	.id		= -1,
    	.dev		= {
    			.dma_mask		= &ti81xx_dma_mask,
    			.coherent_dma_mask	= ~(u32)0,
    	},
    	.num_resources = 2,
    	.resource = ti81xx_hdvpss_capture_resource,
    };
    
    static int __init ti81xx_vin_init(void)
    {
    	int r;
    	hdvpss_capture_dev.dev.platform_data = &ti81xx_hsvpss_capture_cfg;
    	if (cpu_is_ti814x()) {
    		hdvpss_capture_sdev_info[0].ti81xxvin_select_decoder =
    			vps_ti814x_select_video_decoder;
    		hdvpss_capture_sdev_info[0].ti81xxvin_set_mode =
    			vps_ti814x_set_tvp7002_filter;
    		hdvpss_capture_sdev_info[0].decoder_id = 0;
    		hdvpss_capture_sdev_info[1].ti81xxvin_select_decoder =
    			NULL;
    		hdvpss_capture_sdev_info[1].ti81xxvin_set_mode =
    			NULL;
    		hdvpss_capture_sdev_info[1].decoder_id = 0;
    	} else {
    		hdvpss_capture_sdev_info[0].ti81xxvin_select_decoder =
    			//vps_ti816x_select_video_decoder; //Nithin
    			NULL;
    		hdvpss_capture_sdev_info[0].ti81xxvin_set_mode =
    #ifdef CONFIG_BEL_TI8168
                //vps_ti816x_set_adv7182_filter; Nithin
                       NULL;
    #else
    			vps_ti816x_set_tvp7002_filter;
    #endif
    			hdvpss_capture_sdev_info[0].decoder_id = 0;
    		hdvpss_capture_sdev_info[1].ti81xxvin_select_decoder =
    			NULL;
    		hdvpss_capture_sdev_info[1].ti81xxvin_set_mode =
    			NULL;
    		hdvpss_capture_sdev_info[1].decoder_id = 0;
    	}
    	r = platform_device_register(&hdvpss_capture_dev);
    	if (r)
    		printk(KERN_ERR "unable to register ti81xx_vin device\n");
    	else
    		printk(KERN_INFO "registered ti81xx_vin device\n");
    	return r;
    
    }
    #else
    static int __init ti81xx_vin_init(void)
    {
    	return 0;
    }
    
    #endif
    
    #if defined(CONFIG_FB_TI81XX_MODULE) || defined(CONFIG_FB_TI81XX)
    static struct ti81xxfb_platform_data ti81xxfb_config;
    
    static struct platform_device ti81xx_fb_device = {
    	.name		= "ti81xxfb",
    	.id		= -1,
    	.dev = {
    		.dma_mask		= &ti81xx_dma_mask,
    		.coherent_dma_mask	= ~(u32)0,
    		.platform_data		= &ti81xxfb_config,
    	},
    	.num_resources = 0,
    };
    
    
    void ti81xxfb_set_platform_data(struct ti81xxfb_platform_data *data)
    {
    	ti81xxfb_config = *data;
    }
    
    static int __init ti81xx_fb_init(void)
    {
    	int r;
    	r = platform_device_register(&ti81xx_fb_device);
    	if (r)
    		printk(KERN_ERR "unable to register ti81xx_fb device\n");
    	else
    		printk(KERN_INFO "registered ti81xx_fb device\n");
    	return r;
    
    }
    #else
    static int __init ti81xx_fb_init(void)
    {
    	return 0;
    }
    void ti81xxfb_set_platform_data(struct ti81xxfb_platform_data *data)
    {
    }
    #endif
    
    #if defined(CONFIG_VIDEO_TI81XX_VIDOUT_MODULE) || \
    		defined(CONFIG_VIDEO_TI81XX_VIDOUT)
    static struct resource ti81xx_vidout_resource[VPS_DISPLAY_INST_MAX] = {
    };
    
    static struct platform_device ti81xx_vidout_device = {
    	.name		= "t81xx_vidout",
    	.num_resources  = ARRAY_SIZE(ti81xx_vidout_resource),
    	.resource       = &ti81xx_vidout_resource[0],
    	.id             = -1,
    };
    
    static int __init ti81xx_init_vout(void)
    {
    	int r;
    
    	r = platform_device_register(&ti81xx_vidout_device);
    	if (r)
    		printk(KERN_ERR "Unable to register ti81xx_vidout device\n");
    	else
    		printk(KERN_INFO "registered ti81xx_vidout device\n");
    	return r;
    }
    #else
    static int __init ti81xx_init_vout(void)
    {
    	return 0;
    }
    #endif
    
    
    static int __init ti81xx_init_vpss(void)
    {
    	int retval = 0;
    	/*if vpss failed to register, none of the below could works*/
    	if (ti81xx_vpss_init())
    		return -1;
    	retval = ti81xx_init_vout();
    	retval += ti81xx_hdmi_init();
    	retval += ti81xx_fb_init();
    	retval += ti81xx_vin_init();
    	return retval;
    }
    
    arch_initcall(ti81xx_init_vpss);
    
    #endif
    


    Thanks and Regards,

    Nithin

  • Hi All,

    I'm able to solve this issue, green color war coming due to user pointer buffer what we are setting in saLoopBack application due to that. 

    While capturing I did one mistake that capture standard set to NTSC, when I disable this setting  I'm able to capture proper input in my capture buffer and display on the Monitor using comosite output.

    Thanks and Regards,

    Nithin