bttv: Width must be a multiple of 16 when capturing planar formats
[pandora-kernel.git] / drivers / media / video / bt8xx / bttv-driver.c
index 14444de..a9ec08b 100644 (file)
@@ -34,6 +34,8 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
@@ -942,8 +944,8 @@ static
 void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits)
 {
        if ((fh->resources & bits) != bits) {
-               /* trying to free ressources not allocated by us ... */
-               printk("bttv: BUG! (btres)\n");
+               /* trying to free resources not allocated by us ... */
+               pr_err("BUG! (btres)\n");
        }
        fh->resources  &= ~bits;
        btv->resources &= ~bits;
@@ -1000,7 +1002,7 @@ static void set_pll(struct bttv *btv)
                return;
 
        if (btv->pll.pll_ofreq == btv->pll.pll_current) {
-               dprintk("bttv%d: PLL: no change required\n",btv->c.nr);
+               dprintk("%d: PLL: no change required\n", btv->c.nr);
                return;
        }
 
@@ -1008,21 +1010,23 @@ static void set_pll(struct bttv *btv)
                /* no PLL needed */
                if (btv->pll.pll_current == 0)
                        return;
-               bttv_printk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n",
-                       btv->c.nr,btv->pll.pll_ifreq);
+               if (bttv_verbose)
+                       pr_info("%d: PLL can sleep, using XTAL (%d)\n",
+                               btv->c.nr, btv->pll.pll_ifreq);
                btwrite(0x00,BT848_TGCTRL);
                btwrite(0x00,BT848_PLL_XCI);
                btv->pll.pll_current = 0;
                return;
        }
 
-       bttv_printk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr,
-               btv->pll.pll_ifreq, btv->pll.pll_ofreq);
+       if (bttv_verbose)
+               pr_info("%d: Setting PLL: %d => %d (needs up to 100ms)\n",
+                       btv->c.nr,
+                       btv->pll.pll_ifreq, btv->pll.pll_ofreq);
        set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
 
        for (i=0; i<10; i++) {
                /*  Let other people run while the PLL stabilizes */
-               bttv_printk(".");
                msleep(10);
 
                if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
@@ -1030,12 +1034,14 @@ static void set_pll(struct bttv *btv)
                } else {
                        btwrite(0x08,BT848_TGCTRL);
                        btv->pll.pll_current = btv->pll.pll_ofreq;
-                       bttv_printk(" ok\n");
+                       if (bttv_verbose)
+                               pr_info("PLL set ok\n");
                        return;
                }
        }
        btv->pll.pll_current = -1;
-       bttv_printk("failed\n");
+       if (bttv_verbose)
+               pr_info("Setting PLL failed\n");
        return;
 }
 
@@ -1047,7 +1053,7 @@ static void bt848A_set_timing(struct bttv *btv)
        int fsc       = bttv_tvnorms[btv->tvnorm].Fsc;
 
        if (btv->input == btv->dig) {
-               dprintk("bttv%d: load digital timing table (table_idx=%d)\n",
+               dprintk("%d: load digital timing table (table_idx=%d)\n",
                        btv->c.nr,table_idx);
 
                /* timing change...reset timing generator address */
@@ -1076,7 +1082,7 @@ static void bt848_bright(struct bttv *btv, int bright)
 {
        int value;
 
-       // printk("bttv: set bright: %d\n",bright); // DEBUG
+       // printk("set bright: %d\n", bright); // DEBUG
        btv->bright = bright;
 
        /* We want -128 to 127 we get 0-65535 */
@@ -1150,8 +1156,7 @@ video_mux(struct bttv *btv, unsigned int input)
        }
        mux = bttv_muxsel(btv, input);
        btaor(mux<<5, ~(3<<5), BT848_IFORM);
-       dprintk(KERN_DEBUG "bttv%d: video mux: input=%d mux=%d\n",
-               btv->c.nr,input,mux);
+       dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux);
 
        /* card specific hook */
        if(bttv_tvcards[btv->c.type].muxsel_hook)
@@ -1440,7 +1445,7 @@ static void bttv_reinit_bt848(struct bttv *btv)
        unsigned long flags;
 
        if (bttv_verbose)
-               printk(KERN_INFO "bttv%d: reset, reinitialize\n",btv->c.nr);
+               pr_info("%d: reset, reinitialize\n", btv->c.nr);
        spin_lock_irqsave(&btv->s_lock,flags);
        btv->errors=0;
        bttv_set_dma(btv,0);
@@ -1622,8 +1627,8 @@ void bttv_gpio_tracking(struct bttv *btv, char *comment)
        unsigned int outbits, data;
        outbits = btread(BT848_GPIO_OUT_EN);
        data    = btread(BT848_GPIO_DATA);
-       printk(KERN_DEBUG "bttv%d: gpio: en=%08x, out=%08x in=%08x [%s]\n",
-              btv->c.nr,outbits,data & outbits, data & ~outbits, comment);
+       pr_debug("%d: gpio: en=%08x, out=%08x in=%08x [%s]\n",
+                btv->c.nr, outbits, data & outbits, data & ~outbits, comment);
 }
 
 static void bttv_field_count(struct bttv *btv)
@@ -1668,7 +1673,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
        unsigned long flags;
        int retval = 0;
 
-       dprintk("switch_overlay: enter [new=%p]\n",new);
+       dprintk("switch_overlay: enter [new=%p]\n", new);
        if (new)
                new->vb.state = VIDEOBUF_DONE;
        spin_lock_irqsave(&btv->s_lock,flags);
@@ -1678,7 +1683,8 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
        bttv_set_dma(btv, 0x03);
        spin_unlock_irqrestore(&btv->s_lock,flags);
        if (NULL != old) {
-               dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state);
+               dprintk("switch_overlay: old=%p state is %d\n",
+                       old, old->vb.state);
                bttv_dma_free(&fh->cap,btv, old);
                kfree(old);
        }
@@ -2029,11 +2035,11 @@ static int bttv_log_status(struct file *file, void *f)
        struct bttv_fh *fh  = f;
        struct bttv *btv = fh->btv;
 
-       printk(KERN_INFO "bttv%d: ========  START STATUS CARD #%d  ========\n",
-                       btv->c.nr, btv->c.nr);
+       pr_info("%d: ========  START STATUS CARD #%d  ========\n",
+               btv->c.nr, btv->c.nr);
        bttv_call_all(btv, core, log_status);
-       printk(KERN_INFO "bttv%d: ========  END STATUS CARD   #%d  ========\n",
-                       btv->c.nr, btv->c.nr);
+       pr_info("%d: ========  END STATUS CARD   #%d  ========\n",
+               btv->c.nr, btv->c.nr);
        return 0;
 }
 
@@ -2474,6 +2480,19 @@ static int bttv_g_fmt_vid_overlay(struct file *file, void *priv,
        return 0;
 }
 
+static void bttv_get_width_mask_vid_cap(const struct bttv_format *fmt,
+                                       unsigned int *width_mask,
+                                       unsigned int *width_bias)
+{
+       if (fmt->flags & FORMAT_FLAGS_PLANAR) {
+               *width_mask = ~15; /* width must be a multiple of 16 pixels */
+               *width_bias = 8;   /* nearest */
+       } else {
+               *width_mask = ~3; /* width must be a multiple of 4 pixels */
+               *width_bias = 2;  /* nearest */
+       }
+}
+
 static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
                                                struct v4l2_format *f)
 {
@@ -2482,6 +2501,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
        struct bttv *btv = fh->btv;
        enum v4l2_field field;
        __s32 width, height;
+       unsigned int width_mask, width_bias;
        int rc;
 
        fmt = format_by_fourcc(f->fmt.pix.pixelformat);
@@ -2519,9 +2539,9 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
        width = f->fmt.pix.width;
        height = f->fmt.pix.height;
 
+       bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
        rc = limit_scaled_size_lock(fh, &width, &height, field,
-                              /* width_mask: 4 pixels */ ~3,
-                              /* width_bias: nearest */ 2,
+                              width_mask, width_bias,
                               /* adjust_size */ 1,
                               /* adjust_crop */ 0);
        if (0 != rc)
@@ -2552,6 +2572,7 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
        struct bttv_fh *fh = priv;
        struct bttv *btv = fh->btv;
        __s32 width, height;
+       unsigned int width_mask, width_bias;
        enum v4l2_field field;
 
        retval = bttv_switch_type(fh, f->type);
@@ -2566,9 +2587,10 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
        height = f->fmt.pix.height;
        field = f->fmt.pix.field;
 
+       fmt = format_by_fourcc(f->fmt.pix.pixelformat);
+       bttv_get_width_mask_vid_cap(fmt, &width_mask, &width_bias);
        retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field,
-                              /* width_mask: 4 pixels */ ~3,
-                              /* width_bias: nearest */ 2,
+                              width_mask, width_bias,
                               /* adjust_size */ 1,
                               /* adjust_crop */ 1);
        if (0 != retval)
@@ -2576,8 +2598,6 @@ static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
 
        f->fmt.pix.field = field;
 
-       fmt = format_by_fourcc(f->fmt.pix.pixelformat);
-
        /* update our state informations */
        fh->fmt              = fmt;
        fh->cap.field        = f->fmt.pix.field;
@@ -2598,7 +2618,7 @@ static int bttv_s_fmt_vid_overlay(struct file *file, void *priv,
        struct bttv *btv = fh->btv;
 
        if (no_overlay > 0) {
-               printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
+               pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
                return -EINVAL;
        }
 
@@ -2673,7 +2693,7 @@ static int bttv_enum_fmt_vid_overlay(struct file *file, void  *priv,
        int rc;
 
        if (no_overlay > 0) {
-               printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
+               pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
                return -EINVAL;
        }
 
@@ -2714,7 +2734,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on)
                        return -EINVAL;
                }
                if (unlikely(!fh->ov.setup_ok)) {
-                       dprintk("bttv%d: overlay: !setup_ok\n", btv->c.nr);
+                       dprintk("%d: overlay: !setup_ok\n", btv->c.nr);
                        retval = -EINVAL;
                }
                if (retval)
@@ -3091,8 +3111,8 @@ static ssize_t bttv_read(struct file *file, char __user *data,
 
        if (fh->btv->errors)
                bttv_reinit_bt848(fh->btv);
-       dprintk("bttv%d: read count=%d type=%s\n",
-               fh->btv->c.nr,(int)count,v4l2_type_names[fh->type]);
+       dprintk("%d: read count=%d type=%s\n",
+               fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]);
 
        switch (fh->type) {
        case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -3174,7 +3194,7 @@ static int bttv_open(struct file *file)
        struct bttv_fh *fh;
        enum v4l2_buf_type type = 0;
 
-       dprintk(KERN_DEBUG "bttv: open dev=%s\n", video_device_node_name(vdev));
+       dprintk("open dev=%s\n", video_device_node_name(vdev));
 
        if (vdev->vfl_type == VFL_TYPE_GRABBER) {
                type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -3185,8 +3205,8 @@ static int bttv_open(struct file *file)
                return -ENODEV;
        }
 
-       dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
-               btv->c.nr,v4l2_type_names[type]);
+       dprintk("%d: open called (type=%s)\n",
+               btv->c.nr, v4l2_type_names[type]);
 
        /* allocate per filehandle data */
        fh = kmalloc(sizeof(*fh), GFP_KERNEL);
@@ -3288,7 +3308,7 @@ bttv_mmap(struct file *file, struct vm_area_struct *vma)
 {
        struct bttv_fh *fh = file->private_data;
 
-       dprintk("bttv%d: mmap type=%s 0x%lx+%ld\n",
+       dprintk("%d: mmap type=%s 0x%lx+%ld\n",
                fh->btv->c.nr, v4l2_type_names[fh->type],
                vma->vm_start, vma->vm_end - vma->vm_start);
        return videobuf_mmap_mapper(bttv_queue(fh),vma);
@@ -3370,9 +3390,9 @@ static int radio_open(struct file *file)
        struct bttv *btv = video_drvdata(file);
        struct bttv_fh *fh;
 
-       dprintk("bttv: open dev=%s\n", video_device_node_name(vdev));
+       dprintk("open dev=%s\n", video_device_node_name(vdev));
 
-       dprintk("bttv%d: open called (radio)\n",btv->c.nr);
+       dprintk("%d: open called (radio)\n", btv->c.nr);
 
        /* allocate per filehandle data */
        fh = kmalloc(sizeof(*fh), GFP_KERNEL);
@@ -3616,12 +3636,12 @@ static int bttv_risc_decode(u32 risc)
        };
        int i;
 
-       printk("0x%08x [ %s", risc,
+       pr_cont("0x%08x [ %s", risc,
               instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
        for (i = ARRAY_SIZE(bits)-1; i >= 0; i--)
                if (risc & (1 << (i + 12)))
-                       printk(" %s",bits[i]);
-       printk(" count=%d ]\n", risc & 0xfff);
+                       pr_cont(" %s", bits[i]);
+       pr_cont(" count=%d ]\n", risc & 0xfff);
        return incr[risc >> 28] ? incr[risc >> 28] : 1;
 }
 
@@ -3630,16 +3650,18 @@ static void bttv_risc_disasm(struct bttv *btv,
 {
        unsigned int i,j,n;
 
-       printk("%s: risc disasm: %p [dma=0x%08lx]\n",
-              btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma);
+       pr_info("%s: risc disasm: %p [dma=0x%08lx]\n",
+               btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma);
        for (i = 0; i < (risc->size >> 2); i += n) {
-               printk("%s:   0x%lx: ", btv->c.v4l2_dev.name,
-                      (unsigned long)(risc->dma + (i<<2)));
+               pr_info("%s:   0x%lx: ",
+                       btv->c.v4l2_dev.name,
+                       (unsigned long)(risc->dma + (i<<2)));
                n = bttv_risc_decode(le32_to_cpu(risc->cpu[i]));
                for (j = 1; j < n; j++)
-                       printk("%s:   0x%lx: 0x%08x [ arg #%d ]\n",
-                              btv->c.v4l2_dev.name, (unsigned long)(risc->dma + ((i+j)<<2)),
-                              risc->cpu[i+j], j);
+                       pr_info("%s:   0x%lx: 0x%08x [ arg #%d ]\n",
+                               btv->c.v4l2_dev.name,
+                               (unsigned long)(risc->dma + ((i+j)<<2)),
+                               risc->cpu[i+j], j);
                if (0 == risc->cpu[i])
                        break;
        }
@@ -3647,17 +3669,18 @@ static void bttv_risc_disasm(struct bttv *btv,
 
 static void bttv_print_riscaddr(struct bttv *btv)
 {
-       printk("  main: %08Lx\n",
-              (unsigned long long)btv->main.dma);
-       printk("  vbi : o=%08Lx e=%08Lx\n",
-              btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
-              btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0);
-       printk("  cap : o=%08Lx e=%08Lx\n",
-              btv->curr.top    ? (unsigned long long)btv->curr.top->top.dma : 0,
-              btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
-       printk("  scr : o=%08Lx e=%08Lx\n",
-              btv->screen ? (unsigned long long)btv->screen->top.dma : 0,
-              btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0);
+       pr_info("  main: %08llx\n", (unsigned long long)btv->main.dma);
+       pr_info("  vbi : o=%08llx e=%08llx\n",
+               btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0,
+               btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0);
+       pr_info("  cap : o=%08llx e=%08llx\n",
+               btv->curr.top
+               ? (unsigned long long)btv->curr.top->top.dma : 0,
+               btv->curr.bottom
+               ? (unsigned long long)btv->curr.bottom->bottom.dma : 0);
+       pr_info("  scr : o=%08llx e=%08llx\n",
+               btv->screen ? (unsigned long long)btv->screen->top.dma : 0,
+               btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0);
        bttv_risc_disasm(btv, &btv->main);
 }
 
@@ -3690,34 +3713,34 @@ static void bttv_print_irqbits(u32 print, u32 mark)
 {
        unsigned int i;
 
-       printk("bits:");
+       pr_cont("bits:");
        for (i = 0; i < ARRAY_SIZE(irq_name); i++) {
                if (print & (1 << i))
-                       printk(" %s",irq_name[i]);
+                       pr_cont(" %s", irq_name[i]);
                if (mark & (1 << i))
-                       printk("*");
+                       pr_cont("*");
        }
 }
 
 static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc)
 {
-       printk("bttv%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
-              btv->c.nr,
-              (unsigned long)btv->main.dma,
-              (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]),
-              (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]),
-              (unsigned long)rc);
+       pr_warn("%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n",
+               btv->c.nr,
+               (unsigned long)btv->main.dma,
+               (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]),
+               (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]),
+               (unsigned long)rc);
 
        if (0 == (btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC)) {
-               printk("bttv%d: Oh, there (temporarely?) is no input signal. "
-                      "Ok, then this is harmless, don't worry ;)\n",
-                      btv->c.nr);
+               pr_notice("%d: Oh, there (temporarily?) is no input signal. "
+                         "Ok, then this is harmless, don't worry ;)\n",
+                         btv->c.nr);
                return;
        }
-       printk("bttv%d: Uhm. Looks like we have unusual high IRQ latencies.\n",
-              btv->c.nr);
-       printk("bttv%d: Lets try to catch the culpit red-handed ...\n",
-              btv->c.nr);
+       pr_notice("%d: Uhm. Looks like we have unusual high IRQ latencies\n",
+                 btv->c.nr);
+       pr_notice("%d: Lets try to catch the culpit red-handed ...\n",
+                 btv->c.nr);
        dump_stack();
 }
 
@@ -3798,9 +3821,9 @@ bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set)
                }
        }
 
-       dprintk("bttv%d: next set: top=%p bottom=%p [screen=%p,irq=%d,%d]\n",
-               btv->c.nr,set->top, set->bottom,
-               btv->screen,set->frame_irq,set->top_irq);
+       dprintk("%d: next set: top=%p bottom=%p [screen=%p,irq=%d,%d]\n",
+               btv->c.nr, set->top, set->bottom,
+               btv->screen, set->frame_irq, set->top_irq);
        return 0;
 }
 
@@ -3815,7 +3838,8 @@ bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup,
        if (wakeup->top == wakeup->bottom) {
                if (NULL != wakeup->top && curr->top != wakeup->top) {
                        if (irq_debug > 1)
-                               printk("bttv%d: wakeup: both=%p\n",btv->c.nr,wakeup->top);
+                               pr_debug("%d: wakeup: both=%p\n",
+                                        btv->c.nr, wakeup->top);
                        wakeup->top->vb.ts = ts;
                        wakeup->top->vb.field_count = btv->field_count;
                        wakeup->top->vb.state = state;
@@ -3824,7 +3848,8 @@ bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup,
        } else {
                if (NULL != wakeup->top && curr->top != wakeup->top) {
                        if (irq_debug > 1)
-                               printk("bttv%d: wakeup: top=%p\n",btv->c.nr,wakeup->top);
+                               pr_debug("%d: wakeup: top=%p\n",
+                                        btv->c.nr, wakeup->top);
                        wakeup->top->vb.ts = ts;
                        wakeup->top->vb.field_count = btv->field_count;
                        wakeup->top->vb.state = state;
@@ -3832,7 +3857,8 @@ bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup,
                }
                if (NULL != wakeup->bottom && curr->bottom != wakeup->bottom) {
                        if (irq_debug > 1)
-                               printk("bttv%d: wakeup: bottom=%p\n",btv->c.nr,wakeup->bottom);
+                               pr_debug("%d: wakeup: bottom=%p\n",
+                                        btv->c.nr, wakeup->bottom);
                        wakeup->bottom->vb.ts = ts;
                        wakeup->bottom->vb.field_count = btv->field_count;
                        wakeup->bottom->vb.state = state;
@@ -3866,11 +3892,11 @@ static void bttv_irq_timeout(unsigned long data)
        unsigned long flags;
 
        if (bttv_verbose) {
-               printk(KERN_INFO "bttv%d: timeout: drop=%d irq=%d/%d, risc=%08x, ",
-                      btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total,
-                      btread(BT848_RISC_COUNT));
+               pr_info("%d: timeout: drop=%d irq=%d/%d, risc=%08x, ",
+                       btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total,
+                       btread(BT848_RISC_COUNT));
                bttv_print_irqbits(btread(BT848_INT_STAT),0);
-               printk("\n");
+               pr_cont("\n");
        }
 
        spin_lock_irqsave(&btv->s_lock,flags);
@@ -4033,21 +4059,23 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
                dstat=btread(BT848_DSTATUS);
 
                if (irq_debug) {
-                       printk(KERN_DEBUG "bttv%d: irq loop=%d fc=%d "
-                              "riscs=%x, riscc=%08x, ",
-                              btv->c.nr, count, btv->field_count,
-                              stat>>28, btread(BT848_RISC_COUNT));
+                       pr_debug("%d: irq loop=%d fc=%d riscs=%x, riscc=%08x, ",
+                                btv->c.nr, count, btv->field_count,
+                                stat>>28, btread(BT848_RISC_COUNT));
                        bttv_print_irqbits(stat,astat);
                        if (stat & BT848_INT_HLOCK)
-                               printk("   HLOC => %s", (dstat & BT848_DSTATUS_HLOC)
-                                      ? "yes" : "no");
+                               pr_cont("   HLOC => %s",
+                                       dstat & BT848_DSTATUS_HLOC
+                                       ? "yes" : "no");
                        if (stat & BT848_INT_VPRES)
-                               printk("   PRES => %s", (dstat & BT848_DSTATUS_PRES)
-                                      ? "yes" : "no");
+                               pr_cont("   PRES => %s",
+                                       dstat & BT848_DSTATUS_PRES
+                                       ? "yes" : "no");
                        if (stat & BT848_INT_FMTCHG)
-                               printk("   NUML => %s", (dstat & BT848_DSTATUS_NUML)
-                                      ? "625" : "525");
-                       printk("\n");
+                               pr_cont("   NUML => %s",
+                                       dstat & BT848_DSTATUS_NUML
+                                       ? "625" : "525");
+                       pr_cont("\n");
                }
 
                if (astat&BT848_INT_VSYNC)
@@ -4075,18 +4103,19 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
                        audio_mute(btv, btv->mute);  /* trigger automute */
 
                if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
-                       printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr,
-                              (astat & BT848_INT_SCERR) ? "SCERR" : "",
-                              (astat & BT848_INT_OCERR) ? "OCERR" : "",
-                              btread(BT848_RISC_COUNT));
+                       pr_info("%d: %s%s @ %08x,",
+                               btv->c.nr,
+                               (astat & BT848_INT_SCERR) ? "SCERR" : "",
+                               (astat & BT848_INT_OCERR) ? "OCERR" : "",
+                               btread(BT848_RISC_COUNT));
                        bttv_print_irqbits(stat,astat);
-                       printk("\n");
+                       pr_cont("\n");
                        if (bttv_debug)
                                bttv_print_riscaddr(btv);
                }
                if (fdsr && astat & BT848_INT_FDSR) {
-                       printk(KERN_INFO "bttv%d: FDSR @ %08x\n",
-                              btv->c.nr,btread(BT848_RISC_COUNT));
+                       pr_info("%d: FDSR @ %08x\n",
+                               btv->c.nr, btread(BT848_RISC_COUNT));
                        if (bttv_debug)
                                bttv_print_riscaddr(btv);
                }
@@ -4097,11 +4126,11 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
                        if (count > 8 || !(astat & BT848_INT_GPINT)) {
                                btwrite(0, BT848_INT_MASK);
 
-                               printk(KERN_ERR
-                                          "bttv%d: IRQ lockup, cleared int mask [", btv->c.nr);
+                               pr_err("%d: IRQ lockup, cleared int mask [",
+                                      btv->c.nr);
                        } else {
-                               printk(KERN_ERR
-                                          "bttv%d: IRQ lockup, clearing GPINT from int mask [", btv->c.nr);
+                               pr_err("%d: IRQ lockup, clearing GPINT from int mask [",
+                                      btv->c.nr);
 
                                btwrite(btread(BT848_INT_MASK) & (-1 ^ BT848_INT_GPINT),
                                                BT848_INT_MASK);
@@ -4109,7 +4138,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
 
                        bttv_print_irqbits(stat,astat);
 
-                       printk("]\n");
+                       pr_cont("]\n");
                }
        }
        btv->irq_total++;
@@ -4171,7 +4200,7 @@ static void bttv_unregister_video(struct bttv *btv)
 static int __devinit bttv_register_video(struct bttv *btv)
 {
        if (no_overlay > 0)
-               printk("bttv: Overlay support disabled.\n");
+               pr_notice("Overlay support disabled\n");
 
        /* video */
        btv->video_dev = vdev_init(btv, &bttv_video_template, "video");
@@ -4181,12 +4210,11 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->video_dev, VFL_TYPE_GRABBER,
                                  video_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device %s\n",
-              btv->c.nr, video_device_node_name(btv->video_dev));
+       pr_info("%d: registered device %s\n",
+               btv->c.nr, video_device_node_name(btv->video_dev));
        if (device_create_file(&btv->video_dev->dev,
                                     &dev_attr_card)<0) {
-               printk(KERN_ERR "bttv%d: device_create_file 'card' "
-                      "failed\n", btv->c.nr);
+               pr_err("%d: device_create_file 'card' failed\n", btv->c.nr);
                goto err;
        }
 
@@ -4198,8 +4226,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->vbi_dev, VFL_TYPE_VBI,
                                  vbi_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device %s\n",
-              btv->c.nr, video_device_node_name(btv->vbi_dev));
+       pr_info("%d: registered device %s\n",
+               btv->c.nr, video_device_node_name(btv->vbi_dev));
 
        if (!btv->has_radio)
                return 0;
@@ -4210,8 +4238,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,
                                  radio_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device %s\n",
-              btv->c.nr, video_device_node_name(btv->radio_dev));
+       pr_info("%d: registered device %s\n",
+               btv->c.nr, video_device_node_name(btv->radio_dev));
 
        /* all done */
        return 0;
@@ -4244,10 +4272,10 @@ static int __devinit bttv_probe(struct pci_dev *dev,
 
        if (bttv_num == BTTV_MAX)
                return -ENOMEM;
-       printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
+       pr_info("Bt8xx card found (%d)\n", bttv_num);
        bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL);
        if (btv == NULL) {
-               printk(KERN_ERR "bttv: out of memory.\n");
+               pr_err("out of memory\n");
                return -ENOMEM;
        }
        btv->c.nr  = bttv_num;
@@ -4277,21 +4305,19 @@ static int __devinit bttv_probe(struct pci_dev *dev,
        btv->c.pci = dev;
        btv->id  = dev->device;
        if (pci_enable_device(dev)) {
-               printk(KERN_WARNING "bttv%d: Can't enable device.\n",
-                      btv->c.nr);
+               pr_warn("%d: Can't enable device\n", btv->c.nr);
                return -EIO;
        }
        if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) {
-               printk(KERN_WARNING "bttv%d: No suitable DMA available.\n",
-                      btv->c.nr);
+               pr_warn("%d: No suitable DMA available\n", btv->c.nr);
                return -EIO;
        }
        if (!request_mem_region(pci_resource_start(dev,0),
                                pci_resource_len(dev,0),
                                btv->c.v4l2_dev.name)) {
-               printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n",
-                      btv->c.nr,
-                      (unsigned long long)pci_resource_start(dev,0));
+               pr_warn("%d: can't request iomem (0x%llx)\n",
+                       btv->c.nr,
+                       (unsigned long long)pci_resource_start(dev, 0));
                return -EBUSY;
        }
        pci_set_master(dev);
@@ -4299,22 +4325,21 @@ static int __devinit bttv_probe(struct pci_dev *dev,
 
        result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev);
        if (result < 0) {
-               printk(KERN_WARNING "bttv%d: v4l2_device_register() failed\n", btv->c.nr);
+               pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr);
                goto fail0;
        }
 
        btv->revision = dev->revision;
        pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-       printk(KERN_INFO "bttv%d: Bt%d (rev %d) at %s, ",
-              bttv_num,btv->id, btv->revision, pci_name(dev));
-       printk("irq: %d, latency: %d, mmio: 0x%llx\n",
-              btv->c.pci->irq, lat,
-              (unsigned long long)pci_resource_start(dev,0));
+       pr_info("%d: Bt%d (rev %d) at %s, irq: %d, latency: %d, mmio: 0x%llx\n",
+               bttv_num, btv->id, btv->revision, pci_name(dev),
+               btv->c.pci->irq, lat,
+               (unsigned long long)pci_resource_start(dev, 0));
        schedule();
 
        btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000);
        if (NULL == btv->bt848_mmio) {
-               printk("bttv%d: ioremap() failed\n", btv->c.nr);
+               pr_err("%d: ioremap() failed\n", btv->c.nr);
                result = -EIO;
                goto fail1;
        }
@@ -4327,8 +4352,8 @@ static int __devinit bttv_probe(struct pci_dev *dev,
        result = request_irq(btv->c.pci->irq, bttv_irq,
            IRQF_SHARED | IRQF_DISABLED, btv->c.v4l2_dev.name, (void *)btv);
        if (result < 0) {
-               printk(KERN_ERR "bttv%d: can't get IRQ %d\n",
-                      bttv_num,btv->c.pci->irq);
+               pr_err("%d: can't get IRQ %d\n",
+                      bttv_num, btv->c.pci->irq);
                goto fail1;
        }
 
@@ -4433,7 +4458,7 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
        struct bttv *btv = to_bttv(v4l2_dev);
 
        if (bttv_verbose)
-               printk("bttv%d: unloading\n",btv->c.nr);
+               pr_info("%d: unloading\n", btv->c.nr);
 
        if (bttv_tvcards[btv->c.type].has_dvb)
                flush_request_modules(btv);
@@ -4481,7 +4506,7 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
        struct bttv_buffer_set idle;
        unsigned long flags;
 
-       dprintk("bttv%d: suspend %d\n", btv->c.nr, state.event);
+       dprintk("%d: suspend %d\n", btv->c.nr, state.event);
 
        /* stop dma + irqs */
        spin_lock_irqsave(&btv->s_lock,flags);
@@ -4517,14 +4542,13 @@ static int bttv_resume(struct pci_dev *pci_dev)
        unsigned long flags;
        int err;
 
-       dprintk("bttv%d: resume\n", btv->c.nr);
+       dprintk("%d: resume\n", btv->c.nr);
 
        /* restore pci state */
        if (btv->state.disabled) {
                err=pci_enable_device(pci_dev);
                if (err) {
-                       printk(KERN_WARNING "bttv%d: Can't enable device.\n",
-                                                               btv->c.nr);
+                       pr_warn("%d: Can't enable device\n", btv->c.nr);
                        return err;
                }
                btv->state.disabled = 0;
@@ -4532,8 +4556,7 @@ static int bttv_resume(struct pci_dev *pci_dev)
        err=pci_set_power_state(pci_dev, PCI_D0);
        if (err) {
                pci_disable_device(pci_dev);
-               printk(KERN_WARNING "bttv%d: Can't enable device.\n",
-                                                       btv->c.nr);
+               pr_warn("%d: Can't enable device\n", btv->c.nr);
                btv->state.disabled = 1;
                return err;
        }
@@ -4585,22 +4608,21 @@ static int __init bttv_init_module(void)
 
        bttv_num = 0;
 
-       printk(KERN_INFO "bttv: driver version %s loaded\n",
-              BTTV_VERSION);
+       pr_info("driver version %s loaded\n", BTTV_VERSION);
        if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
                gbuffers = 2;
        if (gbufsize > BTTV_MAX_FBUF)
                gbufsize = BTTV_MAX_FBUF;
        gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK;
        if (bttv_verbose)
-               printk(KERN_INFO "bttv: using %d buffers with %dk (%d pages) each for capture\n",
-                      gbuffers, gbufsize >> 10, gbufsize >> PAGE_SHIFT);
+               pr_info("using %d buffers with %dk (%d pages) each for capture\n",
+                       gbuffers, gbufsize >> 10, gbufsize >> PAGE_SHIFT);
 
        bttv_check_chipset();
 
        ret = bus_register(&bttv_sub_bus_type);
        if (ret < 0) {
-               printk(KERN_WARNING "bttv: bus_register error: %d\n", ret);
+               pr_warn("bus_register error: %d\n", ret);
                return ret;
        }
        ret = pci_register_driver(&bttv_pci_driver);