Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 515 → Rev 516

/shark/trunk/drivers/bttv/bttv-driver.c
58,9 → 58,9
static unsigned int gbuffers = 8;
static unsigned int gbufsize = 0x208000;
 
static int video_nr = -1;
static int radio_nr = -1;
static int vbi_nr = -1;
//static int video_nr = -1;
//static int radio_nr = -1;
//static int vbi_nr = -1;
 
static unsigned int fdsr = 0;
 
130,7 → 130,7
 
/* ----------------------------------------------------------------------- */
/* sysfs */
 
/*
static ssize_t show_card(struct class_device *cd, char *buf)
{
struct video_device *vfd = to_video_device(cd);
137,7 → 137,8
struct bttv *btv = dev_get_drvdata(vfd->dev);
return sprintf26(buf, "%d\n", btv ? btv->type : UNSET);
}
static CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
*/
//static CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
 
/* ----------------------------------------------------------------------- */
/* static data */
1393,6 → 1394,7
.buf_release = buffer_release,
};
 
/*
static const char *v4l1_ioctls[] = {
"?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER", "GPICT", "SPICT",
"CCAPTURE", "GWIN", "SWIN", "GFBUF", "SFBUF", "KEY", "GFREQ",
1399,6 → 1401,7
"SFREQ", "GAUDIO", "SAUDIO", "SYNC", "MCAPTURE", "GMBUF", "GUNIT",
"GCAPTURE", "SCAPTURE", "SPLAYMODE", "SWRITEMODE", "GPLAYINFO",
"SMICROCODE", "GVBIFMT", "SVBIFMT" };
*/
#define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls)
 
int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1553,8 → 1556,8
if (index >= BTTV_TVNORMS)
return -EINVAL;
v4l2_video_std_construct(e, bttv_tvnorms[e->index].v4l2_id,
bttv_tvnorms[e->index].name);
//v4l2_video_std_construct(e, bttv_tvnorms[e->index].v4l2_id,
// bttv_tvnorms[e->index].name);
e->index = index;
return 0;
}
1927,7 → 1930,7
f->fmt.win.field = fh->ov.field;
return 0;
case V4L2_BUF_TYPE_VBI_CAPTURE:
bttv_vbi_get_fmt(fh,f);
//bttv_vbi_get_fmt(fh,f);
return 0;
default:
return -EINVAL;
1995,7 → 1998,7
return verify_window(&bttv_tvnorms[btv->tvnorm],
&f->fmt.win, 1);
case V4L2_BUF_TYPE_VBI_CAPTURE:
bttv_vbi_try_fmt(fh,f);
//bttv_vbi_try_fmt(fh,f);
return 0;
default:
return -EINVAL;
2042,9 → 2045,9
return retval;
if (locked_btres(fh->btv, RESOURCE_VBI))
return -EBUSY;
bttv_vbi_try_fmt(fh,f);
bttv_vbi_setlines(fh,btv,f->fmt.vbi.count[0]);
bttv_vbi_get_fmt(fh,f);
//bttv_vbi_try_fmt(fh,f);
//bttv_vbi_setlines(fh,btv,f->fmt.vbi.count[0]);
//bttv_vbi_get_fmt(fh,f);
return 0;
default:
return -EINVAL;
2051,7 → 2054,7
}
}
 
static int bttv_do_ioctl(struct inode *inode, struct file *file,
int bttv_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{
struct bttv_fh *fh = file->private_data;
2062,13 → 2065,13
if (bttv_debug > 1) {
switch (_IOC_TYPE(cmd)) {
case 'v':
printk("bttv%d: ioctl 0x%x (v4l1, VIDIOC%s)\n",
btv->nr, cmd, (_IOC_NR(cmd) < V4L1_IOCTLS) ?
v4l1_ioctls[_IOC_NR(cmd)] : "???");
//printk("bttv%d: ioctl 0x%x (v4l1, VIDIOC%s)\n",
// btv->nr, cmd, (_IOC_NR(cmd) < V4L1_IOCTLS) ?
// v4l1_ioctls[_IOC_NR(cmd)] : "???");
break;
case 'V':
printk("bttv%d: ioctl 0x%x (v4l2, %s)\n",
btv->nr, cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
//printk("bttv%d: ioctl 0x%x (v4l2, %s)\n",
// btv->nr, cmd, v4l2_ioctl_names[_IOC_NR(cmd)]);
break;
default:
printk("bttv%d: ioctl 0x%x ()\n",
2385,7 → 2388,7
retval = -EIO;
/* fall through */
case STATE_DONE:
videobuf_dma_pci_sync(btv->dev,&buf->vb.dma);
//videobuf_dma_pci_sync(btv->dev,&buf->vb.dma);
bttv_dma_free(btv,buf);
break;
default:
2406,7 → 2409,7
if (0 != retval)
return retval;
}
bttv_vbi_get_fmt(fh, &fmt2);
//bttv_vbi_get_fmt(fh, &fmt2);
 
memset(fmt,0,sizeof(*fmt));
fmt->sampling_rate = fmt2.fmt.vbi.sampling_rate;
2430,7 → 2433,7
retval = bttv_switch_type(fh,V4L2_BUF_TYPE_VBI_CAPTURE);
if (0 != retval)
return retval;
bttv_vbi_get_fmt(fh, &fmt2);
//bttv_vbi_get_fmt(fh, &fmt2);
 
if (fmt->sampling_rate != fmt2.fmt.vbi.sampling_rate ||
fmt->samples_per_line != fmt2.fmt.vbi.samples_per_line ||
2442,7 → 2445,7
fmt->count[0] > 32 /* VBI_MAXLINES */)
return -EINVAL;
 
bttv_vbi_setlines(fh,btv,fmt->count[0]);
//bttv_vbi_setlines(fh,btv,fmt->count[0]);
return 0;
}
 
2465,7 → 2468,7
if (0 == v4l2)
return -EINVAL;
strcpy(cap->driver,"bttv");
strlcpy(cap->card,btv->video_dev->name,sizeof(cap->card));
strncpy(cap->card,btv->video_dev->name,sizeof(cap->card));
sprintf26(cap->bus_info,"PCI:%s",pci_name(btv->dev));
cap->version = BTTV_VERSION_CODE;
cap->capabilities =
2524,7 → 2527,7
f->index = index;
f->type = type;
f->pixelformat = bttv_formats[i].fourcc;
strlcpy(f->description,bttv_formats[i].name,sizeof(f->description));
strncpy(f->description,bttv_formats[i].name,sizeof(f->description));
return 0;
}
 
2702,8 → 2705,8
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
memset(parm,0,sizeof(*parm));
v4l2_video_std_construct(&s, bttv_tvnorms[btv->tvnorm].v4l2_id,
bttv_tvnorms[btv->tvnorm].name);
//v4l2_video_std_construct(&s, bttv_tvnorms[btv->tvnorm].v4l2_id,
// bttv_tvnorms[btv->tvnorm].name);
parm->parm.capture.timeperframe = s.frameperiod;
return 0;
}
2747,7 → 2750,7
return retval;
}
 
static int bttv_ioctl(struct inode *inode, struct file *file,
int bttv_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct bttv_fh *fh = file->private_data;
2757,11 → 2760,11
bttv_switch_type(fh,V4L2_BUF_TYPE_VBI_CAPTURE);
return fh->lines * 2 * 2048;
default:
return video_usercopy(inode, file, cmd, arg, bttv_do_ioctl);
return 0;//video_usercopy(inode, file, cmd, arg, bttv_do_ioctl);
}
}
 
static ssize_t bttv_read(struct file *file, char *data,
ssize_t bttv_read(struct file *file, char *data,
size_t count, loff_t *ppos)
{
struct bttv_fh *fh = file->private_data;
2769,8 → 2772,8
 
if (fh->btv->errors)
bttv_reinit_bt848(fh->btv);
dprintk("bttv%d: read count=%d type=%s\n",
fh->btv->nr,(int)count,v4l2_type_names[fh->type]);
//dprintk("bttv%d: read count=%d type=%s\n",
// fh->btv->nr,(int)count,v4l2_type_names[fh->type]);
 
switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2839,7 → 2842,7
}
*/
 
static int bttv_open(struct inode *inode, struct file *file)
int bttv_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct bttv *btv = NULL;
2864,8 → 2867,8
if (NULL == btv)
return -ENODEV;
 
dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
btv->nr,v4l2_type_names[type]);
//dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
// btv->nr,v4l2_type_names[type]);
 
/* allocate per filehandle data */
fh = kmalloc(sizeof(*fh),GFP_KERNEL);
2878,27 → 2881,29
#ifdef VIDIOC_G_PRIORITY
v4l2_prio_open(&btv->prio,&fh->prio);
#endif
 
videobuf_queue_init(&fh->cap, &bttv_video_qops,
btv->dev, &btv->s_lock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct bttv_buffer));
/*
videobuf_queue_init(&fh->vbi, &bttv_vbi_qops,
btv->dev, &btv->s_lock,
V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB,
sizeof(struct bttv_buffer));
*/
i2c_vidiocschan(btv);
 
btv->users++;
if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)
bttv_vbi_setlines(fh,btv,16);
//if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)
//bttv_vbi_setlines(fh,btv,16);
bttv_field_count(btv);
return 0;
}
 
static int bttv_release(struct inode *inode, struct file *file)
int bttv_release(struct inode *inode, struct file *file)
{
struct bttv_fh *fh = file->private_data;
struct bttv *btv = fh->btv;
2937,17 → 2942,17
return 0;
}
 
static int
int
bttv_mmap(struct file *file, struct vm_area_struct *vma)
{
struct bttv_fh *fh = file->private_data;
 
dprintk("bttv%d: mmap type=%s 0x%lx+%ld\n",
fh->btv->nr, v4l2_type_names[fh->type],
vma->vm_start, vma->vm_end - vma->vm_start);
//dprintk("bttv%d: mmap type=%s 0x%lx+%ld\n",
// fh->btv->nr, v4l2_type_names[fh->type],
// vma->vm_start, vma->vm_end - vma->vm_start);
return videobuf_mmap_mapper(vma,bttv_queue(fh));
}
 
/*
static struct file_operations bttv_fops =
{
.owner = THIS_MODULE,
2958,7 → 2963,8
.read = bttv_read,
.mmap = bttv_mmap,
};
 
*/
/*
static struct video_device bttv_video_template =
{
.name = "UNSET",
2977,11 → 2983,11
.fops = &bttv_fops,
.minor = -1,
};
 
*/
/* ----------------------------------------------------------------------- */
/* radio interface */
 
static int radio_open(struct inode *inode, struct file *file)
int radio_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
struct bttv *btv = NULL;
3015,7 → 3021,7
return 0;
}
 
static int radio_release(struct inode *inode, struct file *file)
int radio_release(struct inode *inode, struct file *file)
{
struct bttv *btv = file->private_data;
 
3023,7 → 3029,7
return 0;
}
 
static int radio_do_ioctl(struct inode *inode, struct file *file,
int radio_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{
struct bttv *btv = file->private_data;
3074,12 → 3080,12
return 0;
}
 
static int radio_ioctl(struct inode *inode, struct file *file,
int radio_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
return video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
return 0;//video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
}
 
/*
static struct file_operations radio_fops =
{
.owner = THIS_MODULE,
3088,7 → 3094,8
.ioctl = radio_ioctl,
.llseek = no_llseek,
};
 
*/
/*
static struct video_device radio_template =
{
.name = "bt848/878 radio",
3097,7 → 3104,7
.fops = &radio_fops,
.minor = -1,
};
 
*/
/* ----------------------------------------------------------------------- */
/* irq handler */
 
3207,7 → 3214,7
{
struct timeval ts;
 
do_gettimeofday(&ts);
//do_gettimeofday(&ts);
 
if (NULL != wakeup->vbi) {
wakeup->vbi->vb.ts = ts;
3300,7 → 3307,7
btv->curr.top = NULL;
bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0);
 
do_gettimeofday(&wakeup->vb.ts);
//do_gettimeofday(&wakeup->vb.ts);
wakeup->vb.field_count = btv->field_count;
wakeup->vb.state = STATE_DONE;
//wake_up(&wakeup->vb.done);
3335,7 → 3342,7
 
/* switch input */
if (UNSET != btv->new_input) {
video_mux(btv,btv->new_input);
//video_mux(btv,btv->new_input);
btv->new_input = UNSET;
}
 
3436,7 → 3443,7
 
/* ----------------------------------------------------------------------- */
/* initialitation */
 
/*
static struct video_device *vdev_init(struct bttv *btv,
struct video_device *template,
char *type)
3480,11 → 3487,11
btv->radio_dev = NULL;
}
}
 
*/
/* register video4linux devices */
/*
static int __devinit bttv_register_video(struct bttv *btv)
{
/* video */
btv->video_dev = vdev_init(btv, &bttv_video_template, "video");
if (NULL == btv->video_dev)
goto err;
3494,7 → 3501,6
btv->nr,btv->video_dev->minor & 0x1f);
video_device_create_file(btv->video_dev, &class_device_attr_card);
 
/* vbi */
btv->vbi_dev = vdev_init(btv, &bttv_vbi_template, "vbi");
if (NULL == btv->vbi_dev)
goto err;
3505,7 → 3511,6
 
if (!btv->has_radio)
return 0;
/* radio */
btv->radio_dev = vdev_init(btv, &radio_template, "radio");
if (NULL == btv->radio_dev)
goto err;
3514,7 → 3519,6
printk(KERN_INFO "bttv%d: registered device radio%d\n",
btv->nr,btv->radio_dev->minor & 0x1f);
 
/* all done */
return 0;
 
err:
3521,8 → 3525,8
bttv_unregister_video(btv);
return -1;
}
*/
 
 
/* on OpenFirmware machines (PowerMac at least), PCI memory cycle */
/* response on cards with no firmware is not enabled by OF */
static void pci_set_command(struct pci_dev *dev)
3552,8 → 3556,8
sprintf26(btv->name,"bttv%d",btv->nr);
 
/* initialize structs / fill in defaults */
init_MUTEX(&btv->lock);
init_MUTEX(&btv->reslock);
//init_MUTEX(&btv->lock);
//init_MUTEX(&btv->reslock);
btv->s_lock = SPIN_LOCK_UNLOCKED;
//init_waitqueue_head(&btv->gpioq);
INIT_LIST_HEAD(&btv->capture);
3677,7 → 3681,7
 
/* register video4linux + input */
if (!bttv_tvcards[btv->type].no_video) {
bttv_register_video(btv);
//bttv_register_video(btv);
#ifdef CONFIG_VIDEO_IR
bttv_input_init(btv);
#endif
3732,7 → 3736,7
#endif
 
/* unregister video4linux */
bttv_unregister_video(btv);
//bttv_unregister_video(btv);
 
/* free allocated memory */
btcx_riscmem_free(btv->dev,&btv->main);