HELP NEEDED To use 2 PV148 Cards (PV148-HA and PV148-HB)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Title: HELP NEEDED To use 2 PV148 Cards (PV148-HA and PV148-HB)

Hi there,

I have two cards PV148H, one PV148HA and another PV148HB, each one has 4 bt878 chips and allows video capture at 25 fps on each video input. This allows me to have 8 video input using only 2 PCI cards. May problem is that I can capture video from the first card (the PV148HA), but form the second I get nothing. I read somewere that the first card used the video channel 0 and that the second used the video channel 1. My question is:

How can I change the video channel in the cards using the bttv2?
Currenty i use the VIDIOC_S_INPUT in order to change channel, but it apears not to be working right. Can someone take a look at my code and tell me what i'm doing wrong?

On Init the card:

        int i,id,chroma_agc_id;
        struct v4l2_control ctrl;
        struct v4l2_queryctrl qc;
        char str_std[20]="Chroma AGC";
       
        fd = open(video_device, O_RDONLY);
        if(fd<=0)  {  perror("open");  exit(-1);  }
 
          video_format = V4L2_PIX_FMT_BGR24;
       
        cfmt.fmt.pix.width = video_width;
        cfmt.fmt.pix.height = video_height;
        cfmt.fmt.pix.depth = 24; //Paulino 16;
        cfmt.fmt.pix.pixelformat = video_format;
        cfmt.fmt.pix.flags = V4L2_FMT_FLAG_INTERLACED;
        if (ioctl(fd, VIDIOC_S_FMT, &cfmt))  {  perror("s_fmt");  exit(-1);  }
        if(cfmt.fmt.pix.pixelformat != video_format)  {  fprintf(stderr, "could not get necessary pixel format.\n"); 
exit(-1);  }

           // Here I change the channel that i want.... I suppose!!!
            video_port = 0;
        if (ioctl(fd,VIDIOC_S_INPUT,&video_port)) {  perror("video_port");  exit(-1);  };

        video_width = cfmt.fmt.pix.width;
        video_height = cfmt.fmt.pix.height;
        video_frame_size = (video_width * video_height * cfmt.fmt.pix.depth)>>3;
        fprintf(stderr, "capture got %ix%i(%i)\n", video_width, video_height, cfmt.fmt.pix.depth);

        cparm.type = V4L2_BUF_TYPE_CAPTURE;
        if (ioctl(fd, VIDIOC_G_PARM, &cparm) != 0)  {  perror("G_PARM");  exit(-1);  }

        video_frame_rate = cparm.parm.capture.timeperframe;
        video_frame_rate = 10000000/video_frame_rate;
        if(half_frame) video_frame_rate/=2;
        fprintf(stderr, "Capturing at %f fps\n", video_frame_rate);
 
        if (!READ)
          {
            crbuf.type = V4L2_BUF_TYPE_CAPTURE;
            crbuf.count = BUFS;
            if (ioctl(fd, VIDIOC_REQBUFS, &crbuf) != 0)  {  perror("REQBUF");  exit(-1);  }
            bufs = crbuf.count;
            fprintf(stderr, "got %i buffers\n", bufs);
 
            for(i=0; i<bufs; i++)
              {
                cbuf.type = V4L2_BUF_TYPE_CAPTURE;
                cbuf.index = i;
                if(ioctl(fd, VIDIOC_QUERYBUF, &cbuf)!=0)  {  perror("querybuf");  exit(-1);  }
                buf[i] = mmap(NULL, cbuf.length, PROT_READ, MAP_SHARED, fd, cbuf.offset);
                if((int)(buf[i])==-1)  {  perror("mmap");  exit(-1);  }
                if(ioctl(fd, VIDIOC_QBUF, &cbuf)!=0)  {  perror("QBUF");  exit(-1);  }
              }
 
            i = V4L2_BUF_TYPE_CAPTURE;
            if(ioctl(fd, VIDIOC_STREAMON, &i)!=0)  {  perror("streamon");  exit(-1);  }
          }

        ctrl.id=V4L2_CID_AUTOGAIN;
        ctrl.value=0;
        ioctl(fd,VIDIOC_S_CTRL,&ctrl);
        ioctl(fd,VIDIOC_G_CTRL,&ctrl);

        ctrl.id=V4L2_CID_AUTO_WHITE_BALANCE;
        ctrl.value=0;
        ioctl(fd,VIDIOC_S_CTRL,&ctrl);
        ioctl(fd,VIDIOC_G_CTRL,&ctrl);

        for (id = 0; id < 100; ++id)
        {
                qc.id = V4L2_CID_PRIVATE_BASE+id;
                i = ioctl(fd, VIDIOC_QUERYCTRL, &qc);
                if (i)
                        break;
                if (strcmp(qc.name,str_std)==0) chroma_agc_id=id;
        }
       
        ctrl.id=V4L2_CID_PRIVATE_BASE+chroma_agc_id;
        ctrl.value=0;
        ioctl(fd,VIDIOC_S_CTRL,&ctrl);
        ioctl(fd,VIDIOC_G_CTRL,&ctrl);


Thanks in advance
Maciel



[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux