int width = buf->fmt->width;
int height = buf->fmt->height;
+ int bytesperline = buf->fmt->bytesperline;
enum v4l2_field field = buf->fmt->field;
int depth = sfmt->depth;
DEB_CAP(("[size=%dx%d,fields=%s]\n",
width,height,v4l2_field_names[field]));
+ if( bytesperline != 0) {
+ vdma1.pitch = bytesperline*2;
+ } else {
vdma1.pitch = (width*depth*2)/8;
+ }
vdma1.num_line_byte = ((vv->standard->v_field<<16) + vv->standard->h_pixels);
vdma1.base_page = buf->pt[0].dma | ME1;
vdma2->pitch = width;
vdma3->pitch = width;
+ /* fixme: look at bytesperline! */
+
if( 0 != vv->vflip ) {
vdma2->prot_addr = buf->pt[1].offset;
vdma2->base_even = ((vdma2->pitch/2)*height)+buf->pt[1].offset;
DEB_CAP(("[size=%dx%d,fields=%s]\n",
width,height,v4l2_field_names[field]));
+ /* fixme: look at bytesperline! */
+
/* fixme: what happens for user space buffers here?. The offsets are
most likely wrong, this version here only works for page-aligned
buffers, modifications to the pagetable-functions are necessary...*/
WRITE_RPS0(CMD_PAUSE | o_wait);
WRITE_RPS0(CMD_PAUSE | e_wait);
} else if ( vv->last_field == V4L2_FIELD_TOP ) {
+ WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
WRITE_RPS0(CMD_PAUSE | o_wait);
} else if ( vv->last_field == V4L2_FIELD_BOTTOM ) {
+ WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
WRITE_RPS0(CMD_PAUSE | e_wait);
}
DEB_CAP(("buf:%p, next:%p\n",buf,next));
-/*
- printk("vdma%d.base_even: 0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
- printk("vdma%d.base_odd: 0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
- printk("vdma%d.prot_addr: 0x%08x\n", 1,saa7146_read(dev,PROT_ADDR1));
- printk("vdma%d.base_page: 0x%08x\n", 1,saa7146_read(dev,BASE_PAGE1));
- printk("vdma%d.pitch: 0x%08x\n", 1,saa7146_read(dev,PITCH1));
- printk("vdma%d.num_line_byte: 0x%08x\n", 1,saa7146_read(dev,NUM_LINE_BYTE1));
- printk("vdma%d => vptr : 0x%08x\n", 1,saa7146_read(dev,PCI_VDP1));
-*/
-
vdma1_prot_addr = saa7146_read(dev, PROT_ADDR1);
if( 0 == vdma1_prot_addr ) {
/* clear out beginning of streaming bit (rps register 0)*/
program_capture_engine(dev,0);
}
+/*
+ printk("vdma%d.base_even: 0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
+ printk("vdma%d.base_odd: 0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
+ printk("vdma%d.prot_addr: 0x%08x\n", 1,saa7146_read(dev,PROT_ADDR1));
+ printk("vdma%d.base_page: 0x%08x\n", 1,saa7146_read(dev,BASE_PAGE1));
+ printk("vdma%d.pitch: 0x%08x\n", 1,saa7146_read(dev,PITCH1));
+ printk("vdma%d.num_line_byte: 0x%08x\n", 1,saa7146_read(dev,NUM_LINE_BYTE1));
+ printk("vdma%d => vptr : 0x%08x\n", 1,saa7146_read(dev,PCI_VDP1));
+*/
+
/* write the address of the rps-program */
saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
struct saa7146_format *fmt;
enum v4l2_field field;
int maxw, maxh;
+ int calc_bpl;
DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n",dev,fh));
f->fmt.pix.width = maxw;
if (f->fmt.pix.height > maxh)
f->fmt.pix.height = maxh;
- f->fmt.pix.sizeimage =
- (f->fmt.pix.width * f->fmt.pix.height * fmt->depth)/8;
+
+ calc_bpl = (f->fmt.pix.width * fmt->depth)/8;
+
+ if (f->fmt.pix.bytesperline < calc_bpl)
+ f->fmt.pix.bytesperline = calc_bpl;
+
+ if (f->fmt.pix.bytesperline > (2*PAGE_SIZE * fmt->depth)/8) /* arbitrary constraint */
+ f->fmt.pix.bytesperline = calc_bpl;
+
+ f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height;
+ DEB_D(("w:%d, h:%d, bytesperline:%d, sizeimage:%d\n",f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.bytesperline,f->fmt.pix.sizeimage));
+
return 0;
}
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
static struct v4l2_queryctrl controls[] = {
{
- .id = V4L2_CID_BRIGHTNESS,
- .name = "Brightness",
- .minimum = 0,
- .maximum = 255,
- .step = 1,
- .default_value = 128,
- .type = V4L2_CTRL_TYPE_INTEGER,
+ id: V4L2_CID_BRIGHTNESS,
+ name: "Brightness",
+ minimum: 0,
+ maximum: 255,
+ step: 1,
+ default_value: 128,
+ type: V4L2_CTRL_TYPE_INTEGER,
},{
- .id = V4L2_CID_CONTRAST,
- .name = "Contrast",
- .minimum = 0,
- .maximum = 127,
- .step = 1,
- .default_value = 64,
- .type = V4L2_CTRL_TYPE_INTEGER,
+ id: V4L2_CID_CONTRAST,
+ name: "Contrast",
+ minimum: 0,
+ maximum: 127,
+ step: 1,
+ default_value: 64,
+ type: V4L2_CTRL_TYPE_INTEGER,
},{
- .id = V4L2_CID_SATURATION,
- .name = "Saturation",
- .minimum = 0,
- .maximum = 127,
- .step = 1,
- .default_value = 64,
- .type = V4L2_CTRL_TYPE_INTEGER,
+ id: V4L2_CID_SATURATION,
+ name: "Saturation",
+ minimum: 0,
+ maximum: 127,
+ step: 1,
+ default_value: 64,
+ type: V4L2_CTRL_TYPE_INTEGER,
},{
- .id = V4L2_CID_VFLIP,
- .name = "Vertical flip",
- .minimum = 0,
- .maximum = 1,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
+ id: V4L2_CID_VFLIP,
+ name: "Vertical flip",
+ minimum: 0,
+ maximum: 1,
+ type: V4L2_CTRL_TYPE_BOOLEAN,
},{
- .id = V4L2_CID_HFLIP,
- .name = "Horizontal flip",
- .minimum = 0,
- .maximum = 1,
- .type = V4L2_CTRL_TYPE_BOOLEAN,
+ id: V4L2_CID_HFLIP,
+ name: "Horizontal flip",
+ minimum: 0,
+ maximum: 1,
+ type: V4L2_CTRL_TYPE_BOOLEAN,
},
};
static int NUM_CONTROLS = sizeof(controls)/sizeof(struct v4l2_queryctrl);
int length = buf->vb.dma.sglen;
struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
- DEB_EE(("dev:%p, buf:%p\n",dev,buf));
+ DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length));
if( 0 != IS_PLANAR(sfmt->trans)) {
struct saa7146_pgtable *pt1 = &buf->pt[0];
return 0;
}
+/* capturing to framebuffer */
+
+int overlay_reqbufs(struct saa7146_dev *dev, struct v4l2_requestbuffers *req)
+{
+/* struct saa7146_fh *fh = file->private_data;
+
+ if (req->count > VIDEO_MAX_FRAME)
+ req->count = VIDEO_MAX_FRAME;
+
+ *size = fh->video_fmt.sizeimage;
+
+*/
+ return 0;
+}
+int overlay_querybuf(struct saa7146_dev *dev, struct v4l2_buffer *buf)
+{
+ return 0;
+}
+int overlay_qbuf(struct saa7146_dev *dev, struct v4l2_buffer *b)
+{
+/* if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
+ DEB_D(("index %d out of bounds.\n",b->index));
+ goto -EINVAL;
+ }
+
+ buf = q->bufs[b->index];
+ if (NULL == buf) {
+ printk("videobuf_qbuf: NULL == buf\n");
+ goto done;
+ }
+ if (0 == buf->baddr) {
+ printk("videobuf_qbuf: 0 == buf->baddr\n");
+ goto done;
+ }
+ if (buf->state == STATE_QUEUED ||
+ buf->state == STATE_ACTIVE) {
+ printk("videobuf_qbuf: already queued or activated.\n");
+ goto done;
+ }
+
+ field = videobuf_next_field(q);
+ retval = q->ops->buf_prepare(file,buf,field);
+ if (0 != retval) {
+ printk("videobuf_qbuf: buf_prepare() failed.\n");
+ goto done;
+ }
+
+ list_add_tail(&buf->stream,&q->stream);
+ if (q->streaming) {
+ spin_lock_irqsave(q->irqlock,flags);
+ q->ops->buf_queue(file,buf);
+ spin_unlock_irqrestore(q->irqlock,flags);
+ }
+ retval = 0;
+
+ done:
+ up(&q->lock);
+ return retval;
+*/
+ return 0;
+}
+int overlay_dqbuf(struct saa7146_dev *dev, struct v4l2_buffer *buf)
+{
+ return 0;
+}
+int overlay_streamon(struct saa7146_dev *dev)
+{
+ return 0;
+}
+int overlay_streamoff(struct saa7146_dev *dev)
+{
+ return 0;
+}
+
+
/*
* This function is _not_ called directly, but from
* video_generic_ioctl (and maybe others). userspace
strcpy(cap->driver, "saa7146 v4l2");
strlcpy(cap->card, dev->ext->name, sizeof(cap->card));
- sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
+ sprintf(cap->bus_info,"PCI:%s",dev->pci->slot_name);
cap->version = SAA7146_VERSION_CODE;
cap->capabilities =
V4L2_CAP_VIDEO_CAPTURE |
ctrl = ctrl_by_id(c->id);
if( NULL == ctrl ) {
+ return -EINVAL;
+/*
c->flags = V4L2_CTRL_FLAG_DISABLED;
return 0;
+*/
}
DEB_EE(("VIDIOC_QUERYCTRL: id:%d\n",c->id));
return err;
}
case VIDIOC_REQBUFS: {
- DEB_D(("VIDIOC_REQBUFS \n"));
- return videobuf_reqbufs(file,q,arg);
+ struct v4l2_requestbuffers *req = arg;
+ DEB_D(("VIDIOC_REQBUFS, type:%d\n",req->type));
+/*
+ if( req->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ return overlay_reqbufs(dev,req);
+ }
+*/
+ return videobuf_reqbufs(file,q,req);
}
case VIDIOC_QUERYBUF: {
- DEB_D(("VIDIOC_QUERYBUF \n"));
- return videobuf_querybuf(q,arg);
+ struct v4l2_buffer *buf = arg;
+ DEB_D(("VIDIOC_QUERYBUF, type:%d, offset:%d\n",buf->type,buf->m.offset));
+/* if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ return overlay_querybuf(dev,buf);
+ }
+ */ return videobuf_querybuf(q,buf);
}
case VIDIOC_QBUF: {
- struct v4l2_buffer *b = arg;
+ struct v4l2_buffer *buf = arg;
int ret = 0;
- ret = videobuf_qbuf(file,q,b);
- DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,b->index));
+/* if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ return overlay_qbuf(dev,buf);
+ }
+ */ ret = videobuf_qbuf(file,q,buf);
+ DEB_D(("VIDIOC_QBUF: ret:%d, index:%d\n",ret,buf->index));
return ret;
}
case VIDIOC_DQBUF: {
- struct v4l2_buffer *b = arg;
+ struct v4l2_buffer *buf = arg;
int ret = 0;
- ret = videobuf_dqbuf(file,q,b);
- DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,b->index));
+/* if( buf->type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ return overlay_dqbuf(dev,buf);
+ }
+ */ ret = videobuf_dqbuf(file,q,buf);
+ DEB_D(("VIDIOC_DQBUF: ret:%d, index:%d\n",ret,buf->index));
return ret;
}
case VIDIOC_STREAMON: {
- DEB_D(("VIDIOC_STREAMON \n"));
+ int *type = arg;
+ DEB_D(("VIDIOC_STREAMON, type:%d\n",*type));
+
if( 0 != ops->capture_begin ) {
if( 0 != (err = ops->capture_begin(fh))) {
return err;
}
}
+/* if( *type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ err = overlay_streamon(dev);
+ } else { */
err = videobuf_streamon(file,q);
+/* } */
return err;
}
case VIDIOC_STREAMOFF: {
- DEB_D(("VIDIOC_STREAMOFF \n"));
+ int *type = arg;
+
+ DEB_D(("VIDIOC_STREAMOFF, type:%d\n",*type));
if( 0 != ops->capture_end ) {
ops->capture_end(fh);
}
- err = videobuf_streamoff(file,q);
- return 0;
+/* if( *type == V4L2_BUF_TYPE_VIDEO_OVERLAY ) {
+ return overlay_streamoff(dev);
+ }
+ */ err = videobuf_streamoff(file,q);
+ return err;
}
case VIDIOCGMBUF:
{
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
int size,err = 0;
+ DEB_CAP(("vbuf:%p\n",vb));
+
/* sanity checks */
if (fh->video_fmt.width < 64 ||
fh->video_fmt.height < 64 ||
DEB_CAP(("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n",
fh->video_fmt.width,fh->video_fmt.height,size,v4l2_field_names[fh->video_fmt.field]));
if (buf->vb.width != fh->video_fmt.width ||
+ buf->vb.bytesperline != fh->video_fmt.bytesperline ||
buf->vb.height != fh->video_fmt.height ||
buf->vb.size != size ||
buf->vb.field != field ||
if (STATE_NEEDS_INIT == buf->vb.state) {
struct saa7146_format *sfmt;
+ buf->vb.bytesperline = fh->video_fmt.bytesperline;
buf->vb.width = fh->video_fmt.width;
buf->vb.height = fh->video_fmt.height;
buf->vb.size = size;
fh->video_fmt.width = 384;
fh->video_fmt.height = 288;
fh->video_fmt.pixelformat = V4L2_PIX_FMT_BGR24;
+ fh->video_fmt.bytesperline = 0;
fh->video_fmt.field = V4L2_FIELD_ANY;
sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat);
fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8;