Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    A133 VIN连接AHD芯片请教

    其它全志芯片讨论区
    2
    5
    2169
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wupaul2001 LV 4 last edited by whycan

      大佬们好,我使用A133的MIPI连接AHD芯片时遇到以下问题。

      这是使用V4L2调用后的打印
      9bfd0d31-a1cd-4493-a447-db89b6d4627d-image.png

      这是设备树的配置

      		vind0:vind@0 {
      			vind0_clk = <336000000>;
      			vind0_isp = <300000000>;
      			status = "okay";
      
      			actuator0:actuator@0 {
      				device_type = "actuator0";
      				actuator0_name = "ad5820_act";
      				actuator0_slave = <0x18>;
      				actuator0_af_pwdn = <>;
      				actuator0_afvdd = "afvcc-csi";
      				actuator0_afvdd_vol = <2800000>;
      				status = "disabled";
      			};
      			flash0:flash@0 {
      				device_type = "flash0";
      				flash0_type = <2>;
      				flash0_en = <&r_pio PL 11 1 0 1 0>;
      				flash0_mode = <>;
      				flash0_flvdd = "";
      				flash0_flvdd_vol = <>;
      				device_id = <0>;
      				status = "disabled";
      			};
      			sensor0:sensor@0 {
      				device_type = "sensor0";
      				sensor0_mname = "xs9922_mipi";
      				sensor0_twi_cci_id = <2>;
      				sensor0_twi_addr = <0x60>;
      				sensor0_mclk_id = <0>;
      				sensor0_pos = "rear";
      				sensor0_isp_used = <0>;
      				sensor0_fmt = <0>;
      				sensor0_stby_mode = <0>;
      				sensor0_vflip = <0>;
      				sensor0_hflip = <0>;
      				sensor0_iovdd-supply = <&reg_dldo2>;
      				sensor0_iovdd_vol = <3300000>;
      				sensor0_avdd-supply = <&reg_dldo3>;
      				sensor0_avdd_vol = <2500000>;
      				sensor0_dvdd-supply = <&reg_dldo4>;
      				sensor0_dvdd_vol = <1100000>;
      				sensor0_power_en = <>;
      				sensor0_reset = <&pio PE 4 1 0 1 0>;
      				sensor0_pwdn = <>;
      				flash_handle = <>;
      				act_handle = <>;
      				status	= "okay";
      			};
      			sensor1:sensor@1 {
      				device_type = "sensor1";
      				sensor1_mname = "gc5035_mipi";
      				sensor1_twi_cci_id = <2>;
      				sensor1_twi_addr = <0x7e>;
      				sensor1_mclk_id = <0>;
      				sensor1_pos = "front";
      				sensor1_isp_used = <1>;
      				sensor1_fmt = <1>;
      				sensor1_stby_mode = <0>;
      				sensor1_vflip = <0>;
      				sensor1_hflip = <0>;
      				sensor1_iovdd-supply = <&reg_dldo2>;
      				sensor1_iovdd_vol = <1800000>;
      				sensor1_avdd-supply = <&reg_dldo3>;
      				sensor1_avdd_vol = <2800000>;
      				sensor1_dvdd-supply = <&reg_eldo2>;
      				sensor1_dvdd_vol = <1200000>;
      				sensor1_power_en = <>;
      				sensor1_reset = <&pio PE 7 1 0 1 0>;
      				sensor1_pwdn = <&pio PE 6 1 0 1 0>;
      				status	= "disabled";
      			};
      			vinc0:vinc@0 {
      				vinc0_csi_sel = <0>;
      				vinc0_mipi_sel = <0>;
      				vinc0_isp_sel = <0>;
      				vinc0_isp_tx_ch = <0>;
      				vinc0_tdm_rx_sel = <0>;
      				vinc0_rear_sensor_sel = <0>;
      				vinc0_front_sensor_sel = <0>;
      				vinc0_sensor_list = <0>;
      				status = "okay";
      			};
      			vinc1:vinc@1 {
      				vinc1_csi_sel = <0>;
      				vinc1_mipi_sel = <0>;
      				vinc1_isp_sel = <0>;
      				vinc1_isp_tx_ch = <1>;
      				vinc1_tdm_rx_sel = <0>;
      				vinc1_rear_sensor_sel = <0>;
      				vinc1_front_sensor_sel = <0>;
      				vinc1_sensor_list = <0>;
      				status = "okay";
      			};
      			vinc2:vinc@2 {
      				vinc2_csi_sel = <0>;
      				vinc2_mipi_sel = <0>;
      				vinc2_isp_sel = <0>;
      				vinc2_isp_tx_ch = <2>;
      				vinc2_tdm_rx_sel = <0>;
      				vinc2_rear_sensor_sel = <0>;
      				vinc2_front_sensor_sel = <0>;
      				vinc2_sensor_list = <0>;
      				status = "okay";
      			};
      			vinc3:vinc@3 {
      				vinc3_csi_sel = <0>;
      				vinc3_mipi_sel = <0>;
      				vinc3_isp_sel = <0>;
      				vinc3_isp_tx_ch = <3>;
      				vinc3_tdm_rx_sel = <0>;
      				vinc3_rear_sensor_sel = <0>;
      				vinc3_front_sensor_sel = <0>;
      				vinc3_sensor_list = <0>;
      				status = "okay";
      			};
      		};
      

      这是V4L2调用代码

      void MainWindow::showEvent(QShowEvent *event)
      {
          struct v4l2_capability cap;
          struct v4l2_input inp;           /* select the current video input */
          struct v4l2_streamparm parms;    /* set streaming parameters */
          struct v4l2_format fmt;          /* try a format */
          struct v4l2_requestbuffers req;
          struct v4l2_buffer buf;
          enum v4l2_buf_type type;
          
      int i;
      
          fd = open("/dev/video0", O_RDWR, 0);
          if(fd < 0)
          {
              qDebug()<<"/dev/video0 open fail...";
              return;
          }
      
          memset(&cap, 0, sizeof(cap));
          if(ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0)
          {
              qDebug()<<"Query device capabilities fail!!!";
              ::close(fd);
              return;
          }
          else
          {
              qDebug()<<"Querey device capabilities succeed";
              qDebug()<<"cap.driver ="<<(char*)cap.driver;
              qDebug()<<"cap.card ="<<(char*)cap.card;
              qDebug()<<"cap.bus_info ="<<(char*)cap.bus_info;
              qDebug()<<"cap.version ="<<QString().sprintf("0x%08x",cap.version);
              qDebug()<<"cap.capabilities ="<<QString().sprintf("0x%08x", cap.capabilities);
          }
      
          if(!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE_MPLANE))
          {
              qDebug()<<"The device is not supports the Video Capture interface!!!";
              ::close(fd);
              return;
          }
      
      
          memset(&inp, 0, sizeof(inp));
          inp.index = 0;
          inp.type = V4L2_INPUT_TYPE_CAMERA;
          if (ioctl(fd, VIDIOC_S_INPUT, &inp) < 0) {
              qDebug()<<"VIDIOC_S_INPUT failed! s_input:"<<inp.index;
              ::close(fd);
              return;
          }
      
          memset(&parms, 0, sizeof(parms));
          parms.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
          parms.parm.capture.timeperframe.numerator = 1;
          parms.parm.capture.timeperframe.denominator = 25;
          if (ioctl(fd, VIDIOC_S_PARM, &parms) < 0) {
              qDebug()<<"Setting streaming parameters failed 1/25";
              ::close(fd);
              return;
          }
      
          memset(&fmt, 0, sizeof(fmt));
          fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
          fmt.fmt.pix_mp.width = 1920;
          fmt.fmt.pix_mp.height = 1080;
          fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_UYVY;
          fmt.fmt.pix_mp.field = V4L2_FIELD_NONE;
          if (ioctl(fd, VIDIOC_S_FMT, &fmt) < 0) {
              qDebug()<<"setting the data format failed!";
              ::close(fd);
              return;
          }
      
          if (ioctl(fd, VIDIOC_G_FMT, &fmt) < 0) {
              qDebug()<<"get the data format failed!";
          }
      
      
          memset(&req, 0, sizeof(req));
          req.count = 3;
          req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
          req.memory = V4L2_MEMORY_MMAP;
          if (ioctl(fd, VIDIOC_REQBUFS, &req) < 0) {
              qDebug()<<"VIDIOC_REQBUFS failed";
              ::close(fd);
              return;
          }
      
      
          memset(&buf, 0, sizeof( buf));
          for (i = 0; i < 3; i++) {
              buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
              buf.memory = V4L2_MEMORY_MMAP;
              buf.index = i;
              buf.length = 1;
              buf.m.planes = (struct v4l2_plane *)calloc(buf.length, sizeof(struct v4l2_plane));
              if(ioctl(fd, VIDIOC_QUERYBUF, &buf) < 0)
              {
                  qDebug()<<"VIDIOC_QUERYBUF failed";
                  free(buf.m.planes);
                  ::close(fd);
                  return;
              }
      
              mptr[i] = (unsigned char *)mmap(NULL, buf.m.planes[0].length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.planes[0].m.mem_offset);
              size[i] = buf.length;
      
              //使用完毕
              if(ioctl(fd, VIDIOC_QBUF, &buf) < 0)
              {
                  qDebug()<<"VIDIOC_QBUF failed";
                  free(buf.m.planes);
                  ::close(fd);
                  return;
              }
          }
      
          type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
          if (ioctl(fd, VIDIOC_STREAMON, &type) == -1) {
              qDebug()<<"VIDIOC_STREAMON error!";
              free(buf.m.planes);
              ::close(fd);
          }
      
          //timer = new QTimer(this);
          //connect(timer,&QTimer::timeout, this, &MainWindow::ReadCarmeraFrame);
          //timer->start(25);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::ReadCarmeraFrame()
      {
          struct v4l2_buffer readbuffer;
          readbuffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
          readbuffer.memory = V4L2_MEMORY_MMAP;
          readbuffer.length = 1;
          readbuffer.m.planes = (struct v4l2_plane *)calloc(readbuffer.length, sizeof(struct v4l2_plane));
          if(ioctl(fd, VIDIOC_DQBUF, &readbuffer) < 0)
          {
              qDebug()<<"VIDIOC_DQBUF failed";
              ::close(fd);
              timer->stop();
              return;
          }
      
      
          qDebug()<<"index:"<<readbuffer.index;
          qDebug()<<"ptr:"<<mptr[readbuffer.index];
      
          /*yuyv_to_rgb(mptr[readbuffer.index], rgbdata, 1920, 1080);
          QImage image = QImage((const uchar*)rgbdata, 1920, 1080, QImage::Format_RGB888);
          ui->label->setPixmap(QPixmap::fromImage(image));*/
      
          //通知内核已经使用完毕
          if(ioctl(fd, VIDIOC_QBUF, &readbuffer) < 0)
          {
              qDebug()<<"VIDIOC_QBUF failed";
              ::close(fd);
              timer->stop();
              return;
          }
          free(readbuffer.m.planes);
      }
      
      W 1 Reply Last reply Reply Quote Share 0
      • W
        wupaul2001 LV 4 @wupaul2001 last edited by

        问题已找到,是因为当AHD输入为UYVY时, CSIC的DMA输出不支持UYVY格式

        Z 1 Reply Last reply Reply Quote Share 0
        • Z
          zxyUser LV 4 last edited by

          你好,请问你调通了吗,我也是用这个芯片,想请教下,能成功使用这个芯片支持4luAHD摄像头吗

          1 Reply Last reply Reply Quote Share 0
          • Z
            zxyUser LV 4 @wupaul2001 last edited by

            @wupaul2001 怎么修改的呢,能看看补丁吗

            W 1 Reply Last reply Reply Quote Share 0
            • W
              wupaul2001 LV 4 @zxyUser last edited by

              @zxyuser 你在Q群里吧,我就是那个搞好XS9922B的群友

              1 Reply Last reply Reply Quote Share 0
              • 1 / 1
              • First post
                Last post

              Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

              行为准则 | 用户协议 | 隐私权政策