<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Camera quality and strange line in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Camera-quality-and-strange-line/m-p/866343#M131901</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi 호영 노&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one can try suggestions provided on&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="link-titled" href="https://community.nxp.com/message/626177?commentID=626177#comment-626177" title="https://community.nxp.com/message/626177?commentID=626177#comment-626177"&gt;https://community.nxp.com/message/626177?commentID=626177#comment-626177&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Mar 2019 05:45:28 GMT</pubDate>
    <dc:creator>igorpadykov</dc:creator>
    <dc:date>2019-03-05T05:45:28Z</dc:date>
    <item>
      <title>Camera quality and strange line</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Camera-quality-and-strange-line/m-p/866342#M131900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the i.MX6DL with ccd camera.&lt;/P&gt;&lt;P&gt;This ccd camera working well with S3C2440.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I connected this ccd camera with i.MX6DL and setting several things and I can see the camera video to my lcd.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It working well as S3C2440, but, when I looking the video in detail,&amp;nbsp;&lt;/P&gt;&lt;P&gt;it has strange line in top.&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it has nosie.d&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Attacehd picture has filcker.&amp;nbsp;Anyway noise is not a serious level, but it does exist.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I adjust this noise level and using full lcd with this camera?&lt;/P&gt;&lt;P&gt;I can not get a sense of what source to test with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should I check the h/w structure first??&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that this problem is depend on some source code setting.. But I can't be sure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77458iACC3871583E447E6/image-size/large?v=v2&amp;amp;px=999" title="captured.jpg" alt="captured.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is what I using for test. ( I attached source code file also.)&lt;/P&gt;&lt;P&gt;Actually I change some values in this sources, but no lucks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * Copyright 2007-2013 Freescale Semiconductor, Inc. All rights reserved.&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * The code contained herein is licensed under the GNU General Public&lt;BR /&gt; * License. You may obtain a copy of the GNU General Public License&lt;BR /&gt; * Version 2 or later at the following locations:&lt;BR /&gt; *&lt;BR /&gt; * &lt;A href="http://www.opensource.org/licenses/gpl-license.html" target="test_blank"&gt;http://www.opensource.org/licenses/gpl-license.html&lt;/A&gt;&lt;BR /&gt; * &lt;A href="http://www.gnu.org/copyleft/gpl.html" target="test_blank"&gt;http://www.gnu.org/copyleft/gpl.html&lt;/A&gt;&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * @file mxc_v4l2_tvin.c&lt;BR /&gt; *&lt;BR /&gt; * @brief Mxc TVIN For Linux 2 driver test application&lt;BR /&gt; *&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;#ifdef __cplusplus&lt;BR /&gt;extern "C"{&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/*=======================================================================&lt;BR /&gt; INCLUDE FILES&lt;BR /&gt;=======================================================================*/&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include &amp;lt;errno.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/types.h&amp;gt;&lt;BR /&gt;#include &amp;lt;stdint.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/stat.h&amp;gt;&lt;BR /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/ioctl.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/time.h&amp;gt;&lt;BR /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;BR /&gt;#include &amp;lt;asm/types.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/videodev2.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/mman.h&amp;gt;&lt;BR /&gt;#include &amp;lt;math.h&amp;gt;&lt;BR /&gt;#include &amp;lt;string.h&amp;gt;&lt;BR /&gt;#include &amp;lt;malloc.h&amp;gt;&lt;BR /&gt;#include &amp;lt;sys/time.h&amp;gt;&lt;/P&gt;&lt;P&gt;#include "mxcfb.h"&lt;BR /&gt;#include "mxc_v4l2.h"&lt;BR /&gt;#include "ipu.h"&lt;/P&gt;&lt;P&gt;#define TFAIL -1&lt;BR /&gt;#define TPASS 0&lt;/P&gt;&lt;P&gt;char v4l_capture_dev[100] = "/dev/video1";&lt;BR /&gt;char v4l_output_dev[100] = "/dev/video17";&lt;BR /&gt;int fd_capture_v4l = 0;&lt;BR /&gt;int fd_output_v4l = 0;&lt;BR /&gt;int g_cap_mode = 0;&lt;BR /&gt;int g_input = 1;&lt;BR /&gt;int g_fmt = V4L2_PIX_FMT_UYVY;&lt;BR /&gt;int g_rotate = 0;&lt;BR /&gt;int g_vflip = 0;&lt;BR /&gt;int g_hflip = 0;&lt;BR /&gt;int g_vdi_enable = 0;&lt;BR /&gt;int g_vdi_motion = 0;&lt;BR /&gt;int g_tb = 0;&lt;BR /&gt;int g_output = 3;&lt;/P&gt;&lt;P&gt;int g_output_num_buffers = 4;&lt;BR /&gt;int g_capture_num_buffers = 3;&lt;/P&gt;&lt;P&gt;int g_in_width = 0;&lt;BR /&gt;int g_in_height = 0;&lt;BR /&gt;int g_display_width = 0;&lt;BR /&gt;int g_display_height = 0;&lt;BR /&gt;int g_display_top = 0;&lt;BR /&gt;int g_display_left = 0;&lt;BR /&gt;int g_frame_size;&lt;BR /&gt;int g_frame_period = 33333;&lt;BR /&gt;v4l2_std_id g_current_std = V4L2_STD_NTSC;&lt;/P&gt;&lt;P&gt;struct testbuffer&lt;BR /&gt;{&lt;BR /&gt; unsigned char *start;&lt;BR /&gt; size_t offset;&lt;BR /&gt; unsigned int length;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;struct testbuffer output_buffers[4];&lt;BR /&gt;struct testbuffer capture_buffers[3];&lt;/P&gt;&lt;P&gt;int start_capturing(void)&lt;BR /&gt;{&lt;BR /&gt; unsigned int i;&lt;BR /&gt; struct v4l2_buffer buf;&lt;BR /&gt; enum v4l2_buf_type type;&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; g_capture_num_buffers; i++)&lt;BR /&gt; {&lt;BR /&gt; memset(&amp;amp;buf, 0, sizeof (buf));&lt;BR /&gt; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; buf.index = i;&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_QUERYBUF, &amp;amp;buf) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_QUERYBUF error\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;capture_buffers[i].length = buf.length;&lt;BR /&gt; capture_buffers[i].offset = (size_t) buf.m.offset;&lt;BR /&gt; capture_buffers[i].start = mmap (NULL, capture_buffers[i].length,&lt;BR /&gt; PROT_READ | PROT_WRITE, MAP_SHARED,&lt;BR /&gt; fd_capture_v4l, capture_buffers[i].offset);&lt;BR /&gt; memset(capture_buffers[i].start, 0xFF, capture_buffers[i].length);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; g_capture_num_buffers; i++)&lt;BR /&gt; {&lt;BR /&gt; memset(&amp;amp;buf, 0, sizeof (buf));&lt;BR /&gt; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; buf.index = i;&lt;BR /&gt; buf.m.offset = capture_buffers[i].offset;&lt;BR /&gt; if (ioctl (fd_capture_v4l, VIDIOC_QBUF, &amp;amp;buf) &amp;lt; 0) {&lt;BR /&gt; printf("VIDIOC_QBUF error\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; if (ioctl (fd_capture_v4l, VIDIOC_STREAMON, &amp;amp;type) &amp;lt; 0) {&lt;BR /&gt; printf("VIDIOC_STREAMON error\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int prepare_output(void)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;BR /&gt; struct v4l2_buffer output_buf;&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; g_output_num_buffers; i++)&lt;BR /&gt; {&lt;BR /&gt; memset(&amp;amp;output_buf, 0, sizeof(output_buf));&lt;BR /&gt; output_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; output_buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; output_buf.index = i;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_QUERYBUF, &amp;amp;output_buf) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_QUERYBUF error\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;output_buffers[i].length = output_buf.length;&lt;BR /&gt; output_buffers[i].offset = (size_t) output_buf.m.offset;&lt;BR /&gt; output_buffers[i].start = mmap (NULL, output_buffers[i].length,&lt;BR /&gt; PROT_READ | PROT_WRITE, MAP_SHARED,&lt;BR /&gt; fd_output_v4l, output_buffers[i].offset);&lt;BR /&gt; if (output_buffers[i].start == NULL) {&lt;BR /&gt; printf("v4l2 tvin test: output mmap failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int v4l_capture_setup(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;struct v4l2_capability cap;&lt;BR /&gt; struct v4l2_cropcap cropcap;&lt;BR /&gt; struct v4l2_crop crop;&lt;BR /&gt; struct v4l2_format fmt;&lt;BR /&gt; struct v4l2_requestbuffers req;&lt;BR /&gt; struct v4l2_dbg_chip_ident chip;&lt;BR /&gt; struct v4l2_streamparm parm;&lt;BR /&gt; v4l2_std_id id;&lt;BR /&gt; unsigned int min;&lt;/P&gt;&lt;P&gt;if (ioctl (fd_capture_v4l, VIDIOC_QUERYCAP, &amp;amp;cap) &amp;lt; 0) {&lt;BR /&gt; if (EINVAL == errno) {&lt;BR /&gt; fprintf (stderr, "%s is no V4L2 device\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; } else {&lt;BR /&gt; fprintf (stderr, "%s isn not V4L device,unknow error\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (!(cap.capabilities &amp;amp; V4L2_CAP_VIDEO_CAPTURE)) {&lt;BR /&gt; fprintf (stderr, "%s is no video capture device\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (!(cap.capabilities &amp;amp; V4L2_CAP_STREAMING)) {&lt;BR /&gt; fprintf (stderr, "%s does not support streaming i/o\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (ioctl(fd_capture_v4l, VIDIOC_DBG_G_CHIP_IDENT, &amp;amp;chip))&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_DBG_G_CHIP_IDENT failed.\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; printf("TV decoder chip is %s\n", chip.match.name);&lt;/P&gt;&lt;P&gt;if (ioctl(fd_capture_v4l, VIDIOC_S_INPUT, &amp;amp;g_input) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_S_INPUT failed\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (ioctl(fd_capture_v4l, VIDIOC_G_STD, &amp;amp;id) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_G_STD failed\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; g_current_std = id;&lt;/P&gt;&lt;P&gt;if (ioctl(fd_capture_v4l, VIDIOC_S_STD, &amp;amp;id) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_S_STD failed\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Select video input, video standard and tune here. */&lt;/P&gt;&lt;P&gt;memset(&amp;amp;cropcap, 0, sizeof(cropcap));&lt;/P&gt;&lt;P&gt;cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;/P&gt;&lt;P&gt;if (ioctl (fd_capture_v4l, VIDIOC_CROPCAP, &amp;amp;cropcap) &amp;lt; 0) {&lt;BR /&gt; crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; crop.c = cropcap.defrect; /* reset to default */&lt;/P&gt;&lt;P&gt;if (ioctl (fd_capture_v4l, VIDIOC_S_CROP, &amp;amp;crop) &amp;lt; 0) {&lt;BR /&gt; switch (errno) {&lt;BR /&gt; case EINVAL:&lt;BR /&gt; /* Cropping not supported. */&lt;BR /&gt; fprintf (stderr, "%s doesn't support crop\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; break;&lt;BR /&gt; default:&lt;BR /&gt; /* Errors ignored. */&lt;BR /&gt; break;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; } else {&lt;BR /&gt; /* Errors ignored. */&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; parm.parm.capture.timeperframe.numerator = 1;&lt;BR /&gt; parm.parm.capture.timeperframe.denominator = 0;&lt;BR /&gt; parm.parm.capture.capturemode = 0;&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_S_PARM, &amp;amp;parm) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_S_PARM failed\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;memset(&amp;amp;fmt, 0, sizeof(fmt));&lt;/P&gt;&lt;P&gt;fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; fmt.fmt.pix.width = 0;&lt;BR /&gt; fmt.fmt.pix.height = 0;&lt;BR /&gt; fmt.fmt.pix.pixelformat = g_fmt;&lt;BR /&gt; fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (ioctl (fd_capture_v4l, VIDIOC_S_FMT, &amp;amp;fmt) &amp;lt; 0){&lt;BR /&gt; fprintf (stderr, "%s iformat not supported \n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Note VIDIOC_S_FMT may change width and height. */&lt;/P&gt;&lt;P&gt;/* Buggy driver paranoia. */&lt;BR /&gt; min = fmt.fmt.pix.width * 2;&lt;BR /&gt; if (fmt.fmt.pix.bytesperline &amp;lt; min)&lt;BR /&gt; fmt.fmt.pix.bytesperline = min;&lt;/P&gt;&lt;P&gt;min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;&lt;BR /&gt; if (fmt.fmt.pix.sizeimage &amp;lt; min)&lt;BR /&gt; fmt.fmt.pix.sizeimage = min;&lt;/P&gt;&lt;P&gt;if (ioctl(fd_capture_v4l, VIDIOC_G_FMT, &amp;amp;fmt) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_G_FMT failed\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;g_in_width = fmt.fmt.pix.width;&lt;BR /&gt; g_in_height = fmt.fmt.pix.height;&lt;/P&gt;&lt;P&gt;memset(&amp;amp;req, 0, sizeof (req));&lt;/P&gt;&lt;P&gt;req.count = g_capture_num_buffers;&lt;BR /&gt; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; req.memory = V4L2_MEMORY_MMAP;&lt;/P&gt;&lt;P&gt;if (ioctl (fd_capture_v4l, VIDIOC_REQBUFS, &amp;amp;req) &amp;lt; 0) {&lt;BR /&gt; if (EINVAL == errno) {&lt;BR /&gt; fprintf (stderr, "%s does not support "&lt;BR /&gt; "memory mapping\n", v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; } else {&lt;BR /&gt; fprintf (stderr, "%s does not support "&lt;BR /&gt; "memory mapping, unknow error\n", v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (req.count &amp;lt; 2) {&lt;BR /&gt; fprintf (stderr, "Insufficient buffer memory on %s\n",&lt;BR /&gt; v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int v4l_output_setup(void)&lt;BR /&gt;{&lt;BR /&gt; struct v4l2_control ctrl;&lt;BR /&gt; struct v4l2_format fmt;&lt;BR /&gt; struct v4l2_framebuffer fb;&lt;BR /&gt; struct v4l2_cropcap cropcap;&lt;BR /&gt; struct v4l2_crop crop;&lt;BR /&gt; struct v4l2_capability cap;&lt;BR /&gt; struct v4l2_fmtdesc fmtdesc;&lt;BR /&gt; struct v4l2_requestbuffers buf_req;&lt;/P&gt;&lt;P&gt;if (!ioctl(fd_output_v4l, VIDIOC_QUERYCAP, &amp;amp;cap)) {&lt;BR /&gt; printf("driver=%s, card=%s, bus=%s, \r\n"&lt;BR /&gt; "version=0x%08x, "&lt;BR /&gt; "capabilities=0x%08x\n",&lt;BR /&gt; cap.driver, cap.card, cap.bus_info,&lt;BR /&gt; cap.version,&lt;BR /&gt; cap.capabilities);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;fmtdesc.index = 0;&lt;BR /&gt; fmtdesc.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; while (!ioctl(fd_output_v4l, VIDIOC_ENUM_FMT, &amp;amp;fmtdesc)) {&lt;BR /&gt; printf("fmt %s: fourcc = 0x%08x\n",&lt;BR /&gt; fmtdesc.description,&lt;BR /&gt; fmtdesc.pixelformat);&lt;BR /&gt; fmtdesc.index++;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;memset(&amp;amp;cropcap, 0, sizeof(cropcap));&lt;BR /&gt; cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_CROPCAP, &amp;amp;cropcap) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("get crop capability failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; crop.c.top = g_display_top;&lt;BR /&gt; crop.c.left = g_display_left;&lt;BR /&gt; crop.c.width = g_display_width;&lt;BR /&gt; crop.c.height = g_display_height;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_CROP, &amp;amp;crop) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set crop failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;// Set rotation&lt;BR /&gt; ctrl.id = V4L2_CID_ROTATE;&lt;BR /&gt; ctrl.value = g_rotate;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_CTRL, &amp;amp;ctrl) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set ctrl rotate failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; ctrl.id = V4L2_CID_VFLIP;&lt;BR /&gt; ctrl.value = g_vflip;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_CTRL, &amp;amp;ctrl) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set ctrl vflip failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; ctrl.id = V4L2_CID_HFLIP;&lt;BR /&gt; ctrl.value = g_hflip;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_CTRL, &amp;amp;ctrl) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set ctrl hflip failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; if (g_vdi_enable) {&lt;BR /&gt; ctrl.id = V4L2_CID_MXC_MOTION;&lt;BR /&gt; ctrl.value = g_vdi_motion;&lt;BR /&gt; //ctrl.value = 0;&lt;BR /&gt;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_CTRL, &amp;amp;ctrl) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set ctrl motion failed\n");&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;fb.flags = V4L2_FBUF_FLAG_OVERLAY;&lt;BR /&gt; ioctl(fd_output_v4l, VIDIOC_S_FBUF, &amp;amp;fb);&lt;/P&gt;&lt;P&gt;memset(&amp;amp;fmt, 0, sizeof(fmt));&lt;BR /&gt; fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; fmt.fmt.pix.width= g_in_width;&lt;BR /&gt; fmt.fmt.pix.height= g_in_height;&lt;BR /&gt; fmt.fmt.pix.pixelformat = g_fmt;&lt;BR /&gt; fmt.fmt.pix.bytesperline = g_in_width;&lt;BR /&gt; fmt.fmt.pix.priv = 0;&lt;BR /&gt; fmt.fmt.pix.sizeimage = 0;&lt;BR /&gt;&lt;BR /&gt; if (g_tb)&lt;BR /&gt; fmt.fmt.pix.field = V4L2_FIELD_INTERLACED_TB;&lt;BR /&gt; else&lt;BR /&gt; fmt.fmt.pix.field = V4L2_FIELD_INTERLACED_BT;&lt;BR /&gt;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_S_FMT, &amp;amp;fmt) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("set format failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (ioctl(fd_output_v4l, VIDIOC_G_FMT, &amp;amp;fmt) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("get format failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; g_frame_size = fmt.fmt.pix.sizeimage;&lt;/P&gt;&lt;P&gt;memset(&amp;amp;buf_req, 0, sizeof(buf_req));&lt;BR /&gt; buf_req.count = g_output_num_buffers;&lt;BR /&gt; buf_req.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; buf_req.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_REQBUFS, &amp;amp;buf_req) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("request buffers failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int&lt;BR /&gt;mxc_v4l_tvin_test(void)&lt;BR /&gt;{&lt;BR /&gt; struct v4l2_buffer capture_buf, output_buf;&lt;BR /&gt; v4l2_std_id id;&lt;BR /&gt; int i, j;&lt;BR /&gt; enum v4l2_buf_type type;&lt;BR /&gt; int total_time;&lt;BR /&gt; struct timeval tv_start, tv_current;&lt;BR /&gt; int rtn;&lt;/P&gt;&lt;P&gt;if (prepare_output() &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("prepare_output failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (start_capturing() &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("start_capturing failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;gettimeofday(&amp;amp;tv_start, 0);&lt;BR /&gt; printf("start time = %d s, %d us\n", (unsigned int) tv_start.tv_sec,&lt;BR /&gt; (unsigned int) tv_start.tv_usec);&lt;/P&gt;&lt;P&gt;for (i = 0; ; i++) {&lt;BR /&gt;begin:&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_G_STD, &amp;amp;id)) {&lt;BR /&gt; printf("VIDIOC_G_STD failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (id == g_current_std)&lt;BR /&gt; {&lt;BR /&gt; //printf("goto next\r\n");&lt;BR /&gt; goto next;&lt;BR /&gt; }&lt;BR /&gt; else if (id == V4L2_STD_PAL || id == V4L2_STD_NTSC) {&lt;BR /&gt; printf("----------------------------------------------------------------------\r\n");&lt;BR /&gt; type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; ioctl(fd_output_v4l, VIDIOC_STREAMOFF, &amp;amp;type);&lt;/P&gt;&lt;P&gt;type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; ioctl(fd_capture_v4l, VIDIOC_STREAMOFF, &amp;amp;type);&lt;/P&gt;&lt;P&gt;for (j = 0; j &amp;lt; g_output_num_buffers; j++)&lt;BR /&gt; {&lt;BR /&gt; munmap(output_buffers[j].start, output_buffers[j].length);&lt;BR /&gt; }&lt;BR /&gt; for (j = 0; j &amp;lt; g_capture_num_buffers; j++)&lt;BR /&gt; {&lt;BR /&gt; munmap(capture_buffers[j].start, capture_buffers[j].length);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (v4l_capture_setup() &amp;lt; 0) {&lt;BR /&gt; printf("Setup v4l capture failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (v4l_output_setup() &amp;lt; 0) {&lt;BR /&gt; printf("Setup v4l output failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (prepare_output() &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("prepare_output failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (start_capturing() &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("start_capturing failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; i = 0;&lt;BR /&gt; printf("TV standard changed\n");&lt;BR /&gt; } else {&lt;BR /&gt; sleep(1);&lt;BR /&gt; /* Try again */&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_G_STD, &amp;amp;id)) {&lt;BR /&gt; printf("VIDIOC_G_STD failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (id != V4L2_STD_ALL)&lt;BR /&gt; goto begin;&lt;/P&gt;&lt;P&gt;printf("Cannot detect TV standard\n");&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;BR /&gt;next:&lt;/P&gt;&lt;P&gt;/*rtn = poll( (struct pollfd *)&amp;amp;poll_fds, 1, tmout );&lt;BR /&gt; if ( rtn &amp;lt; 0 ) return -1;*/&lt;/P&gt;&lt;P&gt;memset(&amp;amp;capture_buf, 0, sizeof(capture_buf));&lt;BR /&gt; capture_buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; capture_buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_DQBUF, &amp;amp;capture_buf) &amp;lt; 0) {&lt;BR /&gt; printf("VIDIOC_DQBUF failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;memset(&amp;amp;output_buf, 0, sizeof(output_buf));&lt;BR /&gt; output_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; output_buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; if (i &amp;lt; g_output_num_buffers) {&lt;BR /&gt; output_buf.index = i;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_QUERYBUF, &amp;amp;output_buf) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_QUERYBUF failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; } else {&lt;BR /&gt; output_buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; output_buf.memory = V4L2_MEMORY_MMAP;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_DQBUF, &amp;amp;output_buf) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_DQBUF failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;memcpy(output_buffers[output_buf.index].start, capture_buffers[capture_buf.index].start, g_frame_size);&lt;BR /&gt;&lt;BR /&gt; if (ioctl(fd_capture_v4l, VIDIOC_QBUF, &amp;amp;capture_buf) &amp;lt; 0) {&lt;BR /&gt; printf("VIDIOC_QBUF failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;output_buf.timestamp.tv_sec = tv_start.tv_sec;&lt;BR /&gt; output_buf.timestamp.tv_usec = tv_start.tv_usec + (g_frame_period * i);&lt;BR /&gt; if (g_vdi_enable)&lt;BR /&gt; output_buf.field = g_tb ? V4L2_FIELD_INTERLACED_TB :&lt;BR /&gt; V4L2_FIELD_INTERLACED_BT;&lt;BR /&gt;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_QBUF, &amp;amp;output_buf) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("VIDIOC_QBUF failed\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; if (i == 1) {&lt;BR /&gt; type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; if (ioctl(fd_output_v4l, VIDIOC_STREAMON, &amp;amp;type) &amp;lt; 0) {&lt;BR /&gt; printf("Could not start stream\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//if(i==4) break;&lt;BR /&gt; }&lt;BR /&gt; gettimeofday(&amp;amp;tv_current, 0);&lt;BR /&gt; total_time = (tv_current.tv_sec - tv_start.tv_sec) * 1000000L;&lt;BR /&gt; total_time += tv_current.tv_usec - tv_start.tv_usec;&lt;BR /&gt; printf("total time for %u frames = %u us = %lld fps\n", i, total_time, (i * 1000000ULL) / total_time);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int process_cmdline(int argc, char **argv)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;/P&gt;&lt;P&gt;for (i = 1; i &amp;lt; argc; i++) {&lt;BR /&gt; if (strcmp(argv[i], "-ow") == 0) {&lt;BR /&gt; g_display_width = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-oh") == 0) {&lt;BR /&gt; g_display_height = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-ot") == 0) {&lt;BR /&gt; g_display_top = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-ol") == 0) {&lt;BR /&gt; g_display_left = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-r") == 0) {&lt;BR /&gt; g_rotate = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-f") == 0) {&lt;BR /&gt; i++;&lt;BR /&gt; g_fmt = v4l2_fourcc(argv[i][0], argv[i][1],argv[i][2],argv[i][3]);&lt;BR /&gt; if ((g_fmt != V4L2_PIX_FMT_NV12) &amp;amp;&amp;amp;&lt;BR /&gt; (g_fmt != V4L2_PIX_FMT_UYVY) &amp;amp;&amp;amp;&lt;BR /&gt; (g_fmt != V4L2_PIX_FMT_YUYV) &amp;amp;&amp;amp;&lt;BR /&gt; (g_fmt != V4L2_PIX_FMT_YUV420)) {&lt;BR /&gt; printf("Default format is used: UYVY\n");&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-m") == 0) {&lt;BR /&gt; g_vdi_enable = 1;&lt;BR /&gt; g_vdi_motion = atoi(argv[++i]);&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-tb") == 0) {&lt;BR /&gt; g_tb = 1;&lt;BR /&gt; }&lt;BR /&gt; else if (strcmp(argv[i], "-help") == 0) {&lt;BR /&gt; printf("MXC Video4Linux TVin Test\n\n" \&lt;BR /&gt; "Syntax: mxc_v4l2_tvin.out\n" \&lt;BR /&gt; " -ow &amp;lt;capture display width&amp;gt;\n" \&lt;BR /&gt; " -oh &amp;lt;capture display height&amp;gt;\n" \&lt;BR /&gt; " -ot &amp;lt;display top&amp;gt;\n" \&lt;BR /&gt; " -ol &amp;lt;display left&amp;gt;\n" \&lt;BR /&gt; " -r &amp;lt;rotation&amp;gt; -c &amp;lt;capture counter&amp;gt; \n"&lt;BR /&gt; " -m &amp;lt;motion&amp;gt; 0:medium 1:low 2:high, 0-default\n"&lt;BR /&gt; " -tb top field first, bottom field first-default\n"&lt;BR /&gt; " -f &amp;lt;format, only YU12, YUYV, UYVY and NV12 are supported&amp;gt; \n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((g_display_width == 0) || (g_display_height == 0)) {&lt;BR /&gt; printf("Zero display width or height\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int main(int argc, char **argv)&lt;BR /&gt;{&lt;BR /&gt;#ifdef BUILD_FOR_ANDROID&lt;BR /&gt; char fb_device[100] = "/dev/graphics/fb0";&lt;BR /&gt;#else&lt;BR /&gt; char fb_device[100] = "/dev/fb0";&lt;BR /&gt;#endif&lt;BR /&gt; int fd_fb = 0, i;&lt;BR /&gt; struct mxcfb_gbl_alpha alpha;&lt;BR /&gt; enum v4l2_buf_type type;&lt;/P&gt;&lt;P&gt;if (process_cmdline(argc, argv) &amp;lt; 0) {&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((fd_capture_v4l = open(v4l_capture_dev, O_RDWR, 0)) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("Unable to open %s\n", v4l_capture_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((fd_output_v4l = open(v4l_output_dev, O_RDWR, 0)) &amp;lt; 0)&lt;BR /&gt; {&lt;BR /&gt; printf("Unable to open %s\n", v4l_output_dev);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (v4l_capture_setup() &amp;lt; 0) {&lt;BR /&gt; printf("Setup v4l capture failed.\n");&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (v4l_output_setup() &amp;lt; 0) {&lt;BR /&gt; printf("Setup v4l output failed.\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((fd_fb = open(fb_device, O_RDWR )) &amp;lt; 0) {&lt;BR /&gt; printf("Unable to open frame buffer\n");&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Overlay setting */&lt;BR /&gt; alpha.alpha = 0;&lt;BR /&gt; alpha.enable = 1;&lt;BR /&gt; if (ioctl(fd_fb, MXCFB_SET_GBL_ALPHA, &amp;amp;alpha) &amp;lt; 0) {&lt;BR /&gt; printf("Set global alpha failed\n");&lt;BR /&gt; close(fd_fb);&lt;BR /&gt; close(fd_capture_v4l);&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; return TFAIL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;mxc_v4l_tvin_test();&lt;/P&gt;&lt;P&gt;type = V4L2_BUF_TYPE_VIDEO_OUTPUT;&lt;BR /&gt; ioctl(fd_output_v4l, VIDIOC_STREAMOFF, &amp;amp;type);&lt;/P&gt;&lt;P&gt;type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; ioctl(fd_capture_v4l, VIDIOC_STREAMOFF, &amp;amp;type);&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; g_output_num_buffers; i++)&lt;BR /&gt; {&lt;BR /&gt; munmap(output_buffers[i].start, output_buffers[i].length);&lt;BR /&gt; }&lt;BR /&gt; for (i = 0; i &amp;lt; g_capture_num_buffers; i++)&lt;BR /&gt; {&lt;BR /&gt; munmap(capture_buffers[i].start, capture_buffers[i].length);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;close(fd_capture_v4l);&lt;BR /&gt; close(fd_output_v4l);&lt;BR /&gt; close(fd_fb);&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this code is tw9900 driver code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * Copyright 2005-2013 Freescale Semiconductor, Inc. All Rights Reserved.&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * The code contained herein is licensed under the GNU General Public&lt;BR /&gt; * License. You may obtain a copy of the GNU General Public License&lt;BR /&gt; * Version 2 or later at the following locations:&lt;BR /&gt; *&lt;BR /&gt; * &lt;A href="http://www.opensource.org/licenses/gpl-license.html" target="test_blank"&gt;http://www.opensource.org/licenses/gpl-license.html&lt;/A&gt;&lt;BR /&gt; * &lt;A href="http://www.gnu.org/copyleft/gpl.html" target="test_blank"&gt;http://www.gnu.org/copyleft/gpl.html&lt;/A&gt;&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * @file adv7180.c&lt;BR /&gt; *&lt;BR /&gt; * @brief Analog Device ADV7180 video decoder functions&lt;BR /&gt; *&lt;BR /&gt; * @ingroup Camera&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;#include &amp;lt;linux/module.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/init.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/types.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/delay.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/device.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/i2c.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/videodev2.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/regulator/consumer.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/fsl_devices.h&amp;gt;&lt;BR /&gt;#include &amp;lt;media/v4l2-chip-ident.h&amp;gt;&lt;BR /&gt;#include &amp;lt;media/v4l2-int-device.h&amp;gt;&lt;BR /&gt;#include "mxc_v4l2_capture.h"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//static struct fsl_mxc_tvin_platform_data *tvin_plat;&lt;BR /&gt;static struct fsl_mxc_camera_platform_data *tvin_plat;&lt;/P&gt;&lt;P&gt;extern void gpio_sensor_active(void);&lt;BR /&gt;extern void gpio_sensor_inactive(void);&lt;/P&gt;&lt;P&gt;static int tw9900_probe(struct i2c_client *adapter,&lt;BR /&gt; const struct i2c_device_id *id);&lt;BR /&gt;static int tw9900_detach(struct i2c_client *client);&lt;/P&gt;&lt;P&gt;static const struct i2c_device_id tw9900_id[] = {&lt;BR /&gt; {"tw9900", 0},&lt;BR /&gt; {},&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;#define TW9900_IDENT 0x00 /* IDENT */&lt;BR /&gt;#define TW9900_STATUS_1 0x01&lt;BR /&gt;#define TW9900_BRIGHTNESS 0x10 /* Brightness */&lt;BR /&gt;#define TW9900_CONTRAST 0x11 /* CONTRAST */&lt;BR /&gt;#define TW9900_SD_SATURATION_CB 0x13 /* SD Saturation Cb */&lt;BR /&gt;#define TW9900_SD_SATURATION_CR 0x14 /* SD Saturation Cr */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define V4L2_IDENT_TW9900 9900&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;//#define NTSC_FIX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;MODULE_DEVICE_TABLE(i2c, tw9900_id);&lt;/P&gt;&lt;P&gt;static struct i2c_driver tw9900_i2c_driver = {&lt;BR /&gt; .driver = {&lt;BR /&gt; .owner = THIS_MODULE,&lt;BR /&gt; .name = "tw9900",&lt;BR /&gt; },&lt;BR /&gt; .probe = tw9900_probe,&lt;BR /&gt; .remove = tw9900_detach,&lt;BR /&gt; .id_table = tw9900_id,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * Maintains the information on the current state of the sensor.&lt;BR /&gt; */&lt;BR /&gt;struct sensor {&lt;BR /&gt; struct sensor_data sen;&lt;BR /&gt; v4l2_std_id std_id;&lt;BR /&gt;} tw9900_data;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*! List of input video formats supported. The video formats is corresponding&lt;BR /&gt; * with v4l2 id in video_fmt_t&lt;BR /&gt; */&lt;BR /&gt;typedef enum {&lt;BR /&gt; tw9900_NTSC = 0, /*!&amp;lt; Locked on (M) NTSC video signal. */&lt;BR /&gt; tw9900_PAL, /*!&amp;lt; (B, G, H, I, N)PAL video signal. */&lt;BR /&gt; tw9900_NOT_LOCKED, /*!&amp;lt; Not locked on a signal. */&lt;BR /&gt;} video_fmt_idx;&lt;/P&gt;&lt;P&gt;/*! Number of video standards supported (including 'not locked' signal). */&lt;BR /&gt;#define tw9900_STD_MAX (tw9900_PAL + 1)&lt;/P&gt;&lt;P&gt;/*! Video format structure. */&lt;BR /&gt;typedef struct {&lt;BR /&gt; int v4l2_id; /*!&amp;lt; Video for linux ID. */&lt;BR /&gt; char name[16]; /*!&amp;lt; Name (e.g., "NTSC", "PAL", etc.) */&lt;BR /&gt; u16 raw_width; /*!&amp;lt; Raw width. */&lt;BR /&gt; u16 raw_height; /*!&amp;lt; Raw height. */&lt;BR /&gt; u16 active_width; /*!&amp;lt; Active width. */&lt;BR /&gt; u16 active_height; /*!&amp;lt; Active height. */&lt;BR /&gt; u16 active_top; /*!&amp;lt; Active top. */&lt;BR /&gt; u16 active_left; /*!&amp;lt; Active left. */&lt;BR /&gt;} video_fmt_t;&lt;/P&gt;&lt;P&gt;/*! Description of video formats supported.&lt;BR /&gt; *&lt;BR /&gt; * PAL: raw=720x625, active=720x576.&lt;BR /&gt; * NTSC: raw=720x525, active=720x480.&lt;BR /&gt; */&lt;BR /&gt;static video_fmt_t video_fmts[] = {&lt;BR /&gt; { /*! NTSC */&lt;BR /&gt; .v4l2_id = V4L2_STD_NTSC,&lt;BR /&gt; .name = "NTSC",&lt;BR /&gt; .raw_width = 720, /* SENS_FRM_WIDTH */&lt;BR /&gt; .raw_height = 525, /* SENS_FRM_HEIGHT */&lt;BR /&gt; .active_width = 720, /* ACT_FRM_WIDTH plus 1 */&lt;BR /&gt; .active_height = 480, /* ACT_FRM_WIDTH plus 1 */&lt;BR /&gt; .active_top = 13,&lt;BR /&gt; .active_left = 0,&lt;BR /&gt; },&lt;BR /&gt; { /*! (B, G, H, I, N) PAL */&lt;BR /&gt; .v4l2_id = V4L2_STD_PAL,&lt;BR /&gt; .name = "PAL",&lt;BR /&gt; .raw_width = 720,&lt;BR /&gt; .raw_height = 625,&lt;BR /&gt; .active_width = 720,&lt;BR /&gt; .active_height = 576,&lt;BR /&gt; },&lt;BR /&gt; { /*! Unlocked standard */&lt;BR /&gt; .v4l2_id = V4L2_STD_ALL,&lt;BR /&gt; .name = "Autodetect",&lt;BR /&gt; .raw_width = 720,&lt;BR /&gt; .raw_height = 625,&lt;BR /&gt; .active_width = 720,&lt;BR /&gt; .active_height = 576,&lt;BR /&gt; },&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;#ifdef NTSC_FIX&lt;BR /&gt;static video_fmt_idx video_idx = tw9900_NTSC;&lt;BR /&gt;#else&lt;BR /&gt;static video_fmt_idx video_idx = tw9900_PAL;&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;/*! @brief This mutex is used to provide mutual exclusion.&lt;BR /&gt; *&lt;BR /&gt; * Create a mutex that can be used to provide mutually exclusive&lt;BR /&gt; * read/write access to the globally accessible data structures&lt;BR /&gt; * and variables that were defined above.&lt;BR /&gt; */&lt;BR /&gt;static DEFINE_MUTEX(mutex);&lt;/P&gt;&lt;P&gt;#define IF_NAME "tw9900"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* supported controls */&lt;BR /&gt;/* This hasn't been fully implemented yet.&lt;BR /&gt; * This is how it should work, though. */&lt;BR /&gt;static struct v4l2_queryctrl tw9900_qctrl[] = {&lt;BR /&gt; {&lt;BR /&gt; .id = V4L2_CID_BRIGHTNESS,&lt;BR /&gt; .type = V4L2_CTRL_TYPE_INTEGER,&lt;BR /&gt; .name = "Brightness",&lt;BR /&gt; .minimum = 0, /* check this value */&lt;BR /&gt; .maximum = 255, /* check this value */&lt;BR /&gt; .step = 1, /* check this value */&lt;BR /&gt; .default_value = 127, /* check this value */&lt;BR /&gt; .flags = 0,&lt;BR /&gt; }, {&lt;BR /&gt; .id = V4L2_CID_SATURATION,&lt;BR /&gt; .type = V4L2_CTRL_TYPE_INTEGER,&lt;BR /&gt; .name = "Saturation",&lt;BR /&gt; .minimum = 0, /* check this value */&lt;BR /&gt; .maximum = 255, /* check this value */&lt;BR /&gt; .step = 0x1, /* check this value */&lt;BR /&gt; .default_value = 127, /* check this value */&lt;BR /&gt; .flags = 0,&lt;BR /&gt; }&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;/***********************************************************************&lt;BR /&gt; * I2C transfert.&lt;BR /&gt; ***********************************************************************/&lt;/P&gt;&lt;P&gt;/*! Read one register from a ADV7180 i2c slave device.&lt;BR /&gt; *&lt;BR /&gt; * @param *reg register in the device we wish to access.&lt;BR /&gt; *&lt;BR /&gt; * @return 0 if success, an error code otherwise.&lt;BR /&gt; */&lt;BR /&gt;static inline int tw9900_read(u8 reg)&lt;BR /&gt;{&lt;BR /&gt; int val;&lt;BR /&gt; val = i2c_smbus_read_byte_data(tw9900_data.sen.i2c_client, reg);&lt;BR /&gt; if (val &amp;lt; 0) {&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; "%s:read reg error: reg=%2x\n", __func__, reg);&lt;BR /&gt; return -1;&lt;BR /&gt; }&lt;BR /&gt; return val;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*! Write one register of a ADV7180 i2c slave device.&lt;BR /&gt; *&lt;BR /&gt; * @param *reg register in the device we wish to access.&lt;BR /&gt; *&lt;BR /&gt; * @return 0 if success, an error code otherwise.&lt;BR /&gt; */&lt;BR /&gt;static int tw9900_write_reg(u8 reg,u8 val)&lt;BR /&gt;{&lt;BR /&gt; s32 ret;&lt;/P&gt;&lt;P&gt;ret = i2c_smbus_write_byte_data(tw9900_data.sen.i2c_client, reg, val);&lt;BR /&gt; if (ret &amp;lt; 0) {&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; "%s:write reg error:reg=%2x,val=%2x\n", __func__,&lt;BR /&gt; reg, val);&lt;BR /&gt; return -1;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/***********************************************************************&lt;BR /&gt; * mxc_v4l2_capture interface.&lt;BR /&gt; ***********************************************************************/&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * Return attributes of current video standard.&lt;BR /&gt; * Since this device autodetects the current standard, this function also&lt;BR /&gt; * sets the values that need to be changed if the standard changes.&lt;BR /&gt; * There is no set std equivalent function.&lt;BR /&gt; *&lt;BR /&gt; * @return None.&lt;BR /&gt; */&lt;BR /&gt;//static void adv7180_get_std(v4l2_std_id *std)&lt;BR /&gt;//{&lt;BR /&gt;// int tmp;&lt;BR /&gt;// int idx;&lt;/P&gt;&lt;P&gt;// dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev, "In adv7180_get_std\n");&lt;/P&gt;&lt;P&gt;/* Read the AD_RESULT to get the detect output video standard */&lt;BR /&gt;// tmp = adv7180_read(ADV7180_STATUS_1) &amp;amp; 0x70;&lt;/P&gt;&lt;P&gt;// mutex_lock(&amp;amp;mutex);&lt;BR /&gt;// if (tmp == 0x40) {&lt;BR /&gt; /* PAL */&lt;BR /&gt;// *std = V4L2_STD_PAL;&lt;BR /&gt;// idx = ADV7180_PAL;&lt;BR /&gt;// } else if (tmp == 0) {&lt;BR /&gt; /*NTSC*/&lt;BR /&gt;// *std = V4L2_STD_NTSC;&lt;BR /&gt;// idx = ADV7180_NTSC;&lt;BR /&gt;// } else {&lt;BR /&gt;// *std = V4L2_STD_ALL;&lt;BR /&gt;// idx = ADV7180_NOT_LOCKED;&lt;BR /&gt;// dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt;// "Got invalid video standard!\n");&lt;BR /&gt;// }&lt;BR /&gt;// mutex_unlock(&amp;amp;mutex);&lt;/P&gt;&lt;P&gt;/* This assumes autodetect which this device uses. */&lt;BR /&gt;// if (*std != adv7180_data.std_id) {&lt;BR /&gt;// video_idx = idx;&lt;BR /&gt;// adv7180_data.std_id = *std;&lt;BR /&gt;// adv7180_data.sen.pix.width = video_fmts[video_idx].raw_width;&lt;BR /&gt;// adv7180_data.sen.pix.height = video_fmts[video_idx].raw_height;&lt;BR /&gt;// }&lt;BR /&gt;//}&lt;BR /&gt;static void tw9900_get_std(v4l2_std_id *std)&lt;BR /&gt;{&lt;BR /&gt; int status_1, standard, idx;&lt;BR /&gt; bool locked;&lt;/P&gt;&lt;P&gt;dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In tw9900_get_std\n");&lt;BR /&gt; status_1 = tw9900_read(TW9900_STATUS_1);&lt;BR /&gt;#if 0&lt;BR /&gt; status_1 = tw9912_read(TW9912_STATUS_1);&lt;BR /&gt; locked = status_1 &amp;amp; 0x1;&lt;BR /&gt; standard = status_1 &amp;amp; 0x70;&lt;BR /&gt;#endif&lt;BR /&gt; mutex_lock(&amp;amp;mutex);&lt;BR /&gt; *std = V4L2_STD_ALL;&lt;BR /&gt; idx = tw9900_NOT_LOCKED;&lt;BR /&gt;&lt;BR /&gt; standard = 0;&lt;BR /&gt; locked = 1;&lt;BR /&gt; if (locked) {&lt;BR /&gt; if (standard == 0x40) {&lt;BR /&gt; *std = V4L2_STD_PAL;&lt;BR /&gt; idx = tw9900_PAL;&lt;BR /&gt; } else if (standard == 0) {&lt;BR /&gt; *std = V4L2_STD_NTSC;&lt;BR /&gt; idx = tw9900_NTSC;&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; mutex_unlock(&amp;amp;mutex);&lt;/P&gt;&lt;P&gt;/* This assumes autodetect which this device uses. */&lt;BR /&gt; if (*std != tw9900_data.std_id) {&lt;BR /&gt; video_idx = idx;&lt;BR /&gt; tw9900_data.std_id = *std;&lt;BR /&gt; tw9900_data.sen.pix.width = video_fmts[video_idx].raw_width;&lt;BR /&gt; tw9900_data.sen.pix.height = video_fmts[video_idx].raw_height;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/***********************************************************************&lt;BR /&gt; * IOCTL Functions from v4l2_int_ioctl_desc.&lt;BR /&gt; ***********************************************************************/&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_g_ifparm - V4L2 sensor interface handler for vidioc_int_g_ifparm_num&lt;BR /&gt; * s: pointer to standard V4L2 device structure&lt;BR /&gt; * p: pointer to standard V4L2 vidioc_int_g_ifparm_num ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * Gets slave interface parameters.&lt;BR /&gt; * Calculates the required xclk value to support the requested&lt;BR /&gt; * clock parameters in p. This value is returned in the p&lt;BR /&gt; * parameter.&lt;BR /&gt; *&lt;BR /&gt; * vidioc_int_g_ifparm returns platform-specific information about the&lt;BR /&gt; * interface settings used by the sensor.&lt;BR /&gt; *&lt;BR /&gt; * Called on open.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_g_ifparm(struct v4l2_int_device *s, struct v4l2_ifparm *p)&lt;BR /&gt;{&lt;BR /&gt; //dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev, "adv7180:ioctl_g_ifparm\n");&lt;BR /&gt; //printk("ioctl g ifparm is ==================================================\n");&lt;BR /&gt; if (s == NULL) {&lt;BR /&gt; pr_err(" ERROR!! no slave device set!\n");&lt;BR /&gt; return -1;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Initialize structure to 0s then set any non-0 values. */&lt;BR /&gt; memset(p, 0, sizeof(*p));&lt;BR /&gt; p-&amp;gt;if_type = V4L2_IF_TYPE_BT656; /* This is the only possibility. */&lt;BR /&gt; p-&amp;gt;u.bt656.mode = V4L2_IF_TYPE_BT656_MODE_NOBT_8BIT;&lt;BR /&gt; p-&amp;gt;u.bt656.nobt_hs_inv = 1;&lt;BR /&gt; p-&amp;gt;u.bt656.bt_sync_correct = 1;&lt;/P&gt;&lt;P&gt;/* ADV7180 has a dedicated clock so no clock settings needed. */&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * Sets the camera power.&lt;BR /&gt; *&lt;BR /&gt; * s pointer to the camera device&lt;BR /&gt; * on if 1, power is to be turned on. 0 means power is to be turned off&lt;BR /&gt; *&lt;BR /&gt; * ioctl_s_power - V4L2 sensor interface handler for vidioc_int_s_power_num&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @on: power state to which device is to be set&lt;BR /&gt; *&lt;BR /&gt; * Sets devices power state to requrested state, if possible.&lt;BR /&gt; * This is called on open, close, suspend and resume.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_s_power(struct v4l2_int_device *s, int on)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;//printk("ioctl s power is =======================================\n");&lt;BR /&gt; struct sensor *sensor = s-&amp;gt;priv;&lt;BR /&gt; sensor-&amp;gt;sen.on = on;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_g_parm - V4L2 sensor interface handler for VIDIOC_G_PARM ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * Returns the sensor's video CAPTURE parameters.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_g_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)&lt;BR /&gt;{&lt;BR /&gt; struct sensor *sensor = s-&amp;gt;priv;&lt;BR /&gt; struct v4l2_captureparm *cparm = &amp;amp;a-&amp;gt;parm.capture;&lt;/P&gt;&lt;P&gt;dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In tw9900:ioctl_g_parm\n");&lt;/P&gt;&lt;P&gt;switch (a-&amp;gt;type) {&lt;BR /&gt; /* These are all the possible cases. */&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_CAPTURE:&lt;BR /&gt; pr_debug(" type is V4L2_BUF_TYPE_VIDEO_CAPTURE\n");&lt;BR /&gt; memset(a, 0, sizeof(*a));&lt;BR /&gt; a-&amp;gt;type = V4L2_BUF_TYPE_VIDEO_CAPTURE;&lt;BR /&gt; cparm-&amp;gt;capability = sensor-&amp;gt;sen.streamcap.capability;&lt;BR /&gt; cparm-&amp;gt;timeperframe = sensor-&amp;gt;sen.streamcap.timeperframe;&lt;BR /&gt; cparm-&amp;gt;capturemode = sensor-&amp;gt;sen.streamcap.capturemode;&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;case V4L2_BUF_TYPE_VIDEO_OUTPUT:&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_OVERLAY:&lt;BR /&gt; case V4L2_BUF_TYPE_VBI_CAPTURE:&lt;BR /&gt; case V4L2_BUF_TYPE_VBI_OUTPUT:&lt;BR /&gt; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:&lt;BR /&gt; case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;default:&lt;BR /&gt; pr_debug("ioctl_g_parm:type is unknown %d\n", a-&amp;gt;type);&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_s_parm - V4L2 sensor interface handler for VIDIOC_S_PARM ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @a: pointer to standard V4L2 VIDIOC_S_PARM ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * Configures the sensor to use the input parameters, if possible. If&lt;BR /&gt; * not possible, reverts to the old parameters and returns the&lt;BR /&gt; * appropriate error code.&lt;BR /&gt; *&lt;BR /&gt; * This driver cannot change these settings.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_s_parm(struct v4l2_int_device *s, struct v4l2_streamparm *a)&lt;BR /&gt;{&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In tw9900:ioctl_s_parm\n");&lt;/P&gt;&lt;P&gt;switch (a-&amp;gt;type) {&lt;BR /&gt; /* These are all the possible cases. */&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_CAPTURE:&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_OUTPUT:&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_OVERLAY:&lt;BR /&gt; case V4L2_BUF_TYPE_VBI_CAPTURE:&lt;BR /&gt; case V4L2_BUF_TYPE_VBI_OUTPUT:&lt;BR /&gt; case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:&lt;BR /&gt; case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;default:&lt;BR /&gt; pr_debug(" type is unknown - %d\n", a-&amp;gt;type);&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_g_fmt_cap - V4L2 sensor interface handler for ioctl_g_fmt_cap&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @f: pointer to standard V4L2 v4l2_format structure&lt;BR /&gt; *&lt;BR /&gt; * Returns the sensor's current pixel format in the v4l2_format&lt;BR /&gt; * parameter.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_g_fmt_cap(struct v4l2_int_device *s, struct v4l2_format *f)&lt;BR /&gt;{&lt;BR /&gt; struct sensor *sensor = s-&amp;gt;priv;&lt;BR /&gt; int val=0;&lt;/P&gt;&lt;P&gt;//dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev, "adv7180:ioctl_g_fmt_cap\n");&lt;/P&gt;&lt;P&gt;switch (f-&amp;gt;type) {&lt;BR /&gt; case V4L2_BUF_TYPE_VIDEO_CAPTURE:&lt;BR /&gt; pr_debug(" Returning size of %dx%d\n",&lt;BR /&gt; sensor-&amp;gt;sen.pix.width, sensor-&amp;gt;sen.pix.height);&lt;BR /&gt; f-&amp;gt;fmt.pix = sensor-&amp;gt;sen.pix;&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;case V4L2_BUF_TYPE_PRIVATE: {&lt;BR /&gt; v4l2_std_id std;&lt;BR /&gt; tw9900_get_std(&amp;amp;std);&lt;BR /&gt; f-&amp;gt;fmt.pix.pixelformat = (u32)std;&lt;BR /&gt; }&lt;BR /&gt; break;&lt;/P&gt;&lt;P&gt;// case V4L2_BUF_TYPE_BRIGHTNESS:&lt;BR /&gt;// val = tw9900_read(TW9900_BRIGHTNESS);&lt;BR /&gt;// f-&amp;gt;fmt.pix.pixelformat = (u32)val;&lt;BR /&gt;// //vc-&amp;gt;value = tw9900_data.sen.brightness;&lt;BR /&gt;// break;&lt;BR /&gt;// case V4L2_BUF_TYPE_CONTRAST:&lt;BR /&gt;// val = tw9900_read(TW9900_CONTRAST);&lt;BR /&gt;// f-&amp;gt;fmt.pix.pixelformat = (u32)val;&lt;BR /&gt;// break;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; default:&lt;BR /&gt; f-&amp;gt;fmt.pix = sensor-&amp;gt;sen.pix;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_queryctrl - V4L2 sensor interface handler for VIDIOC_QUERYCTRL ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @qc: standard V4L2 VIDIOC_QUERYCTRL ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * If the requested control is supported, returns the control information&lt;BR /&gt; * from the video_control[] array. Otherwise, returns -EINVAL if the&lt;BR /&gt; * control is not supported.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_queryctrl(struct v4l2_int_device *s,&lt;BR /&gt; struct v4l2_queryctrl *qc)&lt;BR /&gt;{&lt;BR /&gt; int i;&lt;/P&gt;&lt;P&gt;dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "adv7180:ioctl_queryctrl\n");&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; ARRAY_SIZE(tw9900_qctrl); i++)&lt;BR /&gt; if (qc-&amp;gt;id &amp;amp;&amp;amp; qc-&amp;gt;id == tw9900_qctrl[i].id) {&lt;BR /&gt; memcpy(qc, &amp;amp;(tw9900_qctrl[i]),&lt;BR /&gt; sizeof(*qc));&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return -EINVAL;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_g_ctrl - V4L2 sensor interface handler for VIDIOC_G_CTRL ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @vc: standard V4L2 VIDIOC_G_CTRL ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * If the requested control is supported, returns the control's current&lt;BR /&gt; * value from the video_control[] array. Otherwise, returns -EINVAL&lt;BR /&gt; * if the control is not supported.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_g_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)&lt;BR /&gt;{&lt;BR /&gt; int ret = 0;&lt;BR /&gt; int sat = 0;&lt;/P&gt;&lt;P&gt;dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In tw9900:ioctl_g_ctrl\n");&lt;/P&gt;&lt;P&gt;switch (vc-&amp;gt;id) {&lt;BR /&gt; case V4L2_CID_BRIGHTNESS:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_BRIGHTNESS\n");&lt;BR /&gt; tw9900_data.sen.brightness = tw9900_read(TW9900_BRIGHTNESS);&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.brightness;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_CONTRAST://add contrast - yongseok&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_CONTRAST\n");&lt;BR /&gt; tw9900_data.sen.contrast = tw9900_read(TW9900_CONTRAST);&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.contrast;&lt;BR /&gt;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_SATURATION:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_SATURATION\n");&lt;BR /&gt; sat = tw9900_read(TW9900_SD_SATURATION_CB);&lt;BR /&gt; tw9900_data.sen.saturation = sat;&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.saturation;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_HUE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_HUE\n");&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.hue;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_AUTO_WHITE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_AUTO_WHITE_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_DO_WHITE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_DO_WHITE_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_RED_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_RED_BALANCE\n");&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.red;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_BLUE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_BLUE_BALANCE\n");&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.blue;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_GAMMA:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_GAMMA\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_EXPOSURE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_EXPOSURE\n");&lt;BR /&gt; vc-&amp;gt;value = tw9900_data.sen.ae_mode;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_AUTOGAIN:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_AUTOGAIN\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_GAIN:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_GAIN\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_HFLIP:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_HFLIP\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_VFLIP:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_VFLIP\n");&lt;BR /&gt; break;&lt;BR /&gt; default:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " Default case\n");&lt;BR /&gt; vc-&amp;gt;value = 0;&lt;BR /&gt; ret = -EPERM;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return ret;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_s_ctrl - V4L2 sensor interface handler for VIDIOC_S_CTRL ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @vc: standard V4L2 VIDIOC_S_CTRL ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * If the requested control is supported, sets the control's current&lt;BR /&gt; * value in HW (and updates the video_control[] array). Otherwise,&lt;BR /&gt; * returns -EINVAL if the control is not supported.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)&lt;BR /&gt;{&lt;BR /&gt; int retval = 0;&lt;BR /&gt; u8 tmp;&lt;/P&gt;&lt;P&gt;dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In tw9900:ioctl_s_ctrl\n");&lt;/P&gt;&lt;P&gt;switch (vc-&amp;gt;id) {&lt;BR /&gt; case V4L2_CID_BRIGHTNESS:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_BRIGHTNESS\n");&lt;BR /&gt; tmp = vc-&amp;gt;value;&lt;BR /&gt; tw9900_write_reg(TW9900_BRIGHTNESS, tmp);&lt;BR /&gt; tw9900_data.sen.brightness = vc-&amp;gt;value;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_CONTRAST: // add contrast - yongseok&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_CONTRAST\n");&lt;BR /&gt; tmp = vc-&amp;gt;value;&lt;BR /&gt; tw9900_write_reg(TW9900_CONTRAST, tmp);&lt;BR /&gt; tw9900_data.sen.contrast = vc-&amp;gt;value;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_SATURATION:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_SATURATION\n");&lt;BR /&gt; tmp = vc-&amp;gt;value;&lt;BR /&gt; tw9900_write_reg(TW9900_SD_SATURATION_CB, tmp);&lt;BR /&gt; tw9900_write_reg(TW9900_SD_SATURATION_CR, tmp);&lt;BR /&gt; tw9900_data.sen.saturation = vc-&amp;gt;value;&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_HUE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_HUE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_AUTO_WHITE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_AUTO_WHITE_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_DO_WHITE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_DO_WHITE_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_RED_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_RED_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_BLUE_BALANCE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_BLUE_BALANCE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_GAMMA:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_GAMMA\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_EXPOSURE:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_EXPOSURE\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_AUTOGAIN:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_AUTOGAIN\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_GAIN:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_GAIN\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_HFLIP:&lt;BR /&gt; printk("____________________________________________________________ \n");&lt;BR /&gt; printk("_________________________ TW9900 ___________________________ \n");&lt;BR /&gt; printk("----------------- case V4L2_CID_HFLIP: --------------------- \n");&lt;BR /&gt; printk("____________________________________________________________ \n");&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_HFLIP\n");&lt;BR /&gt; break;&lt;BR /&gt; case V4L2_CID_VFLIP:&lt;BR /&gt; printk("____________________________________________________________ \n");&lt;BR /&gt; printk("_________________________ TW9900 ___________________________ \n");&lt;BR /&gt; printk("----------------- case V4L2_CID_VFLIP: --------------------- \n");&lt;BR /&gt; printk("____________________________________________________________ \n");&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " V4L2_CID_VFLIP\n");&lt;BR /&gt; break;&lt;BR /&gt; default:&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev,&lt;BR /&gt; " Default case\n");&lt;BR /&gt; retval = -EPERM;&lt;BR /&gt; break;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return retval;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_enum_framesizes - V4L2 sensor interface handler for&lt;BR /&gt; * VIDIOC_ENUM_FRAMESIZES ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @fsize: standard V4L2 VIDIOC_ENUM_FRAMESIZES ioctl structure&lt;BR /&gt; *&lt;BR /&gt; * Return 0 if successful, otherwise -EINVAL.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_enum_framesizes(struct v4l2_int_device *s,&lt;BR /&gt; struct v4l2_frmsizeenum *fsize)&lt;BR /&gt;{&lt;BR /&gt; if (fsize-&amp;gt;index &amp;gt;= 1)&lt;BR /&gt; return -EINVAL;&lt;/P&gt;&lt;P&gt;fsize-&amp;gt;discrete.width = video_fmts[video_idx].active_width;&lt;BR /&gt; fsize-&amp;gt;discrete.height = video_fmts[video_idx].active_height;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_g_chip_ident - V4L2 sensor interface handler for&lt;BR /&gt; * VIDIOC_DBG_G_CHIP_IDENT ioctl&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; * @id: pointer to int&lt;BR /&gt; *&lt;BR /&gt; * Return 0.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_g_chip_ident(struct v4l2_int_device *s, int *id)&lt;BR /&gt;{&lt;BR /&gt; ((struct v4l2_dbg_chip_ident *)id)-&amp;gt;match.type =&lt;BR /&gt; V4L2_CHIP_MATCH_I2C_DRIVER;&lt;BR /&gt; strcpy(((struct v4l2_dbg_chip_ident *)id)-&amp;gt;match.name,&lt;BR /&gt; "tw9900_decoder");&lt;BR /&gt; ((struct v4l2_dbg_chip_ident *)id)-&amp;gt;ident = V4L2_IDENT_TW9900;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_init - V4L2 sensor interface handler for VIDIOC_INT_INIT&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_init(struct v4l2_int_device *s)&lt;BR /&gt;{&lt;BR /&gt; //dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev, "In adv7180:ioctl_init\n");&lt;/P&gt;&lt;P&gt;//printk("ioctl init is ================================================\n");&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ioctl_dev_init - V4L2 sensor interface handler for vidioc_int_dev_init_num&lt;BR /&gt; * @s: pointer to standard V4L2 device structure&lt;BR /&gt; *&lt;BR /&gt; * Initialise the device when slave attaches to the master.&lt;BR /&gt; */&lt;BR /&gt;static int ioctl_dev_init(struct v4l2_int_device *s)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;//printk("ioctl dev init====================================================\n");&lt;BR /&gt; //dev_dbg(&amp;amp;adv7180_data.sen.i2c_client-&amp;gt;dev, "adv7180:ioctl_dev_init\n");&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * This structure defines all the ioctls for this module.&lt;BR /&gt; */&lt;BR /&gt;static struct v4l2_int_ioctl_desc tw9900_ioctl_desc[] = {&lt;/P&gt;&lt;P&gt;{vidioc_int_dev_init_num, (v4l2_int_ioctl_func*)ioctl_dev_init},&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * Delinitialise the dev. at slave detach.&lt;BR /&gt; * The complement of ioctl_dev_init.&lt;BR /&gt; */&lt;BR /&gt;/* {vidioc_int_dev_exit_num, (v4l2_int_ioctl_func *)ioctl_dev_exit}, */&lt;/P&gt;&lt;P&gt;{vidioc_int_s_power_num, (v4l2_int_ioctl_func*)ioctl_s_power},&lt;BR /&gt; {vidioc_int_g_ifparm_num, (v4l2_int_ioctl_func*)ioctl_g_ifparm},&lt;BR /&gt;/* {vidioc_int_g_needs_reset_num,&lt;BR /&gt; (v4l2_int_ioctl_func *)ioctl_g_needs_reset}, */&lt;BR /&gt;/* {vidioc_int_reset_num, (v4l2_int_ioctl_func *)ioctl_reset}, */&lt;BR /&gt; {vidioc_int_init_num, (v4l2_int_ioctl_func*)ioctl_init},&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * VIDIOC_ENUM_FMT ioctl for the CAPTURE buffer type.&lt;BR /&gt; */&lt;BR /&gt;/* {vidioc_int_enum_fmt_cap_num,&lt;BR /&gt; (v4l2_int_ioctl_func *)ioctl_enum_fmt_cap}, */&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type.&lt;BR /&gt; * This ioctl is used to negotiate the image capture size and&lt;BR /&gt; * pixel format without actually making it take effect.&lt;BR /&gt; */&lt;BR /&gt;/* {vidioc_int_try_fmt_cap_num,&lt;BR /&gt; (v4l2_int_ioctl_func *)ioctl_try_fmt_cap}, */&lt;/P&gt;&lt;P&gt;{vidioc_int_g_fmt_cap_num, (v4l2_int_ioctl_func*)ioctl_g_fmt_cap},&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * If the requested format is supported, configures the HW to use that&lt;BR /&gt; * format, returns error code if format not supported or HW can't be&lt;BR /&gt; * correctly configured.&lt;BR /&gt; */&lt;BR /&gt;/* {vidioc_int_s_fmt_cap_num, (v4l2_int_ioctl_func *)ioctl_s_fmt_cap}, */&lt;/P&gt;&lt;P&gt;{vidioc_int_g_parm_num, (v4l2_int_ioctl_func*)ioctl_g_parm},&lt;BR /&gt; {vidioc_int_s_parm_num, (v4l2_int_ioctl_func*)ioctl_s_parm},&lt;BR /&gt; {vidioc_int_queryctrl_num, (v4l2_int_ioctl_func*)ioctl_queryctrl},&lt;BR /&gt; {vidioc_int_g_ctrl_num, (v4l2_int_ioctl_func*)ioctl_g_ctrl},&lt;BR /&gt; {vidioc_int_s_ctrl_num, (v4l2_int_ioctl_func*)ioctl_s_ctrl},&lt;BR /&gt; {vidioc_int_enum_framesizes_num,&lt;BR /&gt; (v4l2_int_ioctl_func *) ioctl_enum_framesizes},&lt;BR /&gt; {vidioc_int_g_chip_ident_num,&lt;BR /&gt; (v4l2_int_ioctl_func *)ioctl_g_chip_ident},&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static struct v4l2_int_slave tw9900_slave = {&lt;BR /&gt; .ioctls = tw9900_ioctl_desc,&lt;BR /&gt; .num_ioctls = ARRAY_SIZE(tw9900_ioctl_desc),&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static struct v4l2_int_device tw9900_int_device = {&lt;BR /&gt; .module = THIS_MODULE,&lt;BR /&gt; .name = "tw9900",&lt;BR /&gt; .type = v4l2_int_type_slave,&lt;BR /&gt; .u = {&lt;BR /&gt; .slave = &amp;amp;tw9900_slave,&lt;BR /&gt; },&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/***********************************************************************&lt;BR /&gt; * I2C client and driver.&lt;BR /&gt; ***********************************************************************/&lt;/P&gt;&lt;P&gt;/*! ADV7180 Reset function.&lt;BR /&gt; *&lt;BR /&gt; * @return None.&lt;BR /&gt; */&lt;BR /&gt;static void tw9900_hard_reset()&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;tw9900_write_reg(0x00, 0x00);&lt;BR /&gt; tw9900_write_reg(0x01, 0x78);&lt;BR /&gt; tw9900_write_reg(0x02, 0x40);&lt;BR /&gt; tw9900_write_reg(0x03, 0xA2);&lt;BR /&gt; tw9900_write_reg(0x04, 0x00);&lt;BR /&gt; tw9900_write_reg(0x05, 0x01);&lt;BR /&gt; tw9900_write_reg(0x06, 0x00);&lt;BR /&gt; tw9900_write_reg(0x07, 0x02);&lt;BR /&gt; tw9900_write_reg(0x08, 0x12);&lt;BR /&gt; tw9900_write_reg(0x09, 0xf4);&lt;BR /&gt; tw9900_write_reg(0x0A, 0x10);&lt;BR /&gt; tw9900_write_reg(0x0B, 0xD0);&lt;BR /&gt; tw9900_write_reg(0x0C, 0xCC);&lt;BR /&gt; tw9900_write_reg(0x0D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x0E, 0x11);&lt;BR /&gt; tw9900_write_reg(0x0F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x10, 0x00);&lt;BR /&gt; tw9900_write_reg(0x11, 0x64);&lt;BR /&gt; tw9900_write_reg(0x12, 0x11);&lt;BR /&gt; tw9900_write_reg(0x13, 0x80);&lt;BR /&gt; tw9900_write_reg(0x14, 0x80);&lt;BR /&gt; tw9900_write_reg(0x15, 0x00);&lt;BR /&gt; tw9900_write_reg(0x16, 0x00);&lt;BR /&gt; tw9900_write_reg(0x17, 0x30);&lt;BR /&gt; tw9900_write_reg(0x18, 0x44);&lt;BR /&gt; tw9900_write_reg(0x19, 0x57);&lt;BR /&gt; tw9900_write_reg(0x1A, 0x0F);&lt;BR /&gt; tw9900_write_reg(0x1B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x1C, 0x07);&lt;BR /&gt; tw9900_write_reg(0x1D, 0x7F);&lt;BR /&gt; tw9900_write_reg(0x1E, 0x08);&lt;BR /&gt; tw9900_write_reg(0x1F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x20, 0x50);&lt;BR /&gt; tw9900_write_reg(0x21, 0x42);&lt;BR /&gt; tw9900_write_reg(0x22, 0xF0);&lt;BR /&gt; tw9900_write_reg(0x23, 0xD8);&lt;BR /&gt; tw9900_write_reg(0x24, 0xBC);&lt;BR /&gt; tw9900_write_reg(0x25, 0xB8);&lt;BR /&gt; tw9900_write_reg(0x26, 0x44);&lt;BR /&gt; tw9900_write_reg(0x27, 0x2A);&lt;BR /&gt; tw9900_write_reg(0x28, 0x00);&lt;BR /&gt; tw9900_write_reg(0x29, 0x03);&lt;BR /&gt; tw9900_write_reg(0x2A, 0x78);&lt;BR /&gt; tw9900_write_reg(0x2B, 0x44);&lt;BR /&gt; tw9900_write_reg(0x2C, 0x30);&lt;BR /&gt; tw9900_write_reg(0x2D, 0x07);&lt;BR /&gt; tw9900_write_reg(0x2E, 0xA5);&lt;BR /&gt; tw9900_write_reg(0x2F, 0xE0);&lt;BR /&gt; tw9900_write_reg(0x30, 0x00);&lt;BR /&gt; tw9900_write_reg(0x31, 0x10);&lt;BR /&gt; tw9900_write_reg(0x32, 0xFF);&lt;BR /&gt; tw9900_write_reg(0x33, 0x05);&lt;BR /&gt; tw9900_write_reg(0x34, 0x1A);&lt;BR /&gt; tw9900_write_reg(0x35, 0x80);&lt;BR /&gt; tw9900_write_reg(0x36, 0x00);&lt;BR /&gt; tw9900_write_reg(0x37, 0x00);&lt;BR /&gt; tw9900_write_reg(0x38, 0x00);&lt;BR /&gt; tw9900_write_reg(0x39, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3C, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x3F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x40, 0x00);&lt;BR /&gt; tw9900_write_reg(0x41, 0x00);&lt;BR /&gt; tw9900_write_reg(0x42, 0x00);&lt;BR /&gt; tw9900_write_reg(0x43, 0x00);&lt;BR /&gt; tw9900_write_reg(0x44, 0x00);&lt;BR /&gt; tw9900_write_reg(0x45, 0x00);&lt;BR /&gt; tw9900_write_reg(0x46, 0x00);&lt;BR /&gt; tw9900_write_reg(0x47, 0x00);&lt;BR /&gt; tw9900_write_reg(0x48, 0x00);&lt;BR /&gt; tw9900_write_reg(0x49, 0x00);&lt;BR /&gt; tw9900_write_reg(0x4A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x4B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x4C, 0x05);&lt;BR /&gt; tw9900_write_reg(0x4D, 0x40);&lt;BR /&gt; tw9900_write_reg(0x4E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x4F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x50, 0xA0);&lt;BR /&gt; tw9900_write_reg(0x51, 0x22);&lt;BR /&gt; tw9900_write_reg(0x52, 0x31);&lt;BR /&gt; tw9900_write_reg(0x53, 0x80);&lt;BR /&gt; tw9900_write_reg(0x54, 0x00);&lt;BR /&gt; tw9900_write_reg(0x55, 0x00);&lt;BR /&gt; tw9900_write_reg(0x56, 0x00);&lt;BR /&gt; tw9900_write_reg(0x57, 0x00);&lt;BR /&gt; tw9900_write_reg(0x58, 0x00);&lt;BR /&gt; tw9900_write_reg(0x59, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5C, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x5F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x60, 0x00);&lt;BR /&gt; tw9900_write_reg(0x61, 0x00);&lt;BR /&gt; tw9900_write_reg(0x62, 0x00);&lt;BR /&gt; tw9900_write_reg(0x63, 0x00);&lt;BR /&gt; tw9900_write_reg(0x64, 0x00);&lt;BR /&gt; tw9900_write_reg(0x65, 0x00);&lt;BR /&gt; tw9900_write_reg(0x66, 0x00);&lt;BR /&gt; tw9900_write_reg(0x67, 0x00);&lt;BR /&gt; tw9900_write_reg(0x68, 0x00);&lt;BR /&gt; tw9900_write_reg(0x69, 0x00);&lt;BR /&gt; tw9900_write_reg(0x6A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x6B, 0x09);&lt;BR /&gt; tw9900_write_reg(0x6C, 0x19);&lt;BR /&gt; tw9900_write_reg(0x6D, 0x0A);&lt;BR /&gt; tw9900_write_reg(0x6E, 0x20);&lt;BR /&gt; tw9900_write_reg(0x6F, 0x13);&lt;BR /&gt; tw9900_write_reg(0x70, 0x00);&lt;BR /&gt; tw9900_write_reg(0x71, 0x00);&lt;BR /&gt; tw9900_write_reg(0x72, 0x00);&lt;BR /&gt; tw9900_write_reg(0x73, 0x00);&lt;BR /&gt; tw9900_write_reg(0x74, 0x00);&lt;BR /&gt; tw9900_write_reg(0x75, 0x00);&lt;BR /&gt; tw9900_write_reg(0x76, 0x00);&lt;BR /&gt; tw9900_write_reg(0x77, 0x00);&lt;BR /&gt; tw9900_write_reg(0x78, 0x00);&lt;BR /&gt; tw9900_write_reg(0x79, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7C, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x7F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x80, 0x00);&lt;BR /&gt; tw9900_write_reg(0x81, 0x00);&lt;BR /&gt; tw9900_write_reg(0x82, 0x00);&lt;BR /&gt; tw9900_write_reg(0x83, 0x00);&lt;BR /&gt; tw9900_write_reg(0x84, 0x00);&lt;BR /&gt; tw9900_write_reg(0x85, 0x00);&lt;BR /&gt; tw9900_write_reg(0x86, 0x00);&lt;BR /&gt; tw9900_write_reg(0x87, 0x00);&lt;BR /&gt; tw9900_write_reg(0x88, 0x00);&lt;BR /&gt; tw9900_write_reg(0x89, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8C, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x8F, 0x00);&lt;BR /&gt; tw9900_write_reg(0x90, 0x00);&lt;BR /&gt; tw9900_write_reg(0x91, 0x00);&lt;BR /&gt; tw9900_write_reg(0x92, 0x00);&lt;BR /&gt; tw9900_write_reg(0x93, 0x00);&lt;BR /&gt; tw9900_write_reg(0x94, 0x00);&lt;BR /&gt; tw9900_write_reg(0x95, 0x00);&lt;BR /&gt; tw9900_write_reg(0x96, 0x00);&lt;BR /&gt; tw9900_write_reg(0x97, 0x00);&lt;BR /&gt; tw9900_write_reg(0x98, 0x00);&lt;BR /&gt; tw9900_write_reg(0x99, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9A, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9B, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9C, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9D, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9E, 0x00);&lt;BR /&gt; tw9900_write_reg(0x9F, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA0, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA7, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xA9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xAA, 0x00);&lt;BR /&gt; tw9900_write_reg(0xAB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xAC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xAD, 0x00);&lt;BR /&gt; tw9900_write_reg(0xAE, 0x1A);&lt;BR /&gt; tw9900_write_reg(0xAF, 0x80);&lt;BR /&gt; tw9900_write_reg(0xB0, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB7, 0x06);&lt;BR /&gt; tw9900_write_reg(0xB8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xB9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xBA, 0x57);&lt;BR /&gt; tw9900_write_reg(0xBB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xBC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xBD, 0x80);&lt;BR /&gt; tw9900_write_reg(0xBE, 0x80);&lt;BR /&gt; tw9900_write_reg(0xBF, 0x80);&lt;BR /&gt; tw9900_write_reg(0xC0, 0x80);&lt;BR /&gt; tw9900_write_reg(0xC1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC7, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xC9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCA, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCD, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCE, 0x00);&lt;BR /&gt; tw9900_write_reg(0xCF, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD0, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD7, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xD9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDA, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDD, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDE, 0x00);&lt;BR /&gt; tw9900_write_reg(0xDF, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE0, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE7, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xE9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xEA, 0x00);&lt;BR /&gt; tw9900_write_reg(0xEB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xEC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xED, 0x00);&lt;BR /&gt; tw9900_write_reg(0xEE, 0x00);&lt;BR /&gt; tw9900_write_reg(0xEF, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF0, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF1, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF2, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF3, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF4, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF5, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF6, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF7, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF8, 0x00);&lt;BR /&gt; tw9900_write_reg(0xF9, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFA, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFB, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFC, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFD, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFE, 0x00);&lt;BR /&gt; tw9900_write_reg(0xFF, 0x00);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/*! ADV7180 I2C attach function.&lt;BR /&gt; *&lt;BR /&gt; * @param *adapter struct i2c_adapter *.&lt;BR /&gt; *&lt;BR /&gt; * @return Error code indicating success or failure.&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ADV7180 I2C probe function.&lt;BR /&gt; * Function set in i2c_driver struct.&lt;BR /&gt; * Called by insmod.&lt;BR /&gt; *&lt;BR /&gt; * @param *adapter I2C adapter descriptor.&lt;BR /&gt; *&lt;BR /&gt; * @return Error code indicating success or failure.&lt;BR /&gt; */&lt;BR /&gt;static int tw9900_probe(struct i2c_client *client,&lt;BR /&gt; const struct i2c_device_id *id)&lt;BR /&gt;{&lt;BR /&gt; int rev_id;&lt;BR /&gt; int ret = 0;&lt;BR /&gt; int regfcnt = 0;&lt;BR /&gt;&lt;BR /&gt; tvin_plat = client-&amp;gt;dev.platform_data;&lt;/P&gt;&lt;P&gt;//printk(KERN_ERR"DBG sensor data is at %p\n", &amp;amp;adv7180_data);&lt;/P&gt;&lt;P&gt;//printk("In tw9900_probe new =========================================\n");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; //printk("enter into tvin plat io init==============\n");&lt;BR /&gt; if (tvin_plat-&amp;gt;io_init){&lt;BR /&gt; tvin_plat-&amp;gt;io_init();&lt;BR /&gt; printk("end into io init==============================\n");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;//printk("out into tvin plat io init============================\n");&lt;/P&gt;&lt;P&gt;//if (tvin_plat-&amp;gt;reset)&lt;BR /&gt; //tvin_plat-&amp;gt;reset();&lt;/P&gt;&lt;P&gt;//if (tvin_plat-&amp;gt;pwdn)&lt;BR /&gt; //tvin_plat-&amp;gt;pwdn(0); //\D7\EE\BA\F3\D0޸\B4ƽ̨\CA\FD\BE\DD&lt;/P&gt;&lt;P&gt;msleep(1);&lt;/P&gt;&lt;P&gt;/* Set initial values for the sensor struct. */&lt;BR /&gt; memset(&amp;amp;tw9900_data, 0, sizeof(tw9900_data));&lt;BR /&gt; tw9900_data.sen.i2c_client = client;&lt;BR /&gt; tw9900_data.sen.streamcap.timeperframe.denominator = 60;&lt;BR /&gt; tw9900_data.sen.streamcap.timeperframe.numerator = 1;&lt;BR /&gt; tw9900_data.std_id = V4L2_STD_ALL;&lt;BR /&gt;#ifdef NTSC_FIX&lt;BR /&gt; video_idx = tw9900_NTSC;&lt;BR /&gt;#else&lt;BR /&gt; video_idx = tw9900_NOT_LOCKED;&lt;BR /&gt;#endif&lt;BR /&gt; tw9900_data.sen.pix.width = video_fmts[video_idx].raw_width;&lt;BR /&gt; tw9900_data.sen.pix.height = video_fmts[video_idx].raw_height;&lt;BR /&gt; tw9900_data.sen.pix.pixelformat = V4L2_PIX_FMT_UYVY; /* YUV422 */&lt;BR /&gt; tw9900_data.sen.pix.priv = 1; /* 1 is used to indicate TV in */&lt;BR /&gt; tw9900_data.sen.on = true;&lt;BR /&gt; gpio_sensor_active();&lt;/P&gt;&lt;P&gt;/*! Read the revision ID of the tvin chip */&lt;BR /&gt; rev_id = tw9900_read(TW9900_IDENT);&lt;BR /&gt; //dev_dbg(dev,&lt;BR /&gt; // "%s:Analog Device TW99%d detected!\n", __func__,&lt;BR /&gt; // GET_ID(rev_id));&lt;/P&gt;&lt;P&gt;/*! ADV7180 initialization. */&lt;BR /&gt; tw9900_hard_reset();&lt;/P&gt;&lt;P&gt;/* This function attaches this structure to the /dev/video0 device.&lt;BR /&gt; * The pointer in priv points to the mt9v111_data structure here.*/&lt;BR /&gt; tw9900_int_device.priv = &amp;amp;tw9900_data;&lt;BR /&gt; ret = v4l2_int_device_register(&amp;amp;tw9900_int_device);&lt;/P&gt;&lt;P&gt;return ret;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ADV7180 I2C detach function.&lt;BR /&gt; * Called on rmmod.&lt;BR /&gt; *&lt;BR /&gt; * @param *client struct i2c_client*.&lt;BR /&gt; *&lt;BR /&gt; * @return Error code indicating success or failure.&lt;BR /&gt; */&lt;BR /&gt;static int tw9900_detach(struct i2c_client *client)&lt;BR /&gt;{&lt;BR /&gt; v4l2_int_device_unregister(&amp;amp;tw9900_int_device);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ADV7180 init function.&lt;BR /&gt; * Called on insmod.&lt;BR /&gt; *&lt;BR /&gt; * @return Error code indicating success or failure.&lt;BR /&gt; */&lt;BR /&gt;static __init int tw9900_init(void)&lt;BR /&gt;{&lt;BR /&gt; u8 err = 0;&lt;/P&gt;&lt;P&gt;pr_debug("In tw9900_init\n");&lt;/P&gt;&lt;P&gt;/* Tells the i2c driver what functions to call for this driver. */&lt;BR /&gt; err = i2c_add_driver(&amp;amp;tw9900_i2c_driver);&lt;BR /&gt; if (err != 0)&lt;BR /&gt; pr_err("%s:driver registration failed, error=%d \n",&lt;BR /&gt; __func__, err);&lt;/P&gt;&lt;P&gt;return err;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt; * ADV7180 cleanup function.&lt;BR /&gt; * Called on rmmod.&lt;BR /&gt; *&lt;BR /&gt; * @return Error code indicating success or failure.&lt;BR /&gt; */&lt;BR /&gt;static void __exit tw9900_clean(void)&lt;BR /&gt;{&lt;BR /&gt; dev_dbg(&amp;amp;tw9900_data.sen.i2c_client-&amp;gt;dev, "In adv7180_clean\n");&lt;BR /&gt; i2c_del_driver(&amp;amp;tw9900_i2c_driver);&lt;BR /&gt; gpio_sensor_inactive();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;module_init(tw9900_init);&lt;BR /&gt;module_exit(tw9900_clean);&lt;/P&gt;&lt;P&gt;MODULE_AUTHOR("Freescale Semiconductor");&lt;BR /&gt;MODULE_DESCRIPTION("Anolog Device ADV7180 video decoder driver");&lt;BR /&gt;MODULE_LICENSE("GPL");&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 02:03:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Camera-quality-and-strange-line/m-p/866342#M131900</guid>
      <dc:creator>호영노</dc:creator>
      <dc:date>2019-03-05T02:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Camera quality and strange line</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Camera-quality-and-strange-line/m-p/866343#M131901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi 호영 노&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one can try suggestions provided on&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="link-titled" href="https://community.nxp.com/message/626177?commentID=626177#comment-626177" title="https://community.nxp.com/message/626177?commentID=626177#comment-626177"&gt;https://community.nxp.com/message/626177?commentID=626177#comment-626177&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;igor&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Mar 2019 05:45:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Camera-quality-and-strange-line/m-p/866343#M131901</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2019-03-05T05:45:28Z</dc:date>
    </item>
  </channel>
</rss>

