[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-video
Subject: HELP NEEDED To use 2 PV148 Cards (PV148-HA and PV148-HB)
From: "Jorge Rodrigues" <jrodrigues () isa ! pt>
Date: 2002-11-29 0:33:49
[Download RAW message or body]
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
[Attachment #3 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.4712.0">
<TITLE>HELP NEEDED To use 2 PV148 Cards (PV148-HA and PV148-HB)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hi there, </FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">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: </FONT></P>
<P><FONT SIZE=2 FACE="Arial">How can I change the video channel in the cards using \
the bttv2? </FONT>
<BR><FONT SIZE=2 FACE="Arial">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?</FONT></P>
<P><FONT SIZE=2 FACE="Arial">On Init the card:</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> int \
i,id,chroma_agc_id;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> struct \
v4l2_control ctrl;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> struct \
v4l2_queryctrl qc;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> char \
str_std[20]="Chroma AGC";</FONT>
<BR>
<BR> <FONT SIZE=2 FACE="Arial">fd = \
open(video_device, O_RDONLY);</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">if(fd<=0) { perror("open"); \
exit(-1); }</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR> <FONT SIZE=2 FACE="Arial"> \
video_format = V4L2_PIX_FMT_BGR24;</FONT>
<BR>
<BR> <FONT SIZE=2 \
FACE="Arial">cfmt.fmt.pix.width = video_width;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">cfmt.fmt.pix.height = video_height;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">cfmt.fmt.pix.depth = 24; //Paulino 16;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">cfmt.fmt.pix.pixelformat = video_format;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">cfmt.fmt.pix.flags = V4L2_FMT_FLAG_INTERLACED;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">if \
(ioctl(fd, VIDIOC_S_FMT, &cfmt)) { perror("s_fmt"); \
exit(-1); }</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">if(cfmt.fmt.pix.pixelformat != video_format) { \
fprintf(stderr, "could not get necessary pixel format.\n"); </FONT>
<BR><FONT SIZE=2 FACE="Arial">exit(-1); }</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> \
// Here I change the channel that i want.... I suppose!!!</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
video_port = 0;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">if \
(ioctl(fd,VIDIOC_S_INPUT,&video_port)) { \
perror("video_port"); exit(-1); };</FONT> </P>
<P> <FONT SIZE=2 FACE="Arial">video_width = \
cfmt.fmt.pix.width;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">video_height \
= cfmt.fmt.pix.height;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">video_frame_size = (video_width * video_height * \
cfmt.fmt.pix.depth)>>3;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">fprintf(stderr, "capture got %ix%i(%i)\n", video_width, \
video_height, cfmt.fmt.pix.depth);</FONT> </P>
<P> <FONT SIZE=2 FACE="Arial">cparm.type = \
V4L2_BUF_TYPE_CAPTURE;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">if \
(ioctl(fd, VIDIOC_G_PARM, &cparm) != 0) { \
perror("G_PARM"); exit(-1); }</FONT> </P>
<P> <FONT SIZE=2 \
FACE="Arial">video_frame_rate = cparm.parm.capture.timeperframe;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">video_frame_rate = 10000000/video_frame_rate;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">if(half_frame) video_frame_rate/=2;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">fprintf(stderr, "Capturing at %f fps\n", \
video_frame_rate);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> if \
(!READ)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
{</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> crbuf.type = V4L2_BUF_TYPE_CAPTURE;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> crbuf.count = BUFS;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
if (ioctl(fd, VIDIOC_REQBUFS, &crbuf) != 0) { \
perror("REQBUF"); exit(-1); }</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> bufs = crbuf.count;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> fprintf(stderr, "got %i buffers\n", \
bufs);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> for(i=0; i<bufs; i++)</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> {</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">cbuf.type = \
V4L2_BUF_TYPE_CAPTURE;</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">cbuf.index = \
i;</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">if(ioctl(fd, \
VIDIOC_QUERYBUF, &cbuf)!=0) { perror("querybuf"); \
exit(-1); }</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">buf[i] = \
mmap(NULL, cbuf.length, PROT_READ, MAP_SHARED, fd, cbuf.offset);</FONT>
<BR> \
<FONT SIZE=2 \
FACE="Arial">if((int)(buf[i])==-1) { perror("mmap"); \
exit(-1); }</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">if(ioctl(fd, \
VIDIOC_QBUF, &cbuf)!=0) { perror("QBUF"); \
exit(-1); }</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> }</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> i = V4L2_BUF_TYPE_CAPTURE;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial"> if(ioctl(fd, VIDIOC_STREAMON, &i)!=0) \
{ perror("streamon"); exit(-1); }</FONT>
<BR> <FONT SIZE=2 FACE="Arial"> \
}</FONT> </P>
<P><FONT SIZE=2 FACE="Arial"> \
ctrl.id=V4L2_CID_AUTOGAIN;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">ctrl.value=0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_S_CTRL,&ctrl);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_G_CTRL,&ctrl);</FONT> </P>
<P><FONT SIZE=2 FACE="Arial"> \
ctrl.id=V4L2_CID_AUTO_WHITE_BALANCE;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">ctrl.value=0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_S_CTRL,&ctrl);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_G_CTRL,&ctrl);</FONT> </P>
<P> <FONT SIZE=2 FACE="Arial">for (id = 0; \
id < 100; ++id)</FONT>
<BR> <FONT SIZE=2 FACE="Arial">{</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">qc.id = \
V4L2_CID_PRIVATE_BASE+id;</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">i = ioctl(fd, \
VIDIOC_QUERYCTRL, &qc);</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">if (i)</FONT>
<BR> \
\
<FONT SIZE=2 FACE="Arial">break;</FONT>
<BR> \
<FONT SIZE=2 FACE="Arial">if \
(strcmp(qc.name,str_std)==0) chroma_agc_id=id;</FONT>
<BR> <FONT SIZE=2 FACE="Arial">}</FONT>
<BR>
<BR><FONT SIZE=2 FACE="Arial"> \
ctrl.id=V4L2_CID_PRIVATE_BASE+chroma_agc_id;</FONT>
<BR> <FONT SIZE=2 \
FACE="Arial">ctrl.value=0;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_S_CTRL,&ctrl);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> \
ioctl(fd,VIDIOC_G_CTRL,&ctrl);</FONT> </P>
<BR>
<P><FONT SIZE=2 FACE="Arial">Thanks in advance</FONT>
<BR><FONT SIZE=2 FACE="Arial">Maciel</FONT>
</P>
<BR>
</BODY>
</HTML>
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/video4linux-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic