Commit 44d0b80e authored by Joe Perches's avatar Joe Perches Committed by Mauro Carvalho Chehab

[media] saa7146: Use current logging styles

Standardize the mechanisms to emit logging messages.

A few other modules used an #include from saa7146,
convert those at the same time.

Add pr_fmt.
Convert printks to pr_<level>
Convert printks without KERN_<level> to appropriate pr_<level>.
Convert logging macros requiring multiple parentheses to normal style.
Removed embedded prefixes when pr_fmt was added.
Whitespace cleanups when around other conversions.
Use printf extension %pM to print mac address.
Coalesce format strings.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Acked-by: default avatarMichael Hunold <michael@mihu.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 0b8bd83c
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <media/saa7146.h> #include <media/saa7146.h>
LIST_HEAD(saa7146_devices); LIST_HEAD(saa7146_devices);
...@@ -35,10 +37,9 @@ static void dump_registers(struct saa7146_dev* dev) ...@@ -35,10 +37,9 @@ static void dump_registers(struct saa7146_dev* dev)
{ {
int i = 0; int i = 0;
INFO((" @ %li jiffies:\n",jiffies)); pr_info(" @ %li jiffies:\n", jiffies);
for(i = 0; i <= 0x148; i+=4) { for (i = 0; i <= 0x148; i += 4)
printk("0x%03x: 0x%08x\n",i,saa7146_read(dev,i)); pr_info("0x%03x: 0x%08x\n", i, saa7146_read(dev, i));
}
} }
#endif #endif
...@@ -72,9 +73,8 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev, ...@@ -72,9 +73,8 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev,
if (saa7146_read(dev, MC2) & 2) if (saa7146_read(dev, MC2) & 2)
break; break;
if (err) { if (err) {
printk(KERN_ERR "%s: %s timed out while waiting for " pr_err("%s: %s timed out while waiting for registers getting programmed\n",
"registers getting programmed\n", dev->name, __func__);
dev->name, __func__);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
msleep(1); msleep(1);
...@@ -88,8 +88,8 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev, ...@@ -88,8 +88,8 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev,
break; break;
saa7146_read(dev, MC2); saa7146_read(dev, MC2);
if (err) { if (err) {
DEB_S(("%s: %s timed out while waiting for transfer " DEB_S("%s: %s timed out while waiting for transfer completion\n",
"completion\n", dev->name, __func__)); dev->name, __func__);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
msleep(1); msleep(1);
...@@ -109,9 +109,8 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev, ...@@ -109,9 +109,8 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev,
if (saa7146_read(dev, MC2) & 2) if (saa7146_read(dev, MC2) & 2)
break; break;
if (!loops--) { if (!loops--) {
printk(KERN_ERR "%s: %s timed out while waiting for " pr_err("%s: %s timed out while waiting for registers getting programmed\n",
"registers getting programmed\n", dev->name, __func__);
dev->name, __func__);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
udelay(1); udelay(1);
...@@ -124,8 +123,8 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev, ...@@ -124,8 +123,8 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev,
break; break;
saa7146_read(dev, MC2); saa7146_read(dev, MC2);
if (!loops--) { if (!loops--) {
DEB_S(("%s: %s timed out while waiting for transfer " DEB_S("%s: %s timed out while waiting for transfer completion\n",
"completion\n", dev->name, __func__)); dev->name, __func__);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
udelay(5); udelay(5);
...@@ -264,7 +263,9 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt ...@@ -264,7 +263,9 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt
ptr = pt->cpu; ptr = pt->cpu;
for (i = 0; i < sglen; i++, list++) { for (i = 0; i < sglen; i++, list++) {
/* /*
printk("i:%d, adr:0x%08x, len:%d, offset:%d\n", i,sg_dma_address(list), sg_dma_len(list), list->offset); pr_debug("i:%d, adr:0x%08x, len:%d, offset:%d\n",
i, sg_dma_address(list), sg_dma_len(list),
list->offset);
*/ */
for (p = 0; p * 4096 < list->length; p++, ptr++) { for (p = 0; p * 4096 < list->length; p++, ptr++) {
*ptr = cpu_to_le32(sg_dma_address(list) + p * 4096); *ptr = cpu_to_le32(sg_dma_address(list) + p * 4096);
...@@ -281,9 +282,9 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt ...@@ -281,9 +282,9 @@ int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt
/* /*
ptr = pt->cpu; ptr = pt->cpu;
printk("offset: %d\n",pt->offset); pr_debug("offset: %d\n", pt->offset);
for(i=0;i<5;i++) { for(i=0;i<5;i++) {
printk("ptr1 %d: 0x%08x\n",i,ptr[i]); pr_debug("ptr1 %d: 0x%08x\n", i, ptr[i]);
} }
*/ */
return 0; return 0;
...@@ -314,7 +315,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id) ...@@ -314,7 +315,7 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
} }
} }
if (0 != (isr & (MASK_27))) { if (0 != (isr & (MASK_27))) {
DEB_INT(("irq: RPS0 (0x%08x).\n",isr)); DEB_INT("irq: RPS0 (0x%08x)\n", isr);
if (dev->vv_data && dev->vv_callback) if (dev->vv_data && dev->vv_callback)
dev->vv_callback(dev,isr); dev->vv_callback(dev,isr);
isr &= ~MASK_27; isr &= ~MASK_27;
...@@ -333,14 +334,15 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id) ...@@ -333,14 +334,15 @@ static irqreturn_t interrupt_hw(int irq, void *dev_id)
} else { } else {
u32 psr = saa7146_read(dev, PSR); u32 psr = saa7146_read(dev, PSR);
u32 ssr = saa7146_read(dev, SSR); u32 ssr = saa7146_read(dev, SSR);
printk(KERN_WARNING "%s: unexpected i2c irq: isr %08x psr %08x ssr %08x\n", pr_warn("%s: unexpected i2c irq: isr %08x psr %08x ssr %08x\n",
dev->name, isr, psr, ssr); dev->name, isr, psr, ssr);
} }
isr &= ~(MASK_16|MASK_17); isr &= ~(MASK_16|MASK_17);
} }
if( 0 != isr ) { if( 0 != isr ) {
ERR(("warning: interrupt enabled, but not handled properly.(0x%08x)\n",isr)); ERR("warning: interrupt enabled, but not handled properly.(0x%08x)\n",
ERR(("disabling interrupt source(s)!\n")); isr);
ERR("disabling interrupt source(s)!\n");
SAA7146_IER_DISABLE(dev,isr); SAA7146_IER_DISABLE(dev,isr);
} }
saa7146_write(dev, ISR, ack_isr); saa7146_write(dev, ISR, ack_isr);
...@@ -360,15 +362,15 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -360,15 +362,15 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
/* clear out mem for sure */ /* clear out mem for sure */
dev = kzalloc(sizeof(struct saa7146_dev), GFP_KERNEL); dev = kzalloc(sizeof(struct saa7146_dev), GFP_KERNEL);
if (!dev) { if (!dev) {
ERR(("out of memory.\n")); ERR("out of memory\n");
goto out; goto out;
} }
DEB_EE(("pci:%p\n",pci)); DEB_EE("pci:%p\n", pci);
err = pci_enable_device(pci); err = pci_enable_device(pci);
if (err < 0) { if (err < 0) {
ERR(("pci_enable_device() failed.\n")); ERR("pci_enable_device() failed\n");
goto err_free; goto err_free;
} }
...@@ -389,7 +391,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -389,7 +391,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
dev->mem = ioremap(pci_resource_start(pci, 0), dev->mem = ioremap(pci_resource_start(pci, 0),
pci_resource_len(pci, 0)); pci_resource_len(pci, 0));
if (!dev->mem) { if (!dev->mem) {
ERR(("ioremap() failed.\n")); ERR("ioremap() failed\n");
err = -ENODEV; err = -ENODEV;
goto err_release; goto err_release;
} }
...@@ -414,7 +416,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -414,7 +416,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
err = request_irq(pci->irq, interrupt_hw, IRQF_SHARED | IRQF_DISABLED, err = request_irq(pci->irq, interrupt_hw, IRQF_SHARED | IRQF_DISABLED,
dev->name, dev); dev->name, dev);
if (err < 0) { if (err < 0) {
ERR(("request_irq() failed.\n")); ERR("request_irq() failed\n");
goto err_unmap; goto err_unmap;
} }
...@@ -444,7 +446,9 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -444,7 +446,9 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
/* create a nice device name */ /* create a nice device name */
sprintf(dev->name, "saa7146 (%d)", saa7146_num); sprintf(dev->name, "saa7146 (%d)", saa7146_num);
INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); pr_info("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x)\n",
dev->mem, dev->revision, pci->irq,
pci->subsystem_vendor, pci->subsystem_device);
dev->ext = ext; dev->ext = ext;
mutex_init(&dev->v4l2_lock); mutex_init(&dev->v4l2_lock);
...@@ -464,12 +468,12 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent ...@@ -464,12 +468,12 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
err = -ENODEV; err = -ENODEV;
if (ext->probe && ext->probe(dev)) { if (ext->probe && ext->probe(dev)) {
DEB_D(("ext->probe() failed for %p. skipping device.\n",dev)); DEB_D("ext->probe() failed for %p. skipping device.\n", dev);
goto err_free_i2c; goto err_free_i2c;
} }
if (ext->attach(dev, pci_ext)) { if (ext->attach(dev, pci_ext)) {
DEB_D(("ext->attach() failed for %p. skipping device.\n",dev)); DEB_D("ext->attach() failed for %p. skipping device.\n", dev);
goto err_free_i2c; goto err_free_i2c;
} }
/* V4L extensions will set the pci drvdata to the v4l2_device in the /* V4L extensions will set the pci drvdata to the v4l2_device in the
...@@ -521,7 +525,7 @@ static void saa7146_remove_one(struct pci_dev *pdev) ...@@ -521,7 +525,7 @@ static void saa7146_remove_one(struct pci_dev *pdev)
{ NULL, 0 } { NULL, 0 }
}, *p; }, *p;
DEB_EE(("dev:%p\n",dev)); DEB_EE("dev:%p\n", dev);
dev->ext->detach(dev); dev->ext->detach(dev);
/* Zero the PCI drvdata after use. */ /* Zero the PCI drvdata after use. */
...@@ -552,21 +556,21 @@ static void saa7146_remove_one(struct pci_dev *pdev) ...@@ -552,21 +556,21 @@ static void saa7146_remove_one(struct pci_dev *pdev)
int saa7146_register_extension(struct saa7146_extension* ext) int saa7146_register_extension(struct saa7146_extension* ext)
{ {
DEB_EE(("ext:%p\n",ext)); DEB_EE("ext:%p\n", ext);
ext->driver.name = ext->name; ext->driver.name = ext->name;
ext->driver.id_table = ext->pci_tbl; ext->driver.id_table = ext->pci_tbl;
ext->driver.probe = saa7146_init_one; ext->driver.probe = saa7146_init_one;
ext->driver.remove = saa7146_remove_one; ext->driver.remove = saa7146_remove_one;
printk("saa7146: register extension '%s'.\n",ext->name); pr_info("register extension '%s'\n", ext->name);
return pci_register_driver(&ext->driver); return pci_register_driver(&ext->driver);
} }
int saa7146_unregister_extension(struct saa7146_extension* ext) int saa7146_unregister_extension(struct saa7146_extension* ext)
{ {
DEB_EE(("ext:%p\n",ext)); DEB_EE("ext:%p\n", ext);
printk("saa7146: unregister extension '%s'.\n",ext->name); pr_info("unregister extension '%s'\n", ext->name);
pci_unregister_driver(&ext->driver); pci_unregister_driver(&ext->driver);
return 0; return 0;
} }
......
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
/****************************************************************************/ /****************************************************************************/
...@@ -9,21 +11,23 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit) ...@@ -9,21 +11,23 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
if (fh->resources & bit) { if (fh->resources & bit) {
DEB_D(("already allocated! want: 0x%02x, cur:0x%02x\n",bit,vv->resources)); DEB_D("already allocated! want: 0x%02x, cur:0x%02x\n",
bit, vv->resources);
/* have it already allocated */ /* have it already allocated */
return 1; return 1;
} }
/* is it free? */ /* is it free? */
if (vv->resources & bit) { if (vv->resources & bit) {
DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit)); DEB_D("locked! vv->resources:0x%02x, we want:0x%02x\n",
vv->resources, bit);
/* no, someone else uses it */ /* no, someone else uses it */
return 0; return 0;
} }
/* it's free, grab it */ /* it's free, grab it */
fh->resources |= bit; fh->resources |= bit;
vv->resources |= bit; vv->resources |= bit;
DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources)); DEB_D("res: get 0x%02x, cur:0x%02x\n", bit, vv->resources);
return 1; return 1;
} }
...@@ -34,9 +38,9 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits) ...@@ -34,9 +38,9 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
BUG_ON((fh->resources & bits) != bits); BUG_ON((fh->resources & bits) != bits);
fh->resources &= ~bits; fh->resources &= ~bits;
vv->resources &= ~bits; vv->resources &= ~bits;
DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources)); DEB_D("res: put 0x%02x, cur:0x%02x\n", bits, vv->resources);
} }
...@@ -47,7 +51,7 @@ void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q, ...@@ -47,7 +51,7 @@ void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
struct saa7146_buf *buf) struct saa7146_buf *buf)
{ {
struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb);
DEB_EE(("dev:%p, buf:%p\n",dev,buf)); DEB_EE("dev:%p, buf:%p\n", dev, buf);
BUG_ON(in_interrupt()); BUG_ON(in_interrupt());
...@@ -66,18 +70,19 @@ int saa7146_buffer_queue(struct saa7146_dev *dev, ...@@ -66,18 +70,19 @@ int saa7146_buffer_queue(struct saa7146_dev *dev,
struct saa7146_buf *buf) struct saa7146_buf *buf)
{ {
assert_spin_locked(&dev->slock); assert_spin_locked(&dev->slock);
DEB_EE(("dev:%p, dmaq:%p, buf:%p\n", dev, q, buf)); DEB_EE("dev:%p, dmaq:%p, buf:%p\n", dev, q, buf);
BUG_ON(!q); BUG_ON(!q);
if (NULL == q->curr) { if (NULL == q->curr) {
q->curr = buf; q->curr = buf;
DEB_D(("immediately activating buffer %p\n", buf)); DEB_D("immediately activating buffer %p\n", buf);
buf->activate(dev,buf,NULL); buf->activate(dev,buf,NULL);
} else { } else {
list_add_tail(&buf->vb.queue,&q->queue); list_add_tail(&buf->vb.queue,&q->queue);
buf->vb.state = VIDEOBUF_QUEUED; buf->vb.state = VIDEOBUF_QUEUED;
DEB_D(("adding buffer %p to queue. (active buffer present)\n", buf)); DEB_D("adding buffer %p to queue. (active buffer present)\n",
buf);
} }
return 0; return 0;
} }
...@@ -87,14 +92,14 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, ...@@ -87,14 +92,14 @@ void saa7146_buffer_finish(struct saa7146_dev *dev,
int state) int state)
{ {
assert_spin_locked(&dev->slock); assert_spin_locked(&dev->slock);
DEB_EE(("dev:%p, dmaq:%p, state:%d\n", dev, q, state)); DEB_EE("dev:%p, dmaq:%p, state:%d\n", dev, q, state);
DEB_EE(("q->curr:%p\n",q->curr)); DEB_EE("q->curr:%p\n", q->curr);
BUG_ON(!q->curr); BUG_ON(!q->curr);
/* finish current buffer */ /* finish current buffer */
if (NULL == q->curr) { if (NULL == q->curr) {
DEB_D(("aiii. no current buffer\n")); DEB_D("aiii. no current buffer\n");
return; return;
} }
...@@ -112,7 +117,7 @@ void saa7146_buffer_next(struct saa7146_dev *dev, ...@@ -112,7 +117,7 @@ void saa7146_buffer_next(struct saa7146_dev *dev,
BUG_ON(!q); BUG_ON(!q);
DEB_INT(("dev:%p, dmaq:%p, vbi:%d\n", dev, q, vbi)); DEB_INT("dev:%p, dmaq:%p, vbi:%d\n", dev, q, vbi);
assert_spin_locked(&dev->slock); assert_spin_locked(&dev->slock);
if (!list_empty(&q->queue)) { if (!list_empty(&q->queue)) {
...@@ -122,10 +127,11 @@ void saa7146_buffer_next(struct saa7146_dev *dev, ...@@ -122,10 +127,11 @@ void saa7146_buffer_next(struct saa7146_dev *dev,
if (!list_empty(&q->queue)) if (!list_empty(&q->queue))
next = list_entry(q->queue.next,struct saa7146_buf, vb.queue); next = list_entry(q->queue.next,struct saa7146_buf, vb.queue);
q->curr = buf; q->curr = buf;
DEB_INT(("next buffer: buf:%p, prev:%p, next:%p\n", buf, q->queue.prev,q->queue.next)); DEB_INT("next buffer: buf:%p, prev:%p, next:%p\n",
buf, q->queue.prev, q->queue.next);
buf->activate(dev,buf,next); buf->activate(dev,buf,next);
} else { } else {
DEB_INT(("no next buffer. stopping.\n")); DEB_INT("no next buffer. stopping.\n");
if( 0 != vbi ) { if( 0 != vbi ) {
/* turn off video-dma3 */ /* turn off video-dma3 */
saa7146_write(dev,MC1, MASK_20); saa7146_write(dev,MC1, MASK_20);
...@@ -162,11 +168,11 @@ void saa7146_buffer_timeout(unsigned long data) ...@@ -162,11 +168,11 @@ void saa7146_buffer_timeout(unsigned long data)
struct saa7146_dev *dev = q->dev; struct saa7146_dev *dev = q->dev;
unsigned long flags; unsigned long flags;
DEB_EE(("dev:%p, dmaq:%p\n", dev, q)); DEB_EE("dev:%p, dmaq:%p\n", dev, q);
spin_lock_irqsave(&dev->slock,flags); spin_lock_irqsave(&dev->slock,flags);
if (q->curr) { if (q->curr) {
DEB_D(("timeout on %p\n", q->curr)); DEB_D("timeout on %p\n", q->curr);
saa7146_buffer_finish(dev,q,VIDEOBUF_ERROR); saa7146_buffer_finish(dev,q,VIDEOBUF_ERROR);
} }
...@@ -194,12 +200,12 @@ static int fops_open(struct file *file) ...@@ -194,12 +200,12 @@ static int fops_open(struct file *file)
enum v4l2_buf_type type; enum v4l2_buf_type type;
DEB_EE(("file:%p, dev:%s\n", file, video_device_node_name(vdev))); DEB_EE("file:%p, dev:%s\n", file, video_device_node_name(vdev));
if (mutex_lock_interruptible(&saa7146_devices_lock)) if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
DEB_D(("using: %p\n",dev)); DEB_D("using: %p\n", dev);
type = vdev->vfl_type == VFL_TYPE_GRABBER type = vdev->vfl_type == VFL_TYPE_GRABBER
? V4L2_BUF_TYPE_VIDEO_CAPTURE ? V4L2_BUF_TYPE_VIDEO_CAPTURE
...@@ -207,7 +213,7 @@ static int fops_open(struct file *file) ...@@ -207,7 +213,7 @@ static int fops_open(struct file *file)
/* check if an extension is registered */ /* check if an extension is registered */
if( NULL == dev->ext ) { if( NULL == dev->ext ) {
DEB_S(("no extension registered for this device.\n")); DEB_S("no extension registered for this device\n");
result = -ENODEV; result = -ENODEV;
goto out; goto out;
} }
...@@ -215,7 +221,7 @@ static int fops_open(struct file *file) ...@@ -215,7 +221,7 @@ static int fops_open(struct file *file)
/* allocate per open data */ /* allocate per open data */
fh = kzalloc(sizeof(*fh),GFP_KERNEL); fh = kzalloc(sizeof(*fh),GFP_KERNEL);
if (NULL == fh) { if (NULL == fh) {
DEB_S(("cannot allocate memory for per open data.\n")); DEB_S("cannot allocate memory for per open data\n");
result = -ENOMEM; result = -ENOMEM;
goto out; goto out;
} }
...@@ -225,13 +231,13 @@ static int fops_open(struct file *file) ...@@ -225,13 +231,13 @@ static int fops_open(struct file *file)
fh->type = type; fh->type = type;
if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
DEB_S(("initializing vbi...\n")); DEB_S("initializing vbi...\n");
if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) if (dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
result = saa7146_vbi_uops.open(dev,file); result = saa7146_vbi_uops.open(dev,file);
if (dev->ext_vv_data->vbi_fops.open) if (dev->ext_vv_data->vbi_fops.open)
dev->ext_vv_data->vbi_fops.open(file); dev->ext_vv_data->vbi_fops.open(file);
} else { } else {
DEB_S(("initializing video...\n")); DEB_S("initializing video...\n");
result = saa7146_video_uops.open(dev,file); result = saa7146_video_uops.open(dev,file);
} }
...@@ -259,7 +265,7 @@ static int fops_release(struct file *file) ...@@ -259,7 +265,7 @@ static int fops_release(struct file *file)
struct saa7146_fh *fh = file->private_data; struct saa7146_fh *fh = file->private_data;
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
DEB_EE(("file:%p\n", file)); DEB_EE("file:%p\n", file);
if (mutex_lock_interruptible(&saa7146_devices_lock)) if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -289,12 +295,14 @@ static int fops_mmap(struct file *file, struct vm_area_struct * vma) ...@@ -289,12 +295,14 @@ static int fops_mmap(struct file *file, struct vm_area_struct * vma)
switch (fh->type) { switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: { case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, vma:%p\n",file, vma)); DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, vma:%p\n",
file, vma);
q = &fh->video_q; q = &fh->video_q;
break; break;
} }
case V4L2_BUF_TYPE_VBI_CAPTURE: { case V4L2_BUF_TYPE_VBI_CAPTURE: {
DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, vma:%p\n",file, vma)); DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, vma:%p\n",
file, vma);
q = &fh->vbi_q; q = &fh->vbi_q;
break; break;
} }
...@@ -312,14 +320,14 @@ static unsigned int fops_poll(struct file *file, struct poll_table_struct *wait) ...@@ -312,14 +320,14 @@ static unsigned int fops_poll(struct file *file, struct poll_table_struct *wait)
struct videobuf_buffer *buf = NULL; struct videobuf_buffer *buf = NULL;
struct videobuf_queue *q; struct videobuf_queue *q;
DEB_EE(("file:%p, poll:%p\n",file, wait)); DEB_EE("file:%p, poll:%p\n", file, wait);
if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
if( 0 == fh->vbi_q.streaming ) if( 0 == fh->vbi_q.streaming )
return videobuf_poll_stream(file, &fh->vbi_q, wait); return videobuf_poll_stream(file, &fh->vbi_q, wait);
q = &fh->vbi_q; q = &fh->vbi_q;
} else { } else {
DEB_D(("using video queue.\n")); DEB_D("using video queue\n");
q = &fh->video_q; q = &fh->video_q;
} }
...@@ -327,17 +335,17 @@ static unsigned int fops_poll(struct file *file, struct poll_table_struct *wait) ...@@ -327,17 +335,17 @@ static unsigned int fops_poll(struct file *file, struct poll_table_struct *wait)
buf = list_entry(q->stream.next, struct videobuf_buffer, stream); buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
if (!buf) { if (!buf) {
DEB_D(("buf == NULL!\n")); DEB_D("buf == NULL!\n");
return POLLERR; return POLLERR;
} }
poll_wait(file, &buf->done, wait); poll_wait(file, &buf->done, wait);
if (buf->state == VIDEOBUF_DONE || buf->state == VIDEOBUF_ERROR) { if (buf->state == VIDEOBUF_DONE || buf->state == VIDEOBUF_ERROR) {
DEB_D(("poll succeeded!\n")); DEB_D("poll succeeded!\n");
return POLLIN|POLLRDNORM; return POLLIN|POLLRDNORM;
} }
DEB_D(("nothing to poll for, buf->state:%d\n",buf->state)); DEB_D("nothing to poll for, buf->state:%d\n", buf->state);
return 0; return 0;
} }
...@@ -346,18 +354,20 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof ...@@ -346,18 +354,20 @@ static ssize_t fops_read(struct file *file, char __user *data, size_t count, lof
struct saa7146_fh *fh = file->private_data; struct saa7146_fh *fh = file->private_data;
switch (fh->type) { switch (fh->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE: { case V4L2_BUF_TYPE_VIDEO_CAPTURE:
// DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun", file, data, (unsigned long)count)); /*
DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: file:%p, data:%p, count:%lun",
file, data, (unsigned long)count);
*/
return saa7146_video_uops.read(file,data,count,ppos); return saa7146_video_uops.read(file,data,count,ppos);
} case V4L2_BUF_TYPE_VBI_CAPTURE:
case V4L2_BUF_TYPE_VBI_CAPTURE: { /*
// DEB_EE(("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n", file, data, (unsigned long)count)); DEB_EE("V4L2_BUF_TYPE_VBI_CAPTURE: file:%p, data:%p, count:%lu\n",
file, data, (unsigned long)count);
*/
if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE) if (fh->dev->ext_vv_data->capabilities & V4L2_CAP_VBI_CAPTURE)
return saa7146_vbi_uops.read(file,data,count,ppos); return saa7146_vbi_uops.read(file,data,count,ppos);
else return -EINVAL;
return -EINVAL;
}
break;
default: default:
BUG(); BUG();
return 0; return 0;
...@@ -398,22 +408,22 @@ static void vv_callback(struct saa7146_dev *dev, unsigned long status) ...@@ -398,22 +408,22 @@ static void vv_callback(struct saa7146_dev *dev, unsigned long status)
{ {
u32 isr = status; u32 isr = status;
DEB_INT(("dev:%p, isr:0x%08x\n",dev,(u32)status)); DEB_INT("dev:%p, isr:0x%08x\n", dev, (u32)status);
if (0 != (isr & (MASK_27))) { if (0 != (isr & (MASK_27))) {
DEB_INT(("irq: RPS0 (0x%08x).\n",isr)); DEB_INT("irq: RPS0 (0x%08x)\n", isr);
saa7146_video_uops.irq_done(dev,isr); saa7146_video_uops.irq_done(dev,isr);
} }
if (0 != (isr & (MASK_28))) { if (0 != (isr & (MASK_28))) {
u32 mc2 = saa7146_read(dev, MC2); u32 mc2 = saa7146_read(dev, MC2);
if( 0 != (mc2 & MASK_15)) { if( 0 != (mc2 & MASK_15)) {
DEB_INT(("irq: RPS1 vbi workaround (0x%08x).\n",isr)); DEB_INT("irq: RPS1 vbi workaround (0x%08x)\n", isr);
wake_up(&dev->vv_data->vbi_wq); wake_up(&dev->vv_data->vbi_wq);
saa7146_write(dev,MC2, MASK_31); saa7146_write(dev,MC2, MASK_31);
return; return;
} }
DEB_INT(("irq: RPS1 (0x%08x).\n",isr)); DEB_INT("irq: RPS1 (0x%08x)\n", isr);
saa7146_vbi_uops.irq_done(dev,isr); saa7146_vbi_uops.irq_done(dev,isr);
} }
} }
...@@ -429,13 +439,13 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) ...@@ -429,13 +439,13 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL); vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL);
if (vv == NULL) { if (vv == NULL) {
ERR(("out of memory. aborting.\n")); ERR("out of memory. aborting.\n");
return -ENOMEM; return -ENOMEM;
} }
ext_vv->ops = saa7146_video_ioctl_ops; ext_vv->ops = saa7146_video_ioctl_ops;
ext_vv->core_ops = &saa7146_video_ioctl_ops; ext_vv->core_ops = &saa7146_video_ioctl_ops;
DEB_EE(("dev:%p\n",dev)); DEB_EE("dev:%p\n", dev);
/* set default values for video parts of the saa7146 */ /* set default values for video parts of the saa7146 */
saa7146_write(dev, BCS_CTRL, 0x80400040); saa7146_write(dev, BCS_CTRL, 0x80400040);
...@@ -450,7 +460,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) ...@@ -450,7 +460,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle); vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
if( NULL == vv->d_clipping.cpu_addr ) { if( NULL == vv->d_clipping.cpu_addr ) {
ERR(("out of memory. aborting.\n")); ERR("out of memory. aborting.\n");
kfree(vv); kfree(vv);
return -1; return -1;
} }
...@@ -471,7 +481,7 @@ int saa7146_vv_release(struct saa7146_dev* dev) ...@@ -471,7 +481,7 @@ int saa7146_vv_release(struct saa7146_dev* dev)
{ {
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
DEB_EE(("dev:%p\n",dev)); DEB_EE("dev:%p\n", dev);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
pci_free_consistent(dev->pci, SAA7146_CLIPPING_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle); pci_free_consistent(dev->pci, SAA7146_CLIPPING_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle);
...@@ -490,7 +500,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, ...@@ -490,7 +500,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
int err; int err;
int i; int i;
DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type)); DEB_EE("dev:%p, name:'%s', type:%d\n", dev, name, type);
// released by vfd->release // released by vfd->release
vfd = video_device_alloc(); vfd = video_device_alloc();
...@@ -509,13 +519,13 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev, ...@@ -509,13 +519,13 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
err = video_register_device(vfd, type, -1); err = video_register_device(vfd, type, -1);
if (err < 0) { if (err < 0) {
ERR(("cannot register v4l2 device. skipping.\n")); ERR("cannot register v4l2 device. skipping.\n");
video_device_release(vfd); video_device_release(vfd);
return err; return err;
} }
INFO(("%s: registered device %s [v4l2]\n", pr_info("%s: registered device %s [v4l2]\n",
dev->name, video_device_node_name(vfd))); dev->name, video_device_node_name(vfd));
*vid = vfd; *vid = vfd;
return 0; return 0;
...@@ -524,7 +534,7 @@ EXPORT_SYMBOL_GPL(saa7146_register_device); ...@@ -524,7 +534,7 @@ EXPORT_SYMBOL_GPL(saa7146_register_device);
int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev) int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
{ {
DEB_EE(("dev:%p\n",dev)); DEB_EE("dev:%p\n", dev);
video_unregister_device(*vid); video_unregister_device(*vid);
*vid = NULL; *vid = NULL;
......
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
...@@ -711,8 +713,8 @@ static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa71 ...@@ -711,8 +713,8 @@ static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa71
int depth = sfmt->depth; int depth = sfmt->depth;
DEB_CAP(("[size=%dx%d,fields=%s]\n", DEB_CAP("[size=%dx%d,fields=%s]\n",
width,height,v4l2_field_names[field])); width, height, v4l2_field_names[field]);
if( bytesperline != 0) { if( bytesperline != 0) {
vdma1.pitch = bytesperline*2; vdma1.pitch = bytesperline*2;
...@@ -837,8 +839,8 @@ static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa71 ...@@ -837,8 +839,8 @@ static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa71
BUG_ON(0 == buf->pt[1].dma); BUG_ON(0 == buf->pt[1].dma);
BUG_ON(0 == buf->pt[2].dma); BUG_ON(0 == buf->pt[2].dma);
DEB_CAP(("[size=%dx%d,fields=%s]\n", DEB_CAP("[size=%dx%d,fields=%s]\n",
width,height,v4l2_field_names[field])); width, height, v4l2_field_names[field]);
/* fixme: look at bytesperline! */ /* fixme: look at bytesperline! */
...@@ -998,12 +1000,12 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc ...@@ -998,12 +1000,12 @@ void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struc
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
u32 vdma1_prot_addr; u32 vdma1_prot_addr;
DEB_CAP(("buf:%p, next:%p\n",buf,next)); DEB_CAP("buf:%p, next:%p\n", buf, next);
vdma1_prot_addr = saa7146_read(dev, PROT_ADDR1); vdma1_prot_addr = saa7146_read(dev, PROT_ADDR1);
if( 0 == vdma1_prot_addr ) { if( 0 == vdma1_prot_addr ) {
/* clear out beginning of streaming bit (rps register 0)*/ /* clear out beginning of streaming bit (rps register 0)*/
DEB_CAP(("forcing sync to new frame\n")); DEB_CAP("forcing sync to new frame\n");
saa7146_write(dev, MC2, MASK_27 ); saa7146_write(dev, MC2, MASK_27 );
} }
......
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
static u32 saa7146_i2c_func(struct i2c_adapter *adapter) static u32 saa7146_i2c_func(struct i2c_adapter *adapter)
{ {
//fm DEB_I2C(("'%s'.\n", adapter->name)); /* DEB_I2C("'%s'\n", adapter->name); */
return I2C_FUNC_I2C return I2C_FUNC_I2C
| I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_QUICK
...@@ -14,9 +16,7 @@ static u32 saa7146_i2c_func(struct i2c_adapter *adapter) ...@@ -14,9 +16,7 @@ static u32 saa7146_i2c_func(struct i2c_adapter *adapter)
static inline u32 saa7146_i2c_status(struct saa7146_dev *dev) static inline u32 saa7146_i2c_status(struct saa7146_dev *dev)
{ {
u32 iicsta = saa7146_read(dev, I2C_STATUS); u32 iicsta = saa7146_read(dev, I2C_STATUS);
/* /* DEB_I2C("status: 0x%08x\n", iicsta); */
DEB_I2C(("status: 0x%08x\n",iicsta));
*/
return iicsta; return iicsta;
} }
...@@ -39,10 +39,11 @@ static int saa7146_i2c_msg_prepare(const struct i2c_msg *m, int num, __le32 *op) ...@@ -39,10 +39,11 @@ static int saa7146_i2c_msg_prepare(const struct i2c_msg *m, int num, __le32 *op)
plus one extra byte to address the device */ plus one extra byte to address the device */
mem = 1 + ((mem-1) / 3); mem = 1 + ((mem-1) / 3);
/* we assume that op points to a memory of at least SAA7146_I2C_MEM bytes /* we assume that op points to a memory of at least
size. if we exceed this limit... */ * SAA7146_I2C_MEM bytes size. if we exceed this limit...
if ( (4*mem) > SAA7146_I2C_MEM ) { */
//fm DEB_I2C(("cannot prepare i2c-message.\n")); if ((4 * mem) > SAA7146_I2C_MEM) {
/* DEB_I2C("cannot prepare i2c-message\n"); */
return -ENOMEM; return -ENOMEM;
} }
...@@ -123,7 +124,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev) ...@@ -123,7 +124,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev)
if ( 0 != ( status & SAA7146_I2C_BUSY) ) { if ( 0 != ( status & SAA7146_I2C_BUSY) ) {
/* yes, kill ongoing operation */ /* yes, kill ongoing operation */
DEB_I2C(("busy_state detected.\n")); DEB_I2C("busy_state detected\n");
/* set "ABORT-OPERATION"-bit (bit 7)*/ /* set "ABORT-OPERATION"-bit (bit 7)*/
saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07)); saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07));
...@@ -141,7 +142,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev) ...@@ -141,7 +142,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev)
if ( dev->i2c_bitrate != status ) { if ( dev->i2c_bitrate != status ) {
DEB_I2C(("error_state detected. status:0x%08x\n",status)); DEB_I2C("error_state detected. status:0x%08x\n", status);
/* Repeat the abort operation. This seems to be necessary /* Repeat the abort operation. This seems to be necessary
after serious protocol errors caused by e.g. the SAA7740 */ after serious protocol errors caused by e.g. the SAA7740 */
...@@ -164,7 +165,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev) ...@@ -164,7 +165,7 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev)
/* if any error is still present, a fatal error has occurred ... */ /* if any error is still present, a fatal error has occurred ... */
status = saa7146_i2c_status(dev); status = saa7146_i2c_status(dev);
if ( dev->i2c_bitrate != status ) { if ( dev->i2c_bitrate != status ) {
DEB_I2C(("fatal error. status:0x%08x\n",status)); DEB_I2C("fatal error. status:0x%08x\n", status);
return -1; return -1;
} }
...@@ -181,7 +182,8 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -181,7 +182,8 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
unsigned long timeout; unsigned long timeout;
/* write out i2c-command */ /* write out i2c-command */
DEB_I2C(("before: 0x%08x (status: 0x%08x), %d\n",*dword,saa7146_read(dev, I2C_STATUS), dev->i2c_op)); DEB_I2C("before: 0x%08x (status: 0x%08x), %d\n",
*dword, saa7146_read(dev, I2C_STATUS), dev->i2c_op);
if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) { if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) {
...@@ -202,7 +204,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -202,7 +204,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
/* a signal arrived */ /* a signal arrived */
return -ERESTARTSYS; return -ERESTARTSYS;
printk(KERN_WARNING "%s %s [irq]: timed out waiting for end of xfer\n", pr_warn("%s %s [irq]: timed out waiting for end of xfer\n",
dev->name, __func__); dev->name, __func__);
return -EIO; return -EIO;
} }
...@@ -220,7 +222,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -220,7 +222,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
break; break;
} }
if (time_after(jiffies,timeout)) { if (time_after(jiffies,timeout)) {
printk(KERN_WARNING "%s %s: timed out waiting for MC2\n", pr_warn("%s %s: timed out waiting for MC2\n",
dev->name, __func__); dev->name, __func__);
return -EIO; return -EIO;
} }
...@@ -237,7 +239,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -237,7 +239,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
/* this is normal when probing the bus /* this is normal when probing the bus
* (no answer from nonexisistant device...) * (no answer from nonexisistant device...)
*/ */
printk(KERN_WARNING "%s %s [poll]: timed out waiting for end of xfer\n", pr_warn("%s %s [poll]: timed out waiting for end of xfer\n",
dev->name, __func__); dev->name, __func__);
return -EIO; return -EIO;
} }
...@@ -257,24 +259,24 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -257,24 +259,24 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
if ( 0 == (status & SAA7146_I2C_ERR) || if ( 0 == (status & SAA7146_I2C_ERR) ||
0 == (status & SAA7146_I2C_BUSY) ) { 0 == (status & SAA7146_I2C_BUSY) ) {
/* it may take some time until ERR goes high - ignore */ /* it may take some time until ERR goes high - ignore */
DEB_I2C(("unexpected i2c status %04x\n", status)); DEB_I2C("unexpected i2c status %04x\n", status);
} }
if( 0 != (status & SAA7146_I2C_SPERR) ) { if( 0 != (status & SAA7146_I2C_SPERR) ) {
DEB_I2C(("error due to invalid start/stop condition.\n")); DEB_I2C("error due to invalid start/stop condition\n");
} }
if( 0 != (status & SAA7146_I2C_DTERR) ) { if( 0 != (status & SAA7146_I2C_DTERR) ) {
DEB_I2C(("error in data transmission.\n")); DEB_I2C("error in data transmission\n");
} }
if( 0 != (status & SAA7146_I2C_DRERR) ) { if( 0 != (status & SAA7146_I2C_DRERR) ) {
DEB_I2C(("error when receiving data.\n")); DEB_I2C("error when receiving data\n");
} }
if( 0 != (status & SAA7146_I2C_AL) ) { if( 0 != (status & SAA7146_I2C_AL) ) {
DEB_I2C(("error because arbitration lost.\n")); DEB_I2C("error because arbitration lost\n");
} }
/* we handle address-errors here */ /* we handle address-errors here */
if( 0 != (status & SAA7146_I2C_APERR) ) { if( 0 != (status & SAA7146_I2C_APERR) ) {
DEB_I2C(("error in address phase.\n")); DEB_I2C("error in address phase\n");
return -EREMOTEIO; return -EREMOTEIO;
} }
...@@ -284,7 +286,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor ...@@ -284,7 +286,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, __le32 *dword, int shor
/* read back data, just in case we were reading ... */ /* read back data, just in case we were reading ... */
*dword = cpu_to_le32(saa7146_read(dev, I2C_TRANSFER)); *dword = cpu_to_le32(saa7146_read(dev, I2C_TRANSFER));
DEB_I2C(("after: 0x%08x\n",*dword)); DEB_I2C("after: 0x%08x\n", *dword);
return 0; return 0;
} }
...@@ -299,7 +301,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m ...@@ -299,7 +301,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
return -ERESTARTSYS; return -ERESTARTSYS;
for(i=0;i<num;i++) { for(i=0;i<num;i++) {
DEB_I2C(("msg:%d/%d\n",i+1,num)); DEB_I2C("msg:%d/%d\n", i+1, num);
} }
/* prepare the message(s), get number of u32s to transfer */ /* prepare the message(s), get number of u32s to transfer */
...@@ -316,7 +318,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m ...@@ -316,7 +318,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
/* reset the i2c-device if necessary */ /* reset the i2c-device if necessary */
err = saa7146_i2c_reset(dev); err = saa7146_i2c_reset(dev);
if ( 0 > err ) { if ( 0 > err ) {
DEB_I2C(("could not reset i2c-device.\n")); DEB_I2C("could not reset i2c-device\n");
goto out; goto out;
} }
...@@ -336,7 +338,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m ...@@ -336,7 +338,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
address error and trust the saa7146 address error detection. */ address error and trust the saa7146 address error detection. */
if (-EREMOTEIO == err && 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) if (-EREMOTEIO == err && 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags))
goto out; goto out;
DEB_I2C(("error while sending message(s). starting again.\n")); DEB_I2C("error while sending message(s). starting again\n");
break; break;
} }
} }
...@@ -356,13 +358,13 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m ...@@ -356,13 +358,13 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
/* if any things had to be read, get the results */ /* if any things had to be read, get the results */
if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) { if ( 0 != saa7146_i2c_msg_cleanup(msgs, num, buffer)) {
DEB_I2C(("could not cleanup i2c-message.\n")); DEB_I2C("could not cleanup i2c-message\n");
err = -1; err = -1;
goto out; goto out;
} }
/* return the number of delivered messages */ /* return the number of delivered messages */
DEB_I2C(("transmission successful. (msg:%d).\n",err)); DEB_I2C("transmission successful. (msg:%d)\n", err);
out: out:
/* another bug in revision 0: the i2c-registers get uploaded randomly by other /* another bug in revision 0: the i2c-registers get uploaded randomly by other
uploads, so we better clear them out before continuing */ uploads, so we better clear them out before continuing */
...@@ -370,7 +372,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m ...@@ -370,7 +372,7 @@ static int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *m
__le32 zero = 0; __le32 zero = 0;
saa7146_i2c_reset(dev); saa7146_i2c_reset(dev);
if( 0 != saa7146_i2c_writeout(dev, &zero, short_delay)) { if( 0 != saa7146_i2c_writeout(dev, &zero, short_delay)) {
INFO(("revision 0 error. this should never happen.\n")); pr_info("revision 0 error. this should never happen\n");
} }
} }
...@@ -400,7 +402,7 @@ static struct i2c_algorithm saa7146_algo = { ...@@ -400,7 +402,7 @@ static struct i2c_algorithm saa7146_algo = {
int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate) int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate)
{ {
DEB_EE(("bitrate: 0x%08x\n",bitrate)); DEB_EE("bitrate: 0x%08x\n", bitrate);
/* enable i2c-port pins */ /* enable i2c-port pins */
saa7146_write(dev, MC1, (MASK_08 | MASK_24)); saa7146_write(dev, MC1, (MASK_08 | MASK_24));
......
...@@ -14,7 +14,7 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -14,7 +14,7 @@ static int vbi_workaround(struct saa7146_dev *dev)
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
DEB_VBI(("dev:%p\n",dev)); DEB_VBI("dev:%p\n", dev);
/* once again, a bug in the saa7146: the brs acquisition /* once again, a bug in the saa7146: the brs acquisition
is buggy and especially the BXO-counter does not work is buggy and especially the BXO-counter does not work
...@@ -40,14 +40,14 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -40,14 +40,14 @@ static int vbi_workaround(struct saa7146_dev *dev)
WRITE_RPS1(0xc000008c); WRITE_RPS1(0xc000008c);
/* wait for vbi_a or vbi_b*/ /* wait for vbi_a or vbi_b*/
if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) { if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) {
DEB_D(("...using port b\n")); DEB_D("...using port b\n");
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_E_FID_B); WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_E_FID_B);
WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_O_FID_B); WRITE_RPS1(CMD_PAUSE | CMD_OAN | CMD_SIG1 | CMD_O_FID_B);
/* /*
WRITE_RPS1(CMD_PAUSE | MASK_09); WRITE_RPS1(CMD_PAUSE | MASK_09);
*/ */
} else { } else {
DEB_D(("...using port a\n")); DEB_D("...using port a\n");
WRITE_RPS1(CMD_PAUSE | MASK_10); WRITE_RPS1(CMD_PAUSE | MASK_10);
} }
/* upload brs */ /* upload brs */
...@@ -103,7 +103,7 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -103,7 +103,7 @@ static int vbi_workaround(struct saa7146_dev *dev)
schedule(); schedule();
DEB_VBI(("brs bug workaround %d/1.\n",i)); DEB_VBI("brs bug workaround %d/1\n", i);
remove_wait_queue(&vv->vbi_wq, &wait); remove_wait_queue(&vv->vbi_wq, &wait);
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
...@@ -116,7 +116,8 @@ static int vbi_workaround(struct saa7146_dev *dev) ...@@ -116,7 +116,8 @@ static int vbi_workaround(struct saa7146_dev *dev)
if(signal_pending(current)) { if(signal_pending(current)) {
DEB_VBI(("aborted (rps:0x%08x).\n",saa7146_read(dev,RPS_ADDR1))); DEB_VBI("aborted (rps:0x%08x)\n",
saa7146_read(dev, RPS_ADDR1));
/* stop rps1 for sure */ /* stop rps1 for sure */
saa7146_write(dev, MC1, MASK_29); saa7146_write(dev, MC1, MASK_29);
...@@ -207,7 +208,7 @@ static int buffer_activate(struct saa7146_dev *dev, ...@@ -207,7 +208,7 @@ static int buffer_activate(struct saa7146_dev *dev,
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
buf->vb.state = VIDEOBUF_ACTIVE; buf->vb.state = VIDEOBUF_ACTIVE;
DEB_VBI(("dev:%p, buf:%p, next:%p\n",dev,buf,next)); DEB_VBI("dev:%p, buf:%p, next:%p\n", dev, buf, next);
saa7146_set_vbi_capture(dev,buf,next); saa7146_set_vbi_capture(dev,buf,next);
mod_timer(&vv->vbi_q.timeout, jiffies+BUFFER_TIMEOUT); mod_timer(&vv->vbi_q.timeout, jiffies+BUFFER_TIMEOUT);
...@@ -228,10 +229,10 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e ...@@ -228,10 +229,10 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
llength = vbi_pixel_to_capture; llength = vbi_pixel_to_capture;
size = lines * llength; size = lines * llength;
DEB_VBI(("vb:%p\n",vb)); DEB_VBI("vb:%p\n", vb);
if (0 != buf->vb.baddr && buf->vb.bsize < size) { if (0 != buf->vb.baddr && buf->vb.bsize < size) {
DEB_VBI(("size mismatch.\n")); DEB_VBI("size mismatch\n");
return -EINVAL; return -EINVAL;
} }
...@@ -263,7 +264,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e ...@@ -263,7 +264,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
return 0; return 0;
oops: oops:
DEB_VBI(("error out.\n")); DEB_VBI("error out\n");
saa7146_dma_free(dev,q,buf); saa7146_dma_free(dev,q,buf);
return err; return err;
...@@ -279,7 +280,7 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned ...@@ -279,7 +280,7 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned
*size = lines * llength; *size = lines * llength;
*count = 2; *count = 2;
DEB_VBI(("count:%d, size:%d\n",*count,*size)); DEB_VBI("count:%d, size:%d\n", *count, *size);
return 0; return 0;
} }
...@@ -292,7 +293,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -292,7 +293,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
struct saa7146_buf *buf = (struct saa7146_buf *)vb; struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_VBI(("vb:%p\n",vb)); DEB_VBI("vb:%p\n", vb);
saa7146_buffer_queue(dev,&vv->vbi_q,buf); saa7146_buffer_queue(dev,&vv->vbi_q,buf);
} }
...@@ -303,7 +304,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -303,7 +304,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
struct saa7146_buf *buf = (struct saa7146_buf *)vb; struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_VBI(("vb:%p\n",vb)); DEB_VBI("vb:%p\n", vb);
saa7146_dma_free(dev,q,buf); saa7146_dma_free(dev,q,buf);
} }
...@@ -321,7 +322,7 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file) ...@@ -321,7 +322,7 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file)
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
unsigned long flags; unsigned long flags;
DEB_VBI(("dev:%p, fh:%p\n",dev, fh)); DEB_VBI("dev:%p, fh:%p\n", dev, fh);
spin_lock_irqsave(&dev->slock,flags); spin_lock_irqsave(&dev->slock,flags);
...@@ -354,14 +355,14 @@ static void vbi_read_timeout(unsigned long data) ...@@ -354,14 +355,14 @@ static void vbi_read_timeout(unsigned long data)
struct saa7146_fh *fh = file->private_data; struct saa7146_fh *fh = file->private_data;
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
DEB_VBI(("dev:%p, fh:%p\n",dev, fh)); DEB_VBI("dev:%p, fh:%p\n", dev, fh);
vbi_stop(fh, file); vbi_stop(fh, file);
} }
static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv) static void vbi_init(struct saa7146_dev *dev, struct saa7146_vv *vv)
{ {
DEB_VBI(("dev:%p\n",dev)); DEB_VBI("dev:%p\n", dev);
INIT_LIST_HEAD(&vv->vbi_q.queue); INIT_LIST_HEAD(&vv->vbi_q.queue);
...@@ -380,11 +381,11 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) ...@@ -380,11 +381,11 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
u32 arbtr_ctrl = saa7146_read(dev, PCI_BT_V1); u32 arbtr_ctrl = saa7146_read(dev, PCI_BT_V1);
int ret = 0; int ret = 0;
DEB_VBI(("dev:%p, fh:%p\n",dev,fh)); DEB_VBI("dev:%p, fh:%p\n", dev, fh);
ret = saa7146_res_get(fh, RESOURCE_DMA3_BRS); ret = saa7146_res_get(fh, RESOURCE_DMA3_BRS);
if (0 == ret) { if (0 == ret) {
DEB_S(("cannot get vbi RESOURCE_DMA3_BRS resource\n")); DEB_S("cannot get vbi RESOURCE_DMA3_BRS resource\n");
return -EBUSY; return -EBUSY;
} }
...@@ -425,7 +426,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) ...@@ -425,7 +426,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
saa7146_write(dev, BRS_CTRL, 0x00000001); saa7146_write(dev, BRS_CTRL, 0x00000001);
if (0 != (ret = vbi_workaround(dev))) { if (0 != (ret = vbi_workaround(dev))) {
DEB_VBI(("vbi workaround failed!\n")); DEB_VBI("vbi workaround failed!\n");
/* return ret;*/ /* return ret;*/
} }
} }
...@@ -439,7 +440,7 @@ static void vbi_close(struct saa7146_dev *dev, struct file *file) ...@@ -439,7 +440,7 @@ static void vbi_close(struct saa7146_dev *dev, struct file *file)
{ {
struct saa7146_fh *fh = file->private_data; struct saa7146_fh *fh = file->private_data;
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
DEB_VBI(("dev:%p, fh:%p\n",dev,fh)); DEB_VBI("dev:%p, fh:%p\n", dev, fh);
if( fh == vv->vbi_streaming ) { if( fh == vv->vbi_streaming ) {
vbi_stop(fh, file); vbi_stop(fh, file);
...@@ -453,13 +454,13 @@ static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status) ...@@ -453,13 +454,13 @@ static void vbi_irq_done(struct saa7146_dev *dev, unsigned long status)
spin_lock(&dev->slock); spin_lock(&dev->slock);
if (vv->vbi_q.curr) { if (vv->vbi_q.curr) {
DEB_VBI(("dev:%p, curr:%p\n",dev,vv->vbi_q.curr)); DEB_VBI("dev:%p, curr:%p\n", dev, vv->vbi_q.curr);
/* this must be += 2, one count for each field */ /* this must be += 2, one count for each field */
vv->vbi_fieldcount+=2; vv->vbi_fieldcount+=2;
vv->vbi_q.curr->vb.field_count = vv->vbi_fieldcount; vv->vbi_q.curr->vb.field_count = vv->vbi_fieldcount;
saa7146_buffer_finish(dev,&vv->vbi_q,VIDEOBUF_DONE); saa7146_buffer_finish(dev,&vv->vbi_q,VIDEOBUF_DONE);
} else { } else {
DEB_VBI(("dev:%p\n",dev)); DEB_VBI("dev:%p\n", dev);
} }
saa7146_buffer_next(dev,&vv->vbi_q,1); saa7146_buffer_next(dev,&vv->vbi_q,1);
...@@ -473,7 +474,7 @@ static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff ...@@ -473,7 +474,7 @@ static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
ssize_t ret = 0; ssize_t ret = 0;
DEB_VBI(("dev:%p, fh:%p\n",dev,fh)); DEB_VBI("dev:%p, fh:%p\n", dev, fh);
if( NULL == vv->vbi_streaming ) { if( NULL == vv->vbi_streaming ) {
// fixme: check if dma3 is available // fixme: check if dma3 is available
...@@ -482,7 +483,8 @@ static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff ...@@ -482,7 +483,8 @@ static ssize_t vbi_read(struct file *file, char __user *data, size_t count, loff
} }
if( fh != vv->vbi_streaming ) { if( fh != vv->vbi_streaming ) {
DEB_VBI(("open %p is already using vbi capture.",vv->vbi_streaming)); DEB_VBI("open %p is already using vbi capture\n",
vv->vbi_streaming);
return -EBUSY; return -EBUSY;
} }
......
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#include <media/v4l2-chip-ident.h> #include <media/v4l2-chip-ident.h>
...@@ -94,7 +96,7 @@ struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fou ...@@ -94,7 +96,7 @@ struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fou
} }
} }
DEB_D(("unknown pixelformat:'%4.4s'\n",(char *)&fourcc)); DEB_D("unknown pixelformat:'%4.4s'\n", (char *)&fourcc);
return NULL; return NULL;
} }
...@@ -107,32 +109,32 @@ int saa7146_start_preview(struct saa7146_fh *fh) ...@@ -107,32 +109,32 @@ int saa7146_start_preview(struct saa7146_fh *fh)
struct v4l2_format fmt; struct v4l2_format fmt;
int ret = 0, err = 0; int ret = 0, err = 0;
DEB_EE(("dev:%p, fh:%p\n",dev,fh)); DEB_EE("dev:%p, fh:%p\n", dev, fh);
/* check if we have overlay informations */ /* check if we have overlay informations */
if( NULL == fh->ov.fh ) { if( NULL == fh->ov.fh ) {
DEB_D(("no overlay data available. try S_FMT first.\n")); DEB_D("no overlay data available. try S_FMT first.\n");
return -EAGAIN; return -EAGAIN;
} }
/* check if streaming capture is running */ /* check if streaming capture is running */
if (IS_CAPTURE_ACTIVE(fh) != 0) { if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("streaming capture is active.\n")); DEB_D("streaming capture is active\n");
return -EBUSY; return -EBUSY;
} }
/* check if overlay is running */ /* check if overlay is running */
if (IS_OVERLAY_ACTIVE(fh) != 0) { if (IS_OVERLAY_ACTIVE(fh) != 0) {
if (vv->video_fh == fh) { if (vv->video_fh == fh) {
DEB_D(("overlay is already active.\n")); DEB_D("overlay is already active\n");
return 0; return 0;
} }
DEB_D(("overlay is already active in another open.\n")); DEB_D("overlay is already active in another open\n");
return -EBUSY; return -EBUSY;
} }
if (0 == saa7146_res_get(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP)) { if (0 == saa7146_res_get(fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP)) {
DEB_D(("cannot get necessary overlay resources\n")); DEB_D("cannot get necessary overlay resources\n");
return -EBUSY; return -EBUSY;
} }
...@@ -145,13 +147,13 @@ int saa7146_start_preview(struct saa7146_fh *fh) ...@@ -145,13 +147,13 @@ int saa7146_start_preview(struct saa7146_fh *fh)
fh->ov.win = fmt.fmt.win; fh->ov.win = fmt.fmt.win;
vv->ov_data = &fh->ov; vv->ov_data = &fh->ov;
DEB_D(("%dx%d+%d+%d %s field=%s\n", DEB_D("%dx%d+%d+%d %s field=%s\n",
fh->ov.win.w.width,fh->ov.win.w.height, fh->ov.win.w.width, fh->ov.win.w.height,
fh->ov.win.w.left,fh->ov.win.w.top, fh->ov.win.w.left, fh->ov.win.w.top,
vv->ov_fmt->name,v4l2_field_names[fh->ov.win.field])); vv->ov_fmt->name, v4l2_field_names[fh->ov.win.field]);
if (0 != (ret = saa7146_enable_overlay(fh))) { if (0 != (ret = saa7146_enable_overlay(fh))) {
DEB_D(("enabling overlay failed: %d\n",ret)); DEB_D("enabling overlay failed: %d\n", ret);
saa7146_res_free(vv->video_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP); saa7146_res_free(vv->video_fh, RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP);
return ret; return ret;
} }
...@@ -168,22 +170,22 @@ int saa7146_stop_preview(struct saa7146_fh *fh) ...@@ -168,22 +170,22 @@ int saa7146_stop_preview(struct saa7146_fh *fh)
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
DEB_EE(("dev:%p, fh:%p\n",dev,fh)); DEB_EE("dev:%p, fh:%p\n", dev, fh);
/* check if streaming capture is running */ /* check if streaming capture is running */
if (IS_CAPTURE_ACTIVE(fh) != 0) { if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("streaming capture is active.\n")); DEB_D("streaming capture is active\n");
return -EBUSY; return -EBUSY;
} }
/* check if overlay is running at all */ /* check if overlay is running at all */
if ((vv->video_status & STATUS_OVERLAY) == 0) { if ((vv->video_status & STATUS_OVERLAY) == 0) {
DEB_D(("no active overlay.\n")); DEB_D("no active overlay\n");
return 0; return 0;
} }
if (vv->video_fh != fh) { if (vv->video_fh != fh) {
DEB_D(("overlay is active, but in another open.\n")); DEB_D("overlay is active, but in another open\n");
return -EBUSY; return -EBUSY;
} }
...@@ -268,7 +270,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu ...@@ -268,7 +270,7 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
int length = dma->sglen; int length = dma->sglen;
struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat); struct saa7146_format *sfmt = saa7146_format_by_fourcc(dev,buf->fmt->pixelformat);
DEB_EE(("dev:%p, buf:%p, sg_len:%d\n",dev,buf,length)); DEB_EE("dev:%p, buf:%p, sg_len:%d\n", dev, buf, length);
if( 0 != IS_PLANAR(sfmt->trans)) { if( 0 != IS_PLANAR(sfmt->trans)) {
struct saa7146_pgtable *pt1 = &buf->pt[0]; struct saa7146_pgtable *pt1 = &buf->pt[0];
...@@ -288,7 +290,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu ...@@ -288,7 +290,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
m3 = ((size+(size/2)+PAGE_SIZE)/PAGE_SIZE)-1; m3 = ((size+(size/2)+PAGE_SIZE)/PAGE_SIZE)-1;
o1 = size%PAGE_SIZE; o1 = size%PAGE_SIZE;
o2 = (size+(size/4))%PAGE_SIZE; o2 = (size+(size/4))%PAGE_SIZE;
DEB_CAP(("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n",size,m1,m2,m3,o1,o2)); DEB_CAP("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n",
size, m1, m2, m3, o1, o2);
break; break;
} }
case 16: { case 16: {
...@@ -298,7 +301,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu ...@@ -298,7 +301,8 @@ static int saa7146_pgtable_build(struct saa7146_dev *dev, struct saa7146_buf *bu
m3 = ((2*size+PAGE_SIZE)/PAGE_SIZE)-1; m3 = ((2*size+PAGE_SIZE)/PAGE_SIZE)-1;
o1 = size%PAGE_SIZE; o1 = size%PAGE_SIZE;
o2 = (size+(size/2))%PAGE_SIZE; o2 = (size+(size/2))%PAGE_SIZE;
DEB_CAP(("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n",size,m1,m2,m3,o1,o2)); DEB_CAP("size:%d, m1:%d, m2:%d, m3:%d, o1:%d, o2:%d\n",
size, m1, m2, m3, o1, o2);
break; break;
} }
default: { default: {
...@@ -387,23 +391,23 @@ static int video_begin(struct saa7146_fh *fh) ...@@ -387,23 +391,23 @@ static int video_begin(struct saa7146_fh *fh)
unsigned int resource; unsigned int resource;
int ret = 0, err = 0; int ret = 0, err = 0;
DEB_EE(("dev:%p, fh:%p\n",dev,fh)); DEB_EE("dev:%p, fh:%p\n", dev, fh);
if ((vv->video_status & STATUS_CAPTURE) != 0) { if ((vv->video_status & STATUS_CAPTURE) != 0) {
if (vv->video_fh == fh) { if (vv->video_fh == fh) {
DEB_S(("already capturing.\n")); DEB_S("already capturing\n");
return 0; return 0;
} }
DEB_S(("already capturing in another open.\n")); DEB_S("already capturing in another open\n");
return -EBUSY; return -EBUSY;
} }
if ((vv->video_status & STATUS_OVERLAY) != 0) { if ((vv->video_status & STATUS_OVERLAY) != 0) {
DEB_S(("warning: suspending overlay video for streaming capture.\n")); DEB_S("warning: suspending overlay video for streaming capture\n");
vv->ov_suspend = vv->video_fh; vv->ov_suspend = vv->video_fh;
err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */ err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */
if (0 != err) { if (0 != err) {
DEB_D(("suspending video failed. aborting\n")); DEB_D("suspending video failed. aborting\n");
return err; return err;
} }
} }
...@@ -420,7 +424,7 @@ static int video_begin(struct saa7146_fh *fh) ...@@ -420,7 +424,7 @@ static int video_begin(struct saa7146_fh *fh)
ret = saa7146_res_get(fh, resource); ret = saa7146_res_get(fh, resource);
if (0 == ret) { if (0 == ret) {
DEB_S(("cannot get capture resource %d\n",resource)); DEB_S("cannot get capture resource %d\n", resource);
if (vv->ov_suspend != NULL) { if (vv->ov_suspend != NULL) {
saa7146_start_preview(vv->ov_suspend); saa7146_start_preview(vv->ov_suspend);
vv->ov_suspend = NULL; vv->ov_suspend = NULL;
...@@ -448,15 +452,15 @@ static int video_end(struct saa7146_fh *fh, struct file *file) ...@@ -448,15 +452,15 @@ static int video_end(struct saa7146_fh *fh, struct file *file)
unsigned long flags; unsigned long flags;
unsigned int resource; unsigned int resource;
u32 dmas = 0; u32 dmas = 0;
DEB_EE(("dev:%p, fh:%p\n",dev,fh)); DEB_EE("dev:%p, fh:%p\n", dev, fh);
if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) { if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) {
DEB_S(("not capturing.\n")); DEB_S("not capturing\n");
return 0; return 0;
} }
if (vv->video_fh != fh) { if (vv->video_fh != fh) {
DEB_S(("capturing, but in another open.\n")); DEB_S("capturing, but in another open\n");
return -EBUSY; return -EBUSY;
} }
...@@ -530,7 +534,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f ...@@ -530,7 +534,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
struct saa7146_format *fmt; struct saa7146_format *fmt;
DEB_EE(("VIDIOC_S_FBUF\n")); DEB_EE("VIDIOC_S_FBUF\n");
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
...@@ -542,13 +546,13 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f ...@@ -542,13 +546,13 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
/* planar formats are not allowed for overlay video, clipping and video dma would clash */ /* planar formats are not allowed for overlay video, clipping and video dma would clash */
if (fmt->flags & FORMAT_IS_PLANAR) if (fmt->flags & FORMAT_IS_PLANAR)
DEB_S(("planar pixelformat '%4.4s' not allowed for overlay\n", DEB_S("planar pixelformat '%4.4s' not allowed for overlay\n",
(char *)&fmt->pixelformat)); (char *)&fmt->pixelformat);
/* check if overlay is running */ /* check if overlay is running */
if (IS_OVERLAY_ACTIVE(fh) != 0) { if (IS_OVERLAY_ACTIVE(fh) != 0) {
if (vv->video_fh != fh) { if (vv->video_fh != fh) {
DEB_D(("refusing to change framebuffer informations while overlay is active in another open.\n")); DEB_D("refusing to change framebuffer informations while overlay is active in another open\n");
return -EBUSY; return -EBUSY;
} }
} }
...@@ -559,7 +563,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f ...@@ -559,7 +563,7 @@ static int vidioc_s_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *f
if (vv->ov_fb.fmt.bytesperline < vv->ov_fb.fmt.width) { if (vv->ov_fb.fmt.bytesperline < vv->ov_fb.fmt.width) {
vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8; vv->ov_fb.fmt.bytesperline = vv->ov_fb.fmt.width * fmt->depth / 8;
DEB_D(("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline)); DEB_D("setting bytesperline to %d\n", vv->ov_fb.fmt.bytesperline);
} }
return 0; return 0;
} }
...@@ -588,7 +592,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl * ...@@ -588,7 +592,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *
if (ctrl == NULL) if (ctrl == NULL)
return -EINVAL; return -EINVAL;
DEB_EE(("VIDIOC_QUERYCTRL: id:%d\n", c->id)); DEB_EE("VIDIOC_QUERYCTRL: id:%d\n", c->id);
*c = *ctrl; *c = *ctrl;
return 0; return 0;
} }
...@@ -607,25 +611,25 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c) ...@@ -607,25 +611,25 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c)
case V4L2_CID_BRIGHTNESS: case V4L2_CID_BRIGHTNESS:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0xff & (value >> 24); c->value = 0xff & (value >> 24);
DEB_D(("V4L2_CID_BRIGHTNESS: %d\n", c->value)); DEB_D("V4L2_CID_BRIGHTNESS: %d\n", c->value);
break; break;
case V4L2_CID_CONTRAST: case V4L2_CID_CONTRAST:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0x7f & (value >> 16); c->value = 0x7f & (value >> 16);
DEB_D(("V4L2_CID_CONTRAST: %d\n", c->value)); DEB_D("V4L2_CID_CONTRAST: %d\n", c->value);
break; break;
case V4L2_CID_SATURATION: case V4L2_CID_SATURATION:
value = saa7146_read(dev, BCS_CTRL); value = saa7146_read(dev, BCS_CTRL);
c->value = 0x7f & (value >> 0); c->value = 0x7f & (value >> 0);
DEB_D(("V4L2_CID_SATURATION: %d\n", c->value)); DEB_D("V4L2_CID_SATURATION: %d\n", c->value);
break; break;
case V4L2_CID_VFLIP: case V4L2_CID_VFLIP:
c->value = vv->vflip; c->value = vv->vflip;
DEB_D(("V4L2_CID_VFLIP: %d\n", c->value)); DEB_D("V4L2_CID_VFLIP: %d\n", c->value);
break; break;
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
c->value = vv->hflip; c->value = vv->hflip;
DEB_D(("V4L2_CID_HFLIP: %d\n", c->value)); DEB_D("V4L2_CID_HFLIP: %d\n", c->value);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -641,7 +645,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c) ...@@ -641,7 +645,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
ctrl = ctrl_by_id(c->id); ctrl = ctrl_by_id(c->id);
if (NULL == ctrl) { if (NULL == ctrl) {
DEB_D(("unknown control %d\n", c->id)); DEB_D("unknown control %d\n", c->id);
return -EINVAL; return -EINVAL;
} }
...@@ -686,14 +690,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c) ...@@ -686,14 +690,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c)
case V4L2_CID_HFLIP: case V4L2_CID_HFLIP:
/* fixme: we can support changing VFLIP and HFLIP here... */ /* fixme: we can support changing VFLIP and HFLIP here... */
if (IS_CAPTURE_ACTIVE(fh) != 0) { if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_HFLIP while active capture.\n")); DEB_D("V4L2_CID_HFLIP while active capture\n");
return -EBUSY; return -EBUSY;
} }
vv->hflip = c->value; vv->hflip = c->value;
break; break;
case V4L2_CID_VFLIP: case V4L2_CID_VFLIP:
if (IS_CAPTURE_ACTIVE(fh) != 0) { if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_VFLIP while active capture.\n")); DEB_D("V4L2_CID_VFLIP while active capture\n");
return -EBUSY; return -EBUSY;
} }
vv->vflip = c->value; vv->vflip = c->value;
...@@ -748,7 +752,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma ...@@ -748,7 +752,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
int maxw, maxh; int maxw, maxh;
int calc_bpl; int calc_bpl;
DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh)); DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh);
fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat); fmt = saa7146_format_by_fourcc(dev, f->fmt.pix.pixelformat);
if (NULL == fmt) if (NULL == fmt)
...@@ -777,7 +781,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma ...@@ -777,7 +781,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
vv->last_field = V4L2_FIELD_INTERLACED; vv->last_field = V4L2_FIELD_INTERLACED;
break; break;
default: default:
DEB_D(("no known field mode '%d'.\n", field)); DEB_D("no known field mode '%d'\n", field);
return -EINVAL; return -EINVAL;
} }
...@@ -796,8 +800,9 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma ...@@ -796,8 +800,9 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
f->fmt.pix.bytesperline = calc_bpl; f->fmt.pix.bytesperline = calc_bpl;
f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height; 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, DEB_D("w:%d, h:%d, bytesperline:%d, sizeimage:%d\n",
f->fmt.pix.height, f->fmt.pix.bytesperline, f->fmt.pix.sizeimage)); f->fmt.pix.width, f->fmt.pix.height,
f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
return 0; return 0;
} }
...@@ -811,22 +816,23 @@ static int vidioc_try_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_f ...@@ -811,22 +816,23 @@ static int vidioc_try_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_f
enum v4l2_field field; enum v4l2_field field;
int maxw, maxh; int maxw, maxh;
DEB_EE(("dev:%p\n", dev)); DEB_EE("dev:%p\n", dev);
if (NULL == vv->ov_fb.base) { if (NULL == vv->ov_fb.base) {
DEB_D(("no fb base set.\n")); DEB_D("no fb base set\n");
return -EINVAL; return -EINVAL;
} }
if (NULL == vv->ov_fmt) { if (NULL == vv->ov_fmt) {
DEB_D(("no fb fmt set.\n")); DEB_D("no fb fmt set\n");
return -EINVAL; return -EINVAL;
} }
if (win->w.width < 48 || win->w.height < 32) { if (win->w.width < 48 || win->w.height < 32) {
DEB_D(("min width/height. (%d,%d)\n", win->w.width, win->w.height)); DEB_D("min width/height. (%d,%d)\n",
win->w.width, win->w.height);
return -EINVAL; return -EINVAL;
} }
if (win->clipcount > 16) { if (win->clipcount > 16) {
DEB_D(("clipcount too big.\n")); DEB_D("clipcount too big\n");
return -EINVAL; return -EINVAL;
} }
...@@ -848,7 +854,7 @@ static int vidioc_try_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_f ...@@ -848,7 +854,7 @@ static int vidioc_try_fmt_vid_overlay(struct file *file, void *fh, struct v4l2_f
case V4L2_FIELD_INTERLACED: case V4L2_FIELD_INTERLACED:
break; break;
default: default:
DEB_D(("no known field mode '%d'.\n", field)); DEB_D("no known field mode '%d'\n", field);
return -EINVAL; return -EINVAL;
} }
...@@ -868,16 +874,17 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_forma ...@@ -868,16 +874,17 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *__fh, struct v4l2_forma
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
int err; int err;
DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh)); DEB_EE("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n", dev, fh);
if (IS_CAPTURE_ACTIVE(fh) != 0) { if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_EE(("streaming capture is active\n")); DEB_EE("streaming capture is active\n");
return -EBUSY; return -EBUSY;
} }
err = vidioc_try_fmt_vid_cap(file, fh, f); err = vidioc_try_fmt_vid_cap(file, fh, f);
if (0 != err) if (0 != err)
return err; return err;
fh->video_fmt = f->fmt.pix; fh->video_fmt = f->fmt.pix;
DEB_EE(("set to pixelformat '%4.4s'\n", (char *)&fh->video_fmt.pixelformat)); DEB_EE("set to pixelformat '%4.4s'\n",
(char *)&fh->video_fmt.pixelformat);
return 0; return 0;
} }
...@@ -888,7 +895,7 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *__fh, struct v4l2_f ...@@ -888,7 +895,7 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *__fh, struct v4l2_f
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
int err; int err;
DEB_EE(("V4L2_BUF_TYPE_VIDEO_OVERLAY: dev:%p, fh:%p\n", dev, fh)); DEB_EE("V4L2_BUF_TYPE_VIDEO_OVERLAY: dev:%p, fh:%p\n", dev, fh);
err = vidioc_try_fmt_vid_overlay(file, fh, f); err = vidioc_try_fmt_vid_overlay(file, fh, f);
if (0 != err) if (0 != err)
return err; return err;
...@@ -931,7 +938,7 @@ static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm) ...@@ -931,7 +938,7 @@ static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)
if (e->index < 0 ) if (e->index < 0 )
return -EINVAL; return -EINVAL;
if( e->index < dev->ext_vv_data->num_stds ) { if( e->index < dev->ext_vv_data->num_stds ) {
DEB_EE(("VIDIOC_ENUMSTD: index:%d\n",e->index)); DEB_EE("VIDIOC_ENUMSTD: index:%d\n", e->index);
v4l2_video_std_construct(e, dev->ext_vv_data->stds[e->index].id, dev->ext_vv_data->stds[e->index].name); v4l2_video_std_construct(e, dev->ext_vv_data->stds[e->index].id, dev->ext_vv_data->stds[e->index].name);
return 0; return 0;
} }
...@@ -946,10 +953,10 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id) ...@@ -946,10 +953,10 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
int found = 0; int found = 0;
int err, i; int err, i;
DEB_EE(("VIDIOC_S_STD\n")); DEB_EE("VIDIOC_S_STD\n");
if ((vv->video_status & STATUS_CAPTURE) == STATUS_CAPTURE) { if ((vv->video_status & STATUS_CAPTURE) == STATUS_CAPTURE) {
DEB_D(("cannot change video standard while streaming capture is active\n")); DEB_D("cannot change video standard while streaming capture is active\n");
return -EBUSY; return -EBUSY;
} }
...@@ -957,7 +964,7 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id) ...@@ -957,7 +964,7 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
vv->ov_suspend = vv->video_fh; vv->ov_suspend = vv->video_fh;
err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */ err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */
if (0 != err) { if (0 != err) {
DEB_D(("suspending video failed. aborting\n")); DEB_D("suspending video failed. aborting\n");
return err; return err;
} }
} }
...@@ -978,11 +985,11 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id) ...@@ -978,11 +985,11 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *id)
} }
if (!found) { if (!found) {
DEB_EE(("VIDIOC_S_STD: standard not found.\n")); DEB_EE("VIDIOC_S_STD: standard not found\n");
return -EINVAL; return -EINVAL;
} }
DEB_EE(("VIDIOC_S_STD: set to standard to '%s'\n", vv->standard->name)); DEB_EE("VIDIOC_S_STD: set to standard to '%s'\n", vv->standard->name);
return 0; return 0;
} }
...@@ -990,7 +997,7 @@ static int vidioc_overlay(struct file *file, void *fh, unsigned int on) ...@@ -990,7 +997,7 @@ static int vidioc_overlay(struct file *file, void *fh, unsigned int on)
{ {
int err; int err;
DEB_D(("VIDIOC_OVERLAY on:%d\n", on)); DEB_D("VIDIOC_OVERLAY on:%d\n", on);
if (on) if (on)
err = saa7146_start_preview(fh); err = saa7146_start_preview(fh);
else else
...@@ -1047,7 +1054,7 @@ static int vidioc_streamon(struct file *file, void *__fh, enum v4l2_buf_type typ ...@@ -1047,7 +1054,7 @@ static int vidioc_streamon(struct file *file, void *__fh, enum v4l2_buf_type typ
struct saa7146_fh *fh = __fh; struct saa7146_fh *fh = __fh;
int err; int err;
DEB_D(("VIDIOC_STREAMON, type:%d\n", type)); DEB_D("VIDIOC_STREAMON, type:%d\n", type);
err = video_begin(fh); err = video_begin(fh);
if (err) if (err)
...@@ -1066,18 +1073,18 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty ...@@ -1066,18 +1073,18 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
int err; int err;
DEB_D(("VIDIOC_STREAMOFF, type:%d\n", type)); DEB_D("VIDIOC_STREAMOFF, type:%d\n", type);
/* ugly: we need to copy some checks from video_end(), /* ugly: we need to copy some checks from video_end(),
because videobuf_streamoff() relies on the capture running. because videobuf_streamoff() relies on the capture running.
check and fix this */ check and fix this */
if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) { if ((vv->video_status & STATUS_CAPTURE) != STATUS_CAPTURE) {
DEB_S(("not capturing.\n")); DEB_S("not capturing\n");
return 0; return 0;
} }
if (vv->video_fh != fh) { if (vv->video_fh != fh) {
DEB_S(("capturing, but in another open.\n")); DEB_S("capturing, but in another open\n");
return -EBUSY; return -EBUSY;
} }
...@@ -1087,7 +1094,7 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty ...@@ -1087,7 +1094,7 @@ static int vidioc_streamoff(struct file *file, void *__fh, enum v4l2_buf_type ty
else if (type == V4L2_BUF_TYPE_VBI_CAPTURE) else if (type == V4L2_BUF_TYPE_VBI_CAPTURE)
err = videobuf_streamoff(&fh->vbi_q); err = videobuf_streamoff(&fh->vbi_q);
if (0 != err) { if (0 != err) {
DEB_D(("warning: videobuf_streamoff() failed.\n")); DEB_D("warning: videobuf_streamoff() failed\n");
video_end(fh, file); video_end(fh, file);
} else { } else {
err = video_end(fh, file); err = video_end(fh, file);
...@@ -1174,25 +1181,27 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -1174,25 +1181,27 @@ static int buffer_prepare(struct videobuf_queue *q,
struct saa7146_buf *buf = (struct saa7146_buf *)vb; struct saa7146_buf *buf = (struct saa7146_buf *)vb;
int size,err = 0; int size,err = 0;
DEB_CAP(("vbuf:%p\n",vb)); DEB_CAP("vbuf:%p\n", vb);
/* sanity checks */ /* sanity checks */
if (fh->video_fmt.width < 48 || if (fh->video_fmt.width < 48 ||
fh->video_fmt.height < 32 || fh->video_fmt.height < 32 ||
fh->video_fmt.width > vv->standard->h_max_out || fh->video_fmt.width > vv->standard->h_max_out ||
fh->video_fmt.height > vv->standard->v_max_out) { fh->video_fmt.height > vv->standard->v_max_out) {
DEB_D(("w (%d) / h (%d) out of bounds.\n",fh->video_fmt.width,fh->video_fmt.height)); DEB_D("w (%d) / h (%d) out of bounds\n",
fh->video_fmt.width, fh->video_fmt.height);
return -EINVAL; return -EINVAL;
} }
size = fh->video_fmt.sizeimage; size = fh->video_fmt.sizeimage;
if (0 != buf->vb.baddr && buf->vb.bsize < size) { if (0 != buf->vb.baddr && buf->vb.bsize < size) {
DEB_D(("size mismatch.\n")); DEB_D("size mismatch\n");
return -EINVAL; return -EINVAL;
} }
DEB_CAP(("buffer_prepare [size=%dx%d,bytes=%d,fields=%s]\n", 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])); fh->video_fmt.width, fh->video_fmt.height,
size, v4l2_field_names[fh->video_fmt.field]);
if (buf->vb.width != fh->video_fmt.width || if (buf->vb.width != fh->video_fmt.width ||
buf->vb.bytesperline != fh->video_fmt.bytesperline || buf->vb.bytesperline != fh->video_fmt.bytesperline ||
buf->vb.height != fh->video_fmt.height || buf->vb.height != fh->video_fmt.height ||
...@@ -1238,7 +1247,7 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -1238,7 +1247,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0; return 0;
oops: oops:
DEB_D(("error out.\n")); DEB_D("error out\n");
saa7146_dma_free(dev,q,buf); saa7146_dma_free(dev,q,buf);
return err; return err;
...@@ -1259,7 +1268,7 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned ...@@ -1259,7 +1268,7 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned
*count = (max_memory*1048576) / *size; *count = (max_memory*1048576) / *size;
} }
DEB_CAP(("%d buffers, %d bytes each.\n",*count,*size)); DEB_CAP("%d buffers, %d bytes each\n", *count, *size);
return 0; return 0;
} }
...@@ -1272,7 +1281,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -1272,7 +1281,7 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
struct saa7146_buf *buf = (struct saa7146_buf *)vb; struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_CAP(("vbuf:%p\n",vb)); DEB_CAP("vbuf:%p\n", vb);
saa7146_buffer_queue(fh->dev,&vv->video_q,buf); saa7146_buffer_queue(fh->dev,&vv->video_q,buf);
} }
...@@ -1283,7 +1292,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -1283,7 +1292,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_dev *dev = fh->dev; struct saa7146_dev *dev = fh->dev;
struct saa7146_buf *buf = (struct saa7146_buf *)vb; struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_CAP(("vbuf:%p\n",vb)); DEB_CAP("vbuf:%p\n", vb);
saa7146_dma_free(dev,q,buf); saa7146_dma_free(dev,q,buf);
...@@ -1368,7 +1377,7 @@ static void video_irq_done(struct saa7146_dev *dev, unsigned long st) ...@@ -1368,7 +1377,7 @@ static void video_irq_done(struct saa7146_dev *dev, unsigned long st)
struct saa7146_dmaqueue *q = &vv->video_q; struct saa7146_dmaqueue *q = &vv->video_q;
spin_lock(&dev->slock); spin_lock(&dev->slock);
DEB_CAP(("called.\n")); DEB_CAP("called\n");
/* only finish the buffer if we have one... */ /* only finish the buffer if we have one... */
if( NULL != q->curr ) { if( NULL != q->curr ) {
...@@ -1386,15 +1395,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo ...@@ -1386,15 +1395,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
struct saa7146_vv *vv = dev->vv_data; struct saa7146_vv *vv = dev->vv_data;
ssize_t ret = 0; ssize_t ret = 0;
DEB_EE(("called.\n")); DEB_EE("called\n");
if ((vv->video_status & STATUS_CAPTURE) != 0) { if ((vv->video_status & STATUS_CAPTURE) != 0) {
/* fixme: should we allow read() captures while streaming capture? */ /* fixme: should we allow read() captures while streaming capture? */
if (vv->video_fh == fh) { if (vv->video_fh == fh) {
DEB_S(("already capturing.\n")); DEB_S("already capturing\n");
return -EBUSY; return -EBUSY;
} }
DEB_S(("already capturing in another open.\n")); DEB_S("already capturing in another open\n");
return -EBUSY; return -EBUSY;
} }
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
* the project's page is at http://www.linuxtv.org/ * the project's page is at http://www.linuxtv.org/
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -253,7 +255,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) ...@@ -253,7 +255,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
switch (av7110->current_input) { switch (av7110->current_input) {
case 1: case 1:
dprintk(1, "switching SAA7113 to Analog Tuner Input.\n"); dprintk(1, "switching SAA7113 to Analog Tuner Input\n");
msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
...@@ -263,7 +265,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) ...@@ -263,7 +265,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
if (ves1820_writereg(dev, 0x09, 0x0f, 0x60)) if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
dprintk(1, "setting band in demodulator failed.\n"); dprintk(1, "setting band in demodulator failed\n");
} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9819 pin9(STD) saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9819 pin9(STD)
saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9819 pin30(VIF) saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9819 pin30(VIF)
...@@ -272,17 +274,17 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) ...@@ -272,17 +274,17 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
break; break;
case 2: case 2:
dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n"); dprintk(1, "switching SAA7113 to Video AV CVBS Input\n");
if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1) if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1)
dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
break; break;
case 3: case 3:
dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n"); dprintk(1, "switching SAA7113 to Video AV Y/C Input\n");
if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1) if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1)
dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num); dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
break; break;
default: default:
dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n"); dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input\n");
} }
} else { } else {
adswitch = 0; adswitch = 0;
...@@ -299,7 +301,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh) ...@@ -299,7 +301,7 @@ static int av7110_dvb_c_switch(struct saa7146_fh *fh)
if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
if (ves1820_writereg(dev, 0x09, 0x0f, 0x20)) if (ves1820_writereg(dev, 0x09, 0x0f, 0x20))
dprintk(1, "setting band in demodulator failed.\n"); dprintk(1, "setting band in demodulator failed\n");
} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD) saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF) saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
...@@ -413,7 +415,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency ...@@ -413,7 +415,7 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; struct av7110 *av7110 = (struct av7110 *)dev->ext_priv;
dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x.\n", f->frequency); dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x\n", f->frequency);
if (!av7110->analog_tuner_flags || av7110->current_input != 1) if (!av7110->analog_tuner_flags || av7110->current_input != 1)
return -EINVAL; return -EINVAL;
...@@ -429,7 +431,7 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency ...@@ -429,7 +431,7 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct av7110 *av7110 = (struct av7110 *)dev->ext_priv; struct av7110 *av7110 = (struct av7110 *)dev->ext_priv;
dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x.\n", f->frequency); dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x\n", f->frequency);
if (!av7110->analog_tuner_flags || av7110->current_input != 1) if (!av7110->analog_tuner_flags || av7110->current_input != 1)
return -EINVAL; return -EINVAL;
...@@ -689,12 +691,12 @@ int av7110_init_analog_module(struct av7110 *av7110) ...@@ -689,12 +691,12 @@ int av7110_init_analog_module(struct av7110 *av7110)
if (i2c_writereg(av7110, 0x80, 0x0, 0x80) == 1 && if (i2c_writereg(av7110, 0x80, 0x0, 0x80) == 1 &&
i2c_writereg(av7110, 0x80, 0x0, 0) == 1) { i2c_writereg(av7110, 0x80, 0x0, 0) == 1) {
printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n", pr_info("DVB-C analog module @ card %d detected, initializing MSP3400\n",
av7110->dvb_adapter.num); av7110->dvb_adapter.num);
av7110->adac_type = DVB_ADAC_MSP34x0; av7110->adac_type = DVB_ADAC_MSP34x0;
} else if (i2c_writereg(av7110, 0x84, 0x0, 0x80) == 1 && } else if (i2c_writereg(av7110, 0x84, 0x0, 0x80) == 1 &&
i2c_writereg(av7110, 0x84, 0x0, 0) == 1) { i2c_writereg(av7110, 0x84, 0x0, 0) == 1) {
printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3415\n", pr_info("DVB-C analog module @ card %d detected, initializing MSP3415\n",
av7110->dvb_adapter.num); av7110->dvb_adapter.num);
av7110->adac_type = DVB_ADAC_MSP34x5; av7110->adac_type = DVB_ADAC_MSP34x5;
} else } else
...@@ -715,7 +717,7 @@ int av7110_init_analog_module(struct av7110 *av7110) ...@@ -715,7 +717,7 @@ int av7110_init_analog_module(struct av7110 *av7110)
msp_writereg(av7110, MSP_WR_DSP, 0x000d, 0x1900); // prescale SCART msp_writereg(av7110, MSP_WR_DSP, 0x000d, 0x1900); // prescale SCART
if (i2c_writereg(av7110, 0x48, 0x01, 0x00)!=1) { if (i2c_writereg(av7110, 0x48, 0x01, 0x00)!=1) {
INFO(("saa7113 not accessible.\n")); pr_info("saa7113 not accessible\n");
} else { } else {
u8 *i = saa7113_init_regs; u8 *i = saa7113_init_regs;
...@@ -733,7 +735,7 @@ int av7110_init_analog_module(struct av7110 *av7110) ...@@ -733,7 +735,7 @@ int av7110_init_analog_module(struct av7110 *av7110)
/* setup for DVB by default */ /* setup for DVB by default */
if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) { if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
if (ves1820_writereg(av7110->dev, 0x09, 0x0f, 0x20)) if (ves1820_writereg(av7110->dev, 0x09, 0x0f, 0x20))
dprintk(1, "setting band in demodulator failed.\n"); dprintk(1, "setting band in demodulator failed\n");
} else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) { } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD) saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF) saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
...@@ -797,7 +799,7 @@ int av7110_init_v4l(struct av7110 *av7110) ...@@ -797,7 +799,7 @@ int av7110_init_v4l(struct av7110 *av7110)
ret = saa7146_vv_init(dev, vv_data); ret = saa7146_vv_init(dev, vv_data);
if (ret) { if (ret) {
ERR(("cannot init capture device. skipping.\n")); ERR("cannot init capture device. skipping\n");
return -ENODEV; return -ENODEV;
} }
vv_data->ops.vidioc_enum_input = vidioc_enum_input; vv_data->ops.vidioc_enum_input = vidioc_enum_input;
...@@ -814,12 +816,12 @@ int av7110_init_v4l(struct av7110 *av7110) ...@@ -814,12 +816,12 @@ int av7110_init_v4l(struct av7110 *av7110)
vv_data->ops.vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out; vv_data->ops.vidioc_s_fmt_sliced_vbi_out = vidioc_s_fmt_sliced_vbi_out;
if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) { if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) {
ERR(("cannot register capture device. skipping.\n")); ERR("cannot register capture device. skipping\n");
saa7146_vv_release(dev); saa7146_vv_release(dev);
return -ENODEV; return -ENODEV;
} }
if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI))
ERR(("cannot register vbi v4l2 device. skipping.\n")); ERR("cannot register vbi v4l2 device. skipping\n");
return 0; return 0;
} }
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
* the project's page is at http://www.linuxtv.org/ * the project's page is at http://www.linuxtv.org/
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "budget.h" #include "budget.h"
#include "stv0299.h" #include "stv0299.h"
#include "stb0899_drv.h" #include "stb0899_drv.h"
...@@ -149,7 +151,7 @@ static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int ad ...@@ -149,7 +151,7 @@ static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int ad
result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1); result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
ciintf_slot_shutdown(ca, slot); ciintf_slot_shutdown(ca, slot);
printk(KERN_INFO "budget-av: cam ejected 1\n"); pr_info("cam ejected 1\n");
} }
return result; return result;
} }
...@@ -168,7 +170,7 @@ static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int a ...@@ -168,7 +170,7 @@ static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int a
result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1); result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
ciintf_slot_shutdown(ca, slot); ciintf_slot_shutdown(ca, slot);
printk(KERN_INFO "budget-av: cam ejected 2\n"); pr_info("cam ejected 2\n");
} }
return result; return result;
} }
...@@ -187,7 +189,7 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre ...@@ -187,7 +189,7 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre
result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0); result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
ciintf_slot_shutdown(ca, slot); ciintf_slot_shutdown(ca, slot);
printk(KERN_INFO "budget-av: cam ejected 3\n"); pr_info("cam ejected 3\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
return result; return result;
...@@ -207,7 +209,7 @@ static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addr ...@@ -207,7 +209,7 @@ static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addr
result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0); result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
ciintf_slot_shutdown(ca, slot); ciintf_slot_shutdown(ca, slot);
printk(KERN_INFO "budget-av: cam ejected 5\n"); pr_info("cam ejected 5\n");
} }
return result; return result;
} }
...@@ -289,7 +291,7 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open ...@@ -289,7 +291,7 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
if (saa7146_read(saa, PSR) & MASK_06) { if (saa7146_read(saa, PSR) & MASK_06) {
if (budget_av->slot_status == SLOTSTATUS_NONE) { if (budget_av->slot_status == SLOTSTATUS_NONE) {
budget_av->slot_status = SLOTSTATUS_PRESENT; budget_av->slot_status = SLOTSTATUS_PRESENT;
printk(KERN_INFO "budget-av: cam inserted A\n"); pr_info("cam inserted A\n");
} }
} }
saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO); saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
...@@ -306,11 +308,11 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open ...@@ -306,11 +308,11 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1); result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) { if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
budget_av->slot_status = SLOTSTATUS_PRESENT; budget_av->slot_status = SLOTSTATUS_PRESENT;
printk(KERN_INFO "budget-av: cam inserted B\n"); pr_info("cam inserted B\n");
} else if (result < 0) { } else if (result < 0) {
if (budget_av->slot_status != SLOTSTATUS_NONE) { if (budget_av->slot_status != SLOTSTATUS_NONE) {
ciintf_slot_shutdown(ca, slot); ciintf_slot_shutdown(ca, slot);
printk(KERN_INFO "budget-av: cam ejected 5\n"); pr_info("cam ejected 5\n");
return 0; return 0;
} }
} }
...@@ -365,11 +367,11 @@ static int ciintf_init(struct budget_av *budget_av) ...@@ -365,11 +367,11 @@ static int ciintf_init(struct budget_av *budget_av)
if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter, if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
&budget_av->ca, 0, 1)) != 0) { &budget_av->ca, 0, 1)) != 0) {
printk(KERN_ERR "budget-av: ci initialisation failed.\n"); pr_err("ci initialisation failed\n");
goto error; goto error;
} }
printk(KERN_INFO "budget-av: ci interface initialised.\n"); pr_info("ci interface initialised\n");
return 0; return 0;
error: error:
...@@ -1345,8 +1347,7 @@ static void frontend_init(struct budget_av *budget_av) ...@@ -1345,8 +1347,7 @@ static void frontend_init(struct budget_av *budget_av)
} }
if (fe == NULL) { if (fe == NULL) {
printk(KERN_ERR "budget-av: A frontend driver was not found " pr_err("A frontend driver was not found for device [%04x:%04x] subsystem [%04x:%04x]\n",
"for device [%04x:%04x] subsystem [%04x:%04x]\n",
saa->pci->vendor, saa->pci->vendor,
saa->pci->device, saa->pci->device,
saa->pci->subsystem_vendor, saa->pci->subsystem_vendor,
...@@ -1358,7 +1359,7 @@ static void frontend_init(struct budget_av *budget_av) ...@@ -1358,7 +1359,7 @@ static void frontend_init(struct budget_av *budget_av)
if (dvb_register_frontend(&budget_av->budget.dvb_adapter, if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
budget_av->budget.dvb_frontend)) { budget_av->budget.dvb_frontend)) {
printk(KERN_ERR "budget-av: Frontend registration failed!\n"); pr_err("Frontend registration failed!\n");
dvb_frontend_detach(budget_av->budget.dvb_frontend); dvb_frontend_detach(budget_av->budget.dvb_frontend);
budget_av->budget.dvb_frontend = NULL; budget_av->budget.dvb_frontend = NULL;
} }
...@@ -1416,7 +1417,7 @@ static struct v4l2_input knc1_inputs[KNC1_INPUTS] = { ...@@ -1416,7 +1417,7 @@ static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{ {
dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index); dprintk(1, "VIDIOC_ENUMINPUT %d\n", i->index);
if (i->index >= KNC1_INPUTS) if (i->index >= KNC1_INPUTS)
return -EINVAL; return -EINVAL;
memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input)); memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
...@@ -1430,7 +1431,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) ...@@ -1430,7 +1431,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
*i = budget_av->cur_input; *i = budget_av->cur_input;
dprintk(1, "VIDIOC_G_INPUT %d.\n", *i); dprintk(1, "VIDIOC_G_INPUT %d\n", *i);
return 0; return 0;
} }
...@@ -1439,7 +1440,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) ...@@ -1439,7 +1440,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct budget_av *budget_av = (struct budget_av *)dev->ext_priv; struct budget_av *budget_av = (struct budget_av *)dev->ext_priv;
dprintk(1, "VIDIOC_S_INPUT %d.\n", input); dprintk(1, "VIDIOC_S_INPUT %d\n", input);
return saa7113_setinput(budget_av, input); return saa7113_setinput(budget_av, input);
} }
...@@ -1478,7 +1479,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio ...@@ -1478,7 +1479,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
if (0 != saa7146_vv_init(dev, &vv_data)) { if (0 != saa7146_vv_init(dev, &vv_data)) {
/* fixme: proper cleanup here */ /* fixme: proper cleanup here */
ERR(("cannot init vv subsystem.\n")); ERR("cannot init vv subsystem\n");
return err; return err;
} }
vv_data.ops.vidioc_enum_input = vidioc_enum_input; vv_data.ops.vidioc_enum_input = vidioc_enum_input;
...@@ -1487,7 +1488,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio ...@@ -1487,7 +1488,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) { if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
/* fixme: proper cleanup here */ /* fixme: proper cleanup here */
ERR(("cannot register capture v4l2 device.\n")); ERR("cannot register capture v4l2 device\n");
saa7146_vv_release(dev); saa7146_vv_release(dev);
return err; return err;
} }
...@@ -1504,13 +1505,12 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio ...@@ -1504,13 +1505,12 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
mac = budget_av->budget.dvb_adapter.proposed_mac; mac = budget_av->budget.dvb_adapter.proposed_mac;
if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) { if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n", pr_err("KNC1-%d: Could not read MAC from KNC1 card\n",
budget_av->budget.dvb_adapter.num); budget_av->budget.dvb_adapter.num);
memset(mac, 0, 6); memset(mac, 0, 6);
} else { } else {
printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", pr_info("KNC1-%d: MAC addr = %pM\n",
budget_av->budget.dvb_adapter.num, budget_av->budget.dvb_adapter.num, mac);
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
} }
budget_av->budget.dvb_adapter.priv = budget_av; budget_av->budget.dvb_adapter.priv = budget_av;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define DEBUG_VARIABLE debug #define DEBUG_VARIABLE debug
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
...@@ -175,13 +177,14 @@ static int hexium_init_done(struct saa7146_dev *dev) ...@@ -175,13 +177,14 @@ static int hexium_init_done(struct saa7146_dev *dev)
union i2c_smbus_data data; union i2c_smbus_data data;
int i = 0; int i = 0;
DEB_D(("hexium_init_done called.\n")); DEB_D("hexium_init_done called\n");
/* initialize the helper ics to useful values */ /* initialize the helper ics to useful values */
for (i = 0; i < sizeof(hexium_ks0127b); i++) { for (i = 0; i < sizeof(hexium_ks0127b); i++) {
data.byte = hexium_ks0127b[i]; data.byte = hexium_ks0127b[i];
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) { if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) {
printk("hexium_gemini: hexium_init_done() failed for address 0x%02x\n", i); pr_err("hexium_init_done() failed for address 0x%02x\n",
i);
} }
} }
...@@ -192,7 +195,7 @@ static int hexium_set_input(struct hexium *hexium, int input) ...@@ -192,7 +195,7 @@ static int hexium_set_input(struct hexium *hexium, int input)
{ {
union i2c_smbus_data data; union i2c_smbus_data data;
DEB_D((".\n")); DEB_D("\n");
data.byte = hexium_input_select[input].byte; data.byte = hexium_input_select[input].byte;
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, hexium_input_select[input].adr, I2C_SMBUS_BYTE_DATA, &data)) { if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, hexium_input_select[input].adr, I2C_SMBUS_BYTE_DATA, &data)) {
...@@ -207,12 +210,13 @@ static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec) ...@@ -207,12 +210,13 @@ static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec)
union i2c_smbus_data data; union i2c_smbus_data data;
int i = 0; int i = 0;
DEB_D((".\n")); DEB_D("\n");
while (vdec[i].adr != -1) { while (vdec[i].adr != -1) {
data.byte = vdec[i].byte; data.byte = vdec[i].byte;
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, vdec[i].adr, I2C_SMBUS_BYTE_DATA, &data)) { if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x6c, 0, I2C_SMBUS_WRITE, vdec[i].adr, I2C_SMBUS_BYTE_DATA, &data)) {
printk("hexium_init_done: hexium_set_standard() failed for address 0x%02x\n", i); pr_err("hexium_init_done: hexium_set_standard() failed for address 0x%02x\n",
i);
return -1; return -1;
} }
i++; i++;
...@@ -222,14 +226,14 @@ static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec) ...@@ -222,14 +226,14 @@ static int hexium_set_standard(struct hexium *hexium, struct hexium_data *vdec)
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{ {
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); DEB_EE("VIDIOC_ENUMINPUT %d\n", i->index);
if (i->index >= HEXIUM_INPUTS) if (i->index >= HEXIUM_INPUTS)
return -EINVAL; return -EINVAL;
memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); DEB_D("v4l2_ioctl: VIDIOC_ENUMINPUT %d\n", i->index);
return 0; return 0;
} }
...@@ -240,7 +244,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) ...@@ -240,7 +244,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input)
*input = hexium->cur_input; *input = hexium->cur_input;
DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); DEB_D("VIDIOC_G_INPUT: %d\n", *input);
return 0; return 0;
} }
...@@ -249,7 +253,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) ...@@ -249,7 +253,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
struct hexium *hexium = (struct hexium *) dev->ext_priv; struct hexium *hexium = (struct hexium *) dev->ext_priv;
DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); DEB_EE("VIDIOC_S_INPUT %d\n", input);
if (input >= HEXIUM_INPUTS) if (input >= HEXIUM_INPUTS)
return -EINVAL; return -EINVAL;
...@@ -270,7 +274,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl * ...@@ -270,7 +274,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *
for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) { for (i = HEXIUM_CONTROLS - 1; i >= 0; i--) {
if (hexium_controls[i].id == qc->id) { if (hexium_controls[i].id == qc->id) {
*qc = hexium_controls[i]; *qc = hexium_controls[i];
DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id)); DEB_D("VIDIOC_QUERYCTRL %d\n", qc->id);
return 0; return 0;
} }
} }
...@@ -293,7 +297,7 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc) ...@@ -293,7 +297,7 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
if (vc->id == V4L2_CID_PRIVATE_BASE) { if (vc->id == V4L2_CID_PRIVATE_BASE) {
vc->value = hexium->cur_bw; vc->value = hexium->cur_bw;
DEB_D(("VIDIOC_G_CTRL BW:%d.\n", vc->value)); DEB_D("VIDIOC_G_CTRL BW:%d\n", vc->value);
return 0; return 0;
} }
return -EINVAL; return -EINVAL;
...@@ -316,7 +320,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc) ...@@ -316,7 +320,7 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
if (vc->id == V4L2_CID_PRIVATE_BASE) if (vc->id == V4L2_CID_PRIVATE_BASE)
hexium->cur_bw = vc->value; hexium->cur_bw = vc->value;
DEB_D(("VIDIOC_S_CTRL BW:%d.\n", hexium->cur_bw)); DEB_D("VIDIOC_S_CTRL BW:%d\n", hexium->cur_bw);
if (0 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) { if (0 == hexium->cur_bw && V4L2_STD_PAL == hexium->cur_std) {
hexium_set_standard(hexium, hexium_pal); hexium_set_standard(hexium, hexium_pal);
...@@ -354,11 +358,11 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -354,11 +358,11 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
struct hexium *hexium; struct hexium *hexium;
int ret; int ret;
DEB_EE((".\n")); DEB_EE("\n");
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
if (NULL == hexium) { if (NULL == hexium) {
printk("hexium_gemini: not enough kernel memory in hexium_attach().\n"); pr_err("not enough kernel memory in hexium_attach()\n");
return -ENOMEM; return -ENOMEM;
} }
dev->ext_priv = hexium; dev->ext_priv = hexium;
...@@ -371,7 +375,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -371,7 +375,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
}; };
saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
if (i2c_add_adapter(&hexium->i2c_adapter) < 0) { if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S("cannot register i2c-device. skipping.\n");
kfree(hexium); kfree(hexium);
return -EFAULT; return -EFAULT;
} }
...@@ -402,11 +406,11 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -402,11 +406,11 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
vv_data.ops.vidioc_s_input = vidioc_s_input; vv_data.ops.vidioc_s_input = vidioc_s_input;
ret = saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER); ret = saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER);
if (ret < 0) { if (ret < 0) {
printk("hexium_gemini: cannot register capture v4l2 device. skipping.\n"); pr_err("cannot register capture v4l2 device. skipping.\n");
return ret; return ret;
} }
printk("hexium_gemini: found 'hexium gemini' frame grabber-%d.\n", hexium_num); pr_info("found 'hexium gemini' frame grabber-%d\n", hexium_num);
hexium_num++; hexium_num++;
return 0; return 0;
...@@ -416,7 +420,7 @@ static int hexium_detach(struct saa7146_dev *dev) ...@@ -416,7 +420,7 @@ static int hexium_detach(struct saa7146_dev *dev)
{ {
struct hexium *hexium = (struct hexium *) dev->ext_priv; struct hexium *hexium = (struct hexium *) dev->ext_priv;
DEB_EE(("dev:%p\n", dev)); DEB_EE("dev:%p\n", dev);
saa7146_unregister_device(&hexium->video_dev, dev); saa7146_unregister_device(&hexium->video_dev, dev);
saa7146_vv_release(dev); saa7146_vv_release(dev);
...@@ -508,7 +512,7 @@ static struct saa7146_extension hexium_extension = { ...@@ -508,7 +512,7 @@ static struct saa7146_extension hexium_extension = {
static int __init hexium_init_module(void) static int __init hexium_init_module(void)
{ {
if (0 != saa7146_register_extension(&hexium_extension)) { if (0 != saa7146_register_extension(&hexium_extension)) {
DEB_S(("failed to register extension.\n")); DEB_S("failed to register extension\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define DEBUG_VARIABLE debug #define DEBUG_VARIABLE debug
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
...@@ -209,7 +211,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -209,7 +211,7 @@ static int hexium_probe(struct saa7146_dev *dev)
union i2c_smbus_data data; union i2c_smbus_data data;
int err = 0; int err = 0;
DEB_EE((".\n")); DEB_EE("\n");
/* there are no hexium orion cards with revision 0 saa7146s */ /* there are no hexium orion cards with revision 0 saa7146s */
if (0 == dev->revision) { if (0 == dev->revision) {
...@@ -218,7 +220,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -218,7 +220,7 @@ static int hexium_probe(struct saa7146_dev *dev)
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
if (NULL == hexium) { if (NULL == hexium) {
printk("hexium_orion: hexium_probe: not enough kernel memory.\n"); pr_err("hexium_probe: not enough kernel memory\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -234,7 +236,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -234,7 +236,7 @@ static int hexium_probe(struct saa7146_dev *dev)
}; };
saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
if (i2c_add_adapter(&hexium->i2c_adapter) < 0) { if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S("cannot register i2c-device. skipping.\n");
kfree(hexium); kfree(hexium);
return -EFAULT; return -EFAULT;
} }
...@@ -248,7 +250,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -248,7 +250,7 @@ static int hexium_probe(struct saa7146_dev *dev)
/* detect newer Hexium Orion cards by subsystem ids */ /* detect newer Hexium Orion cards by subsystem ids */
if (0x17c8 == dev->pci->subsystem_vendor && 0x0101 == dev->pci->subsystem_device) { if (0x17c8 == dev->pci->subsystem_vendor && 0x0101 == dev->pci->subsystem_device) {
printk("hexium_orion: device is a Hexium Orion w/ 1 SVHS + 3 BNC inputs.\n"); pr_info("device is a Hexium Orion w/ 1 SVHS + 3 BNC inputs\n");
/* we store the pointer in our private data field */ /* we store the pointer in our private data field */
dev->ext_priv = hexium; dev->ext_priv = hexium;
hexium->type = HEXIUM_ORION_1SVHS_3BNC; hexium->type = HEXIUM_ORION_1SVHS_3BNC;
...@@ -256,7 +258,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -256,7 +258,7 @@ static int hexium_probe(struct saa7146_dev *dev)
} }
if (0x17c8 == dev->pci->subsystem_vendor && 0x2101 == dev->pci->subsystem_device) { if (0x17c8 == dev->pci->subsystem_vendor && 0x2101 == dev->pci->subsystem_device) {
printk("hexium_orion: device is a Hexium Orion w/ 4 BNC inputs.\n"); pr_info("device is a Hexium Orion w/ 4 BNC inputs\n");
/* we store the pointer in our private data field */ /* we store the pointer in our private data field */
dev->ext_priv = hexium; dev->ext_priv = hexium;
hexium->type = HEXIUM_ORION_4BNC; hexium->type = HEXIUM_ORION_4BNC;
...@@ -266,7 +268,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -266,7 +268,7 @@ static int hexium_probe(struct saa7146_dev *dev)
/* check if this is an old hexium Orion card by looking at /* check if this is an old hexium Orion card by looking at
a saa7110 at address 0x4e */ a saa7110 at address 0x4e */
if (0 == (err = i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_READ, 0x00, I2C_SMBUS_BYTE_DATA, &data))) { if (0 == (err = i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_READ, 0x00, I2C_SMBUS_BYTE_DATA, &data))) {
printk("hexium_orion: device is a Hexium HV-PCI6/Orion (old).\n"); pr_info("device is a Hexium HV-PCI6/Orion (old)\n");
/* we store the pointer in our private data field */ /* we store the pointer in our private data field */
dev->ext_priv = hexium; dev->ext_priv = hexium;
hexium->type = HEXIUM_HV_PCI6_ORION; hexium->type = HEXIUM_HV_PCI6_ORION;
...@@ -288,13 +290,13 @@ static int hexium_init_done(struct saa7146_dev *dev) ...@@ -288,13 +290,13 @@ static int hexium_init_done(struct saa7146_dev *dev)
union i2c_smbus_data data; union i2c_smbus_data data;
int i = 0; int i = 0;
DEB_D(("hexium_init_done called.\n")); DEB_D("hexium_init_done called\n");
/* initialize the helper ics to useful values */ /* initialize the helper ics to useful values */
for (i = 0; i < sizeof(hexium_saa7110); i++) { for (i = 0; i < sizeof(hexium_saa7110); i++) {
data.byte = hexium_saa7110[i]; data.byte = hexium_saa7110[i];
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) { if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, i, I2C_SMBUS_BYTE_DATA, &data)) {
printk("hexium_orion: failed for address 0x%02x\n", i); pr_err("failed for address 0x%02x\n", i);
} }
} }
...@@ -306,7 +308,7 @@ static int hexium_set_input(struct hexium *hexium, int input) ...@@ -306,7 +308,7 @@ static int hexium_set_input(struct hexium *hexium, int input)
union i2c_smbus_data data; union i2c_smbus_data data;
int i = 0; int i = 0;
DEB_D((".\n")); DEB_D("\n");
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
int adr = hexium_input_select[input].data[i].adr; int adr = hexium_input_select[input].data[i].adr;
...@@ -314,7 +316,7 @@ static int hexium_set_input(struct hexium *hexium, int input) ...@@ -314,7 +316,7 @@ static int hexium_set_input(struct hexium *hexium, int input)
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, adr, I2C_SMBUS_BYTE_DATA, &data)) { if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, adr, I2C_SMBUS_BYTE_DATA, &data)) {
return -1; return -1;
} }
printk("%d: 0x%02x => 0x%02x\n",input, adr,data.byte); pr_debug("%d: 0x%02x => 0x%02x\n", input, adr, data.byte);
} }
return 0; return 0;
...@@ -322,14 +324,14 @@ static int hexium_set_input(struct hexium *hexium, int input) ...@@ -322,14 +324,14 @@ static int hexium_set_input(struct hexium *hexium, int input)
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{ {
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); DEB_EE("VIDIOC_ENUMINPUT %d\n", i->index);
if (i->index >= HEXIUM_INPUTS) if (i->index >= HEXIUM_INPUTS)
return -EINVAL; return -EINVAL;
memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input)); memcpy(i, &hexium_inputs[i->index], sizeof(struct v4l2_input));
DEB_D(("v4l2_ioctl: VIDIOC_ENUMINPUT %d.\n", i->index)); DEB_D("v4l2_ioctl: VIDIOC_ENUMINPUT %d\n", i->index);
return 0; return 0;
} }
...@@ -340,7 +342,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input) ...@@ -340,7 +342,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *input)
*input = hexium->cur_input; *input = hexium->cur_input;
DEB_D(("VIDIOC_G_INPUT: %d\n", *input)); DEB_D("VIDIOC_G_INPUT: %d\n", *input);
return 0; return 0;
} }
...@@ -365,18 +367,18 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -365,18 +367,18 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
{ {
struct hexium *hexium = (struct hexium *) dev->ext_priv; struct hexium *hexium = (struct hexium *) dev->ext_priv;
DEB_EE((".\n")); DEB_EE("\n");
saa7146_vv_init(dev, &vv_data); saa7146_vv_init(dev, &vv_data);
vv_data.ops.vidioc_enum_input = vidioc_enum_input; vv_data.ops.vidioc_enum_input = vidioc_enum_input;
vv_data.ops.vidioc_g_input = vidioc_g_input; vv_data.ops.vidioc_g_input = vidioc_g_input;
vv_data.ops.vidioc_s_input = vidioc_s_input; vv_data.ops.vidioc_s_input = vidioc_s_input;
if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_GRABBER)) { if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_GRABBER)) {
printk("hexium_orion: cannot register capture v4l2 device. skipping.\n"); pr_err("cannot register capture v4l2 device. skipping.\n");
return -1; return -1;
} }
printk("hexium_orion: found 'hexium orion' frame grabber-%d.\n", hexium_num); pr_err("found 'hexium orion' frame grabber-%d\n", hexium_num);
hexium_num++; hexium_num++;
/* the rest */ /* the rest */
...@@ -390,7 +392,7 @@ static int hexium_detach(struct saa7146_dev *dev) ...@@ -390,7 +392,7 @@ static int hexium_detach(struct saa7146_dev *dev)
{ {
struct hexium *hexium = (struct hexium *) dev->ext_priv; struct hexium *hexium = (struct hexium *) dev->ext_priv;
DEB_EE(("dev:%p\n", dev)); DEB_EE("dev:%p\n", dev);
saa7146_unregister_device(&hexium->video_dev, dev); saa7146_unregister_device(&hexium->video_dev, dev);
saa7146_vv_release(dev); saa7146_vv_release(dev);
...@@ -479,7 +481,7 @@ static struct saa7146_extension extension = { ...@@ -479,7 +481,7 @@ static struct saa7146_extension extension = {
static int __init hexium_init_module(void) static int __init hexium_init_module(void)
{ {
if (0 != saa7146_register_extension(&extension)) { if (0 != saa7146_register_extension(&extension)) {
DEB_S(("failed to register extension.\n")); DEB_S("failed to register extension\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define DEBUG_VARIABLE debug #define DEBUG_VARIABLE debug
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
...@@ -171,7 +173,7 @@ static int mxb_probe(struct saa7146_dev *dev) ...@@ -171,7 +173,7 @@ static int mxb_probe(struct saa7146_dev *dev)
mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL); mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL);
if (mxb == NULL) { if (mxb == NULL) {
DEB_D(("not enough kernel memory.\n")); DEB_D("not enough kernel memory\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -179,7 +181,7 @@ static int mxb_probe(struct saa7146_dev *dev) ...@@ -179,7 +181,7 @@ static int mxb_probe(struct saa7146_dev *dev)
saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
if (i2c_add_adapter(&mxb->i2c_adapter) < 0) { if (i2c_add_adapter(&mxb->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S("cannot register i2c-device. skipping.\n");
kfree(mxb); kfree(mxb);
return -EFAULT; return -EFAULT;
} }
...@@ -200,7 +202,7 @@ static int mxb_probe(struct saa7146_dev *dev) ...@@ -200,7 +202,7 @@ static int mxb_probe(struct saa7146_dev *dev)
/* check if all devices are present */ /* check if all devices are present */
if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c || if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
!mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) { !mxb->tda9840 || !mxb->saa7111a || !mxb->tuner) {
printk("mxb: did not find all i2c devices. aborting\n"); pr_err("did not find all i2c devices. aborting\n");
i2c_del_adapter(&mxb->i2c_adapter); i2c_del_adapter(&mxb->i2c_adapter);
kfree(mxb); kfree(mxb);
return -ENODEV; return -ENODEV;
...@@ -346,11 +348,11 @@ static int mxb_init_done(struct saa7146_dev* dev) ...@@ -346,11 +348,11 @@ static int mxb_init_done(struct saa7146_dev* dev)
msg.buf = &mxb_saa7740_init[i].data[0]; msg.buf = &mxb_saa7740_init[i].data[0];
err = i2c_transfer(&mxb->i2c_adapter, &msg, 1); err = i2c_transfer(&mxb->i2c_adapter, &msg, 1);
if (err != 1) { if (err != 1) {
DEB_D(("failed to initialize 'sound arena module'.\n")); DEB_D("failed to initialize 'sound arena module'\n");
goto err; goto err;
} }
} }
INFO(("'sound arena module' detected.\n")); pr_info("'sound arena module' detected\n");
} }
err: err:
/* the rest for saa7146: you should definitely set some basic values /* the rest for saa7146: you should definitely set some basic values
...@@ -390,7 +392,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl * ...@@ -390,7 +392,7 @@ static int vidioc_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *
for (i = MAXCONTROLS - 1; i >= 0; i--) { for (i = MAXCONTROLS - 1; i >= 0; i--) {
if (mxb_controls[i].id == qc->id) { if (mxb_controls[i].id == qc->id) {
*qc = mxb_controls[i]; *qc = mxb_controls[i];
DEB_D(("VIDIOC_QUERYCTRL %d.\n", qc->id)); DEB_D("VIDIOC_QUERYCTRL %d\n", qc->id);
return 0; return 0;
} }
} }
...@@ -413,11 +415,11 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc) ...@@ -413,11 +415,11 @@ static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
if (vc->id == V4L2_CID_AUDIO_MUTE) { if (vc->id == V4L2_CID_AUDIO_MUTE) {
vc->value = mxb->cur_mute; vc->value = mxb->cur_mute;
DEB_D(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n", vc->value)); DEB_D("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d\n", vc->value);
return 0; return 0;
} }
DEB_EE(("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d.\n", vc->value)); DEB_EE("VIDIOC_G_CTRL V4L2_CID_AUDIO_MUTE:%d\n", vc->value);
return 0; return 0;
} }
...@@ -440,14 +442,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc) ...@@ -440,14 +442,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
/* switch the audio-source */ /* switch the audio-source */
tea6420_route_line(mxb, vc->value ? 6 : tea6420_route_line(mxb, vc->value ? 6 :
video_audio_connect[mxb->cur_input]); video_audio_connect[mxb->cur_input]);
DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); DEB_EE("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d\n", vc->value);
} }
return 0; return 0;
} }
static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
{ {
DEB_EE(("VIDIOC_ENUMINPUT %d.\n", i->index)); DEB_EE("VIDIOC_ENUMINPUT %d\n", i->index);
if (i->index >= MXB_INPUTS) if (i->index >= MXB_INPUTS)
return -EINVAL; return -EINVAL;
memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input)); memcpy(i, &mxb_inputs[i->index], sizeof(struct v4l2_input));
...@@ -460,7 +462,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) ...@@ -460,7 +462,7 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
*i = mxb->cur_input; *i = mxb->cur_input;
DEB_EE(("VIDIOC_G_INPUT %d.\n", *i)); DEB_EE("VIDIOC_G_INPUT %d\n", *i);
return 0; return 0;
} }
...@@ -471,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) ...@@ -471,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
int err = 0; int err = 0;
int i = 0; int i = 0;
DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); DEB_EE("VIDIOC_S_INPUT %d\n", input);
if (input >= MXB_INPUTS) if (input >= MXB_INPUTS)
return -EINVAL; return -EINVAL;
...@@ -514,7 +516,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) ...@@ -514,7 +516,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
/* switch video in saa7111a */ /* switch video in saa7111a */
if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0)) if (saa7111a_call(mxb, video, s_routing, i, SAA7111_FMT_CCIR, 0))
printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a.\n"); pr_err("VIDIOC_S_INPUT: could not address saa7111a\n");
/* switch the audio-source only if necessary */ /* switch the audio-source only if necessary */
if (0 == mxb->cur_mute) if (0 == mxb->cur_mute)
...@@ -529,11 +531,12 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t) ...@@ -529,11 +531,12 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
if (t->index) { if (t->index) {
DEB_D(("VIDIOC_G_TUNER: channel %d does not have a tuner attached.\n", t->index)); DEB_D("VIDIOC_G_TUNER: channel %d does not have a tuner attached\n",
t->index);
return -EINVAL; return -EINVAL;
} }
DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index)); DEB_EE("VIDIOC_G_TUNER: %d\n", t->index);
memset(t, 0, sizeof(*t)); memset(t, 0, sizeof(*t));
strlcpy(t->name, "TV Tuner", sizeof(t->name)); strlcpy(t->name, "TV Tuner", sizeof(t->name));
...@@ -550,7 +553,8 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t) ...@@ -550,7 +553,8 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
if (t->index) { if (t->index) {
DEB_D(("VIDIOC_S_TUNER: channel %d does not have a tuner attached.\n", t->index)); DEB_D("VIDIOC_S_TUNER: channel %d does not have a tuner attached\n",
t->index);
return -EINVAL; return -EINVAL;
} }
...@@ -564,14 +568,14 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency ...@@ -564,14 +568,14 @@ static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
if (mxb->cur_input) { if (mxb->cur_input) {
DEB_D(("VIDIOC_G_FREQ: channel %d does not have a tuner!\n", DEB_D("VIDIOC_G_FREQ: channel %d does not have a tuner!\n",
mxb->cur_input)); mxb->cur_input);
return -EINVAL; return -EINVAL;
} }
*f = mxb->cur_freq; *f = mxb->cur_freq;
DEB_EE(("VIDIOC_G_FREQ: freq:0x%08x.\n", mxb->cur_freq.frequency)); DEB_EE("VIDIOC_G_FREQ: freq:0x%08x\n", mxb->cur_freq.frequency);
return 0; return 0;
} }
...@@ -588,12 +592,13 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency ...@@ -588,12 +592,13 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency
return -EINVAL; return -EINVAL;
if (mxb->cur_input) { if (mxb->cur_input) {
DEB_D(("VIDIOC_S_FREQ: channel %d does not have a tuner!\n", mxb->cur_input)); DEB_D("VIDIOC_S_FREQ: channel %d does not have a tuner!\n",
mxb->cur_input);
return -EINVAL; return -EINVAL;
} }
mxb->cur_freq = *f; mxb->cur_freq = *f;
DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency)); DEB_EE("VIDIOC_S_FREQUENCY: freq:0x%08x\n", mxb->cur_freq.frequency);
/* tune in desired frequency */ /* tune in desired frequency */
tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq); tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);
...@@ -612,18 +617,18 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a) ...@@ -612,18 +617,18 @@ static int vidioc_g_audio(struct file *file, void *fh, struct v4l2_audio *a)
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
if (a->index > MXB_INPUTS) { if (a->index > MXB_INPUTS) {
DEB_D(("VIDIOC_G_AUDIO %d out of range.\n", a->index)); DEB_D("VIDIOC_G_AUDIO %d out of range\n", a->index);
return -EINVAL; return -EINVAL;
} }
DEB_EE(("VIDIOC_G_AUDIO %d.\n", a->index)); DEB_EE("VIDIOC_G_AUDIO %d\n", a->index);
memcpy(a, &mxb_audios[video_audio_connect[mxb->cur_input]], sizeof(struct v4l2_audio)); memcpy(a, &mxb_audios[video_audio_connect[mxb->cur_input]], sizeof(struct v4l2_audio));
return 0; return 0;
} }
static int vidioc_s_audio(struct file *file, void *fh, struct v4l2_audio *a) static int vidioc_s_audio(struct file *file, void *fh, struct v4l2_audio *a)
{ {
DEB_D(("VIDIOC_S_AUDIO %d.\n", a->index)); DEB_D("VIDIOC_S_AUDIO %d\n", a->index);
return 0; return 0;
} }
...@@ -655,11 +660,11 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio, ...@@ -655,11 +660,11 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio,
int i = *(int *)arg; int i = *(int *)arg;
if (i < 0 || i >= MXB_AUDIOS) { if (i < 0 || i >= MXB_AUDIOS) {
DEB_D(("illegal argument to MXB_S_AUDIO_CD: i:%d.\n", i)); DEB_D("invalid argument to MXB_S_AUDIO_CD: i:%d\n", i);
return -EINVAL; return -EINVAL;
} }
DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); DEB_EE("MXB_S_AUDIO_CD: i:%d\n", i);
tea6420_route_cd(mxb, i); tea6420_route_cd(mxb, i);
return 0; return 0;
...@@ -669,17 +674,18 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio, ...@@ -669,17 +674,18 @@ static long vidioc_default(struct file *file, void *fh, bool valid_prio,
int i = *(int *)arg; int i = *(int *)arg;
if (i < 0 || i >= MXB_AUDIOS) { if (i < 0 || i >= MXB_AUDIOS) {
DEB_D(("illegal argument to MXB_S_AUDIO_LINE: i:%d.\n", i)); DEB_D("invalid argument to MXB_S_AUDIO_LINE: i:%d\n",
i);
return -EINVAL; return -EINVAL;
} }
DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); DEB_EE("MXB_S_AUDIO_LINE: i:%d\n", i);
tea6420_route_line(mxb, i); tea6420_route_line(mxb, i);
return 0; return 0;
} }
default: default:
/* /*
DEB2(printk("does not handle this ioctl.\n")); DEB2(pr_err("does not handle this ioctl\n"));
*/ */
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
...@@ -693,7 +699,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data ...@@ -693,7 +699,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
{ {
struct mxb *mxb; struct mxb *mxb;
DEB_EE(("dev:%p\n", dev)); DEB_EE("dev:%p\n", dev);
saa7146_vv_init(dev, &vv_data); saa7146_vv_init(dev, &vv_data);
if (mxb_probe(dev)) { if (mxb_probe(dev)) {
...@@ -720,7 +726,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data ...@@ -720,7 +726,7 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
#endif #endif
vv_data.ops.vidioc_default = vidioc_default; vv_data.ops.vidioc_default = vidioc_default;
if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) { if (saa7146_register_device(&mxb->video_dev, dev, "mxb", VFL_TYPE_GRABBER)) {
ERR(("cannot register capture v4l2 device. skipping.\n")); ERR("cannot register capture v4l2 device. skipping.\n");
saa7146_vv_release(dev); saa7146_vv_release(dev);
return -1; return -1;
} }
...@@ -728,11 +734,11 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data ...@@ -728,11 +734,11 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
/* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/ /* initialization stuff (vbi) (only for revision > 0 and for extensions which want it)*/
if (MXB_BOARD_CAN_DO_VBI(dev)) { if (MXB_BOARD_CAN_DO_VBI(dev)) {
if (saa7146_register_device(&mxb->vbi_dev, dev, "mxb", VFL_TYPE_VBI)) { if (saa7146_register_device(&mxb->vbi_dev, dev, "mxb", VFL_TYPE_VBI)) {
ERR(("cannot register vbi v4l2 device. skipping.\n")); ERR("cannot register vbi v4l2 device. skipping.\n");
} }
} }
printk("mxb: found Multimedia eXtension Board #%d.\n", mxb_num); pr_info("found Multimedia eXtension Board #%d\n", mxb_num);
mxb_num++; mxb_num++;
mxb_init_done(dev); mxb_init_done(dev);
...@@ -743,7 +749,7 @@ static int mxb_detach(struct saa7146_dev *dev) ...@@ -743,7 +749,7 @@ static int mxb_detach(struct saa7146_dev *dev)
{ {
struct mxb *mxb = (struct mxb *)dev->ext_priv; struct mxb *mxb = (struct mxb *)dev->ext_priv;
DEB_EE(("dev:%p\n", dev)); DEB_EE("dev:%p\n", dev);
saa7146_unregister_device(&mxb->video_dev,dev); saa7146_unregister_device(&mxb->video_dev,dev);
if (MXB_BOARD_CAN_DO_VBI(dev)) if (MXB_BOARD_CAN_DO_VBI(dev))
...@@ -765,7 +771,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa ...@@ -765,7 +771,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
if (V4L2_STD_PAL_I == standard->id) { if (V4L2_STD_PAL_I == standard->id) {
v4l2_std_id std = V4L2_STD_PAL_I; v4l2_std_id std = V4L2_STD_PAL_I;
DEB_D(("VIDIOC_S_STD: setting mxb for PAL_I.\n")); DEB_D("VIDIOC_S_STD: setting mxb for PAL_I\n");
/* set the 7146 gpio register -- I don't know what this does exactly */ /* set the 7146 gpio register -- I don't know what this does exactly */
saa7146_write(dev, GPIO_CTRL, 0x00404050); saa7146_write(dev, GPIO_CTRL, 0x00404050);
/* unset the 7111 gpio register -- I don't know what this does exactly */ /* unset the 7111 gpio register -- I don't know what this does exactly */
...@@ -774,7 +780,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa ...@@ -774,7 +780,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
} else { } else {
v4l2_std_id std = V4L2_STD_PAL_BG; v4l2_std_id std = V4L2_STD_PAL_BG;
DEB_D(("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM.\n")); DEB_D("VIDIOC_S_STD: setting mxb for PAL/NTSC/SECAM\n");
/* set the 7146 gpio register -- I don't know what this does exactly */ /* set the 7146 gpio register -- I don't know what this does exactly */
saa7146_write(dev, GPIO_CTRL, 0x00404050); saa7146_write(dev, GPIO_CTRL, 0x00404050);
/* set the 7111 gpio register -- I don't know what this does exactly */ /* set the 7111 gpio register -- I don't know what this does exactly */
...@@ -852,7 +858,7 @@ static struct saa7146_extension extension = { ...@@ -852,7 +858,7 @@ static struct saa7146_extension extension = {
static int __init mxb_init_module(void) static int __init mxb_init_module(void)
{ {
if (saa7146_register_extension(&extension)) { if (saa7146_register_extension(&extension)) {
DEB_S(("failed to register extension.\n")); DEB_S("failed to register extension\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -25,24 +25,32 @@ ...@@ -25,24 +25,32 @@
extern unsigned int saa7146_debug; extern unsigned int saa7146_debug;
//#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),KBUILD_MODNAME,__func__)
#ifndef DEBUG_VARIABLE #ifndef DEBUG_VARIABLE
#define DEBUG_VARIABLE saa7146_debug #define DEBUG_VARIABLE saa7146_debug
#endif #endif
#define DEBUG_PROLOG printk("%s: %s(): ",KBUILD_MODNAME, __func__) #define ERR(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
#define INFO(x) { printk("%s: ",KBUILD_MODNAME); printk x; }
#define _DBG(mask, fmt, ...) \
#define ERR(x) { DEBUG_PROLOG; printk x; } do { \
if (DEBUG_VARIABLE & mask) \
#define DEB_S(x) if (0!=(DEBUG_VARIABLE&0x01)) { DEBUG_PROLOG; printk x; } /* simple debug messages */ pr_debug("%s(): " fmt, __func__, ##__VA_ARGS__); \
#define DEB_D(x) if (0!=(DEBUG_VARIABLE&0x02)) { DEBUG_PROLOG; printk x; } /* more detailed debug messages */ } while (0)
#define DEB_EE(x) if (0!=(DEBUG_VARIABLE&0x04)) { DEBUG_PROLOG; printk x; } /* print enter and exit of functions */
#define DEB_I2C(x) if (0!=(DEBUG_VARIABLE&0x08)) { DEBUG_PROLOG; printk x; } /* i2c debug messages */ /* simple debug messages */
#define DEB_VBI(x) if (0!=(DEBUG_VARIABLE&0x10)) { DEBUG_PROLOG; printk x; } /* vbi debug messages */ #define DEB_S(fmt, ...) _DBG(0x01, fmt, ##__VA_ARGS__)
#define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */ /* more detailed debug messages */
#define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */ #define DEB_D(fmt, ...) _DBG(0x02, fmt, ##__VA_ARGS__)
/* print enter and exit of functions */
#define DEB_EE(fmt, ...) _DBG(0x04, fmt, ##__VA_ARGS__)
/* i2c debug messages */
#define DEB_I2C(fmt, ...) _DBG(0x08, fmt, ##__VA_ARGS__)
/* vbi debug messages */
#define DEB_VBI(fmt, ...) _DBG(0x10, fmt, ##__VA_ARGS__)
/* interrupt debug messages */
#define DEB_INT(fmt, ...) _DBG(0x20, fmt, ##__VA_ARGS__)
/* capture debug messages */
#define DEB_CAP(fmt, ...) _DBG(0x40, fmt, ##__VA_ARGS__)
#define SAA7146_ISR_CLEAR(x,y) \ #define SAA7146_ISR_CLEAR(x,y) \
saa7146_write(x, ISR, (y)); saa7146_write(x, ISR, (y));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment