2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* device driver for philips saa7134 based TV cards
|
|
|
|
* driver core
|
|
|
|
*
|
|
|
|
* (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2015-04-30 17:44:56 +08:00
|
|
|
#include "saa7134.h"
|
|
|
|
#include "saa7134-reg.h"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/kmod.h>
|
|
|
|
#include <linux/sound.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
2006-01-15 17:52:23 +08:00
|
|
|
#include <linux/mutex.h>
|
2006-04-11 13:54:21 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
2007-09-28 07:34:25 +08:00
|
|
|
#include <linux/pm.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("v4l2 driver module for saa7130/34 based TV cards");
|
|
|
|
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
|
|
|
|
MODULE_LICENSE("GPL");
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 01:45:49 +08:00
|
|
|
MODULE_VERSION(SAA7134_VERSION);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static unsigned int irq_debug;
|
2005-04-17 06:20:36 +08:00
|
|
|
module_param(irq_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static unsigned int core_debug;
|
2005-04-17 06:20:36 +08:00
|
|
|
module_param(core_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
|
|
|
|
|
2008-04-23 01:41:48 +08:00
|
|
|
static unsigned int gpio_tracking;
|
2005-04-17 06:20:36 +08:00
|
|
|
module_param(gpio_tracking, int, 0644);
|
|
|
|
MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
|
|
|
|
|
2009-01-31 19:14:24 +08:00
|
|
|
static unsigned int alsa = 1;
|
2005-11-14 08:08:00 +08:00
|
|
|
module_param(alsa, int, 0644);
|
2009-01-31 19:14:24 +08:00
|
|
|
MODULE_PARM_DESC(alsa,"enable/disable ALSA DMA sound [dmasound]");
|
2005-11-14 08:08:00 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned int latency = UNSET;
|
|
|
|
module_param(latency, int, 0444);
|
|
|
|
MODULE_PARM_DESC(latency,"pci latency timer");
|
|
|
|
|
2006-03-18 07:54:32 +08:00
|
|
|
int saa7134_no_overlay=-1;
|
|
|
|
module_param_named(no_overlay, saa7134_no_overlay, int, 0444);
|
2006-03-11 03:46:50 +08:00
|
|
|
MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)"
|
|
|
|
" [some VIA/SIS chipsets are known to have problem with overlay]");
|
|
|
|
|
2014-04-17 17:44:31 +08:00
|
|
|
bool saa7134_userptr;
|
|
|
|
module_param(saa7134_userptr, bool, 0644);
|
|
|
|
MODULE_PARM_DESC(saa7134_userptr, "enable page-aligned userptr support");
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
|
|
|
static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
|
|
|
static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
|
|
|
static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
|
|
|
static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
|
|
|
|
2005-12-12 16:37:28 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
module_param_array(video_nr, int, NULL, 0444);
|
|
|
|
module_param_array(vbi_nr, int, NULL, 0444);
|
|
|
|
module_param_array(radio_nr, int, NULL, 0444);
|
|
|
|
module_param_array(tuner, int, NULL, 0444);
|
|
|
|
module_param_array(card, int, NULL, 0444);
|
|
|
|
|
|
|
|
MODULE_PARM_DESC(video_nr, "video device number");
|
|
|
|
MODULE_PARM_DESC(vbi_nr, "vbi device number");
|
|
|
|
MODULE_PARM_DESC(radio_nr, "radio device number");
|
|
|
|
MODULE_PARM_DESC(tuner, "tuner type");
|
|
|
|
MODULE_PARM_DESC(card, "card type");
|
|
|
|
|
2009-02-09 23:27:03 +08:00
|
|
|
DEFINE_MUTEX(saa7134_devlist_lock);
|
|
|
|
EXPORT_SYMBOL(saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
LIST_HEAD(saa7134_devlist);
|
2009-02-09 23:27:03 +08:00
|
|
|
EXPORT_SYMBOL(saa7134_devlist);
|
2005-04-17 06:20:36 +08:00
|
|
|
static LIST_HEAD(mops_list);
|
|
|
|
static unsigned int saa7134_devcount;
|
|
|
|
|
2006-07-16 02:19:56 +08:00
|
|
|
int (*saa7134_dmasound_init)(struct saa7134_dev *dev);
|
|
|
|
int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
|
2005-12-01 16:51:20 +08:00
|
|
|
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
#define core_dbg(fmt, arg...) if (core_debug) \
|
|
|
|
printk(KERN_DEBUG pr_fmt("core: " fmt), ## arg)
|
|
|
|
|
|
|
|
#define irq_dbg(level, fmt, arg...) if (irq_debug > level) \
|
|
|
|
printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
|
|
|
|
{
|
|
|
|
unsigned long mode,status;
|
|
|
|
|
|
|
|
if (!gpio_tracking)
|
|
|
|
return;
|
|
|
|
/* rising SAA7134_GPIO_GPRESCAN reads the status */
|
|
|
|
saa_andorb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN,0);
|
|
|
|
saa_andorb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN,SAA7134_GPIO_GPRESCAN);
|
|
|
|
mode = saa_readl(SAA7134_GPIO_GPMODE0 >> 2) & 0xfffffff;
|
|
|
|
status = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2) & 0xfffffff;
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("%s: gpio: mode=0x%07lx in=0x%07lx out=0x%07lx [%s]\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name, mode, (~mode) & status, mode & status, msg);
|
|
|
|
}
|
|
|
|
|
2007-04-27 23:31:11 +08:00
|
|
|
void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value)
|
|
|
|
{
|
|
|
|
u32 index, bitval;
|
|
|
|
|
|
|
|
index = 1 << bit_no;
|
|
|
|
switch (value) {
|
|
|
|
case 0: /* static value */
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
case 1: core_dbg("setting GPIO%d to static %d\n", bit_no, value);
|
2007-04-27 23:31:11 +08:00
|
|
|
/* turn sync mode off if necessary */
|
|
|
|
if (index & 0x00c00000)
|
|
|
|
saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x00);
|
|
|
|
if (value)
|
|
|
|
bitval = index;
|
|
|
|
else
|
|
|
|
bitval = 0;
|
|
|
|
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, index);
|
|
|
|
saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, index, bitval);
|
|
|
|
break;
|
|
|
|
case 3: /* tristate */
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("setting GPIO%d to tristate\n", bit_no);
|
2007-04-27 23:31:11 +08:00
|
|
|
saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0);
|
|
|
|
break;
|
2007-04-27 23:31:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
/* delayed request_module */
|
|
|
|
|
2005-12-01 16:51:39 +08:00
|
|
|
#if defined(CONFIG_MODULES) && defined(MODULE)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-04-27 23:31:17 +08:00
|
|
|
static void request_module_async(struct work_struct *work){
|
|
|
|
struct saa7134_dev* dev = container_of(work, struct saa7134_dev, request_module_wk);
|
|
|
|
if (card_is_empress(dev))
|
2005-11-09 13:37:43 +08:00
|
|
|
request_module("saa7134-empress");
|
2007-04-27 23:31:17 +08:00
|
|
|
if (card_is_dvb(dev))
|
2005-11-09 13:37:43 +08:00
|
|
|
request_module("saa7134-dvb");
|
2014-09-21 17:52:03 +08:00
|
|
|
if (card_is_go7007(dev))
|
|
|
|
request_module("saa7134-go7007");
|
2009-01-31 19:14:24 +08:00
|
|
|
if (alsa) {
|
|
|
|
if (dev->pci->device != PCI_DEVICE_ID_PHILIPS_SAA7130)
|
|
|
|
request_module("saa7134-alsa");
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-04-27 23:31:17 +08:00
|
|
|
static void request_submodules(struct saa7134_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-04-27 23:31:17 +08:00
|
|
|
INIT_WORK(&dev->request_module_wk, request_module_async);
|
|
|
|
schedule_work(&dev->request_module_wk);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-12-24 23:14:20 +08:00
|
|
|
static void flush_request_submodules(struct saa7134_dev *dev)
|
|
|
|
{
|
2012-08-21 05:51:24 +08:00
|
|
|
flush_work(&dev->request_module_wk);
|
2010-12-24 23:14:20 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
2007-03-10 04:39:52 +08:00
|
|
|
#define request_submodules(dev)
|
2010-12-24 23:14:20 +08:00
|
|
|
#define flush_request_submodules(dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* CONFIG_MODULES */
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
/* nr of (saa7134-)pages for the given buffer size */
|
|
|
|
static int saa7134_buffer_pages(int size)
|
|
|
|
{
|
|
|
|
size = PAGE_ALIGN(size);
|
|
|
|
size += PAGE_SIZE; /* for non-page-aligned buffers */
|
|
|
|
size /= 4096;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* calc max # of buffers from size (must not exceed the 4MB virtual
|
|
|
|
* address space per DMA channel) */
|
|
|
|
int saa7134_buffer_count(unsigned int size, unsigned int count)
|
|
|
|
{
|
|
|
|
unsigned int maxcount;
|
|
|
|
|
|
|
|
maxcount = 1024 / saa7134_buffer_pages(size);
|
|
|
|
if (count > maxcount)
|
|
|
|
count = maxcount;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int saa7134_buffer_startpage(struct saa7134_buf *buf)
|
|
|
|
{
|
2014-04-17 18:30:53 +08:00
|
|
|
return saa7134_buffer_pages(vb2_plane_size(&buf->vb2, 0)) * buf->vb2.v4l2_buf.index;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long saa7134_buffer_base(struct saa7134_buf *buf)
|
|
|
|
{
|
|
|
|
unsigned long base;
|
2014-04-17 18:30:53 +08:00
|
|
|
struct sg_table *dma = vb2_dma_sg_plane_desc(&buf->vb2, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
base = saa7134_buffer_startpage(buf) * 4096;
|
2014-04-17 18:30:53 +08:00
|
|
|
base += dma->sgl[0].offset;
|
2005-04-17 06:20:36 +08:00
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
int saa7134_pgtable_alloc(struct pci_dev *pci, struct saa7134_pgtable *pt)
|
|
|
|
{
|
2005-11-09 13:37:43 +08:00
|
|
|
__le32 *cpu;
|
2008-08-23 04:01:45 +08:00
|
|
|
dma_addr_t dma_addr = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
cpu = pci_alloc_consistent(pci, SAA7134_PGTABLE_SIZE, &dma_addr);
|
|
|
|
if (NULL == cpu)
|
|
|
|
return -ENOMEM;
|
|
|
|
pt->size = SAA7134_PGTABLE_SIZE;
|
|
|
|
pt->cpu = cpu;
|
|
|
|
pt->dma = dma_addr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int saa7134_pgtable_build(struct pci_dev *pci, struct saa7134_pgtable *pt,
|
|
|
|
struct scatterlist *list, unsigned int length,
|
|
|
|
unsigned int startpage)
|
|
|
|
{
|
2005-06-24 13:04:37 +08:00
|
|
|
__le32 *ptr;
|
2014-04-17 14:48:50 +08:00
|
|
|
unsigned int i, p;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
BUG_ON(NULL == pt || NULL == pt->cpu);
|
|
|
|
|
|
|
|
ptr = pt->cpu + startpage;
|
2014-04-17 18:30:53 +08:00
|
|
|
for (i = 0; i < length; i++, list = sg_next(list)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
for (p = 0; p * 4096 < list->length; p++, ptr++)
|
2014-04-17 18:30:53 +08:00
|
|
|
*ptr = cpu_to_le32(sg_dma_address(list) +
|
|
|
|
list->offset + p * 4096);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
|
|
|
|
{
|
|
|
|
if (NULL == pt->cpu)
|
|
|
|
return;
|
|
|
|
pci_free_consistent(pci, pt->size, pt->cpu, pt->dma);
|
|
|
|
pt->cpu = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
int saa7134_buffer_queue(struct saa7134_dev *dev,
|
|
|
|
struct saa7134_dmaqueue *q,
|
|
|
|
struct saa7134_buf *buf)
|
|
|
|
{
|
|
|
|
struct saa7134_buf *next = NULL;
|
2014-04-17 18:30:53 +08:00
|
|
|
unsigned long flags;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-04-17 18:30:53 +08:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_queue %p\n", buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (NULL == q->curr) {
|
|
|
|
if (!q->need_two) {
|
|
|
|
q->curr = buf;
|
2014-04-17 14:48:50 +08:00
|
|
|
buf->activate(dev, buf, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else if (list_empty(&q->queue)) {
|
2014-04-17 18:30:53 +08:00
|
|
|
list_add_tail(&buf->entry, &q->queue);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2014-04-17 14:48:50 +08:00
|
|
|
next = list_entry(q->queue.next, struct saa7134_buf,
|
2014-04-17 18:30:53 +08:00
|
|
|
entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->curr = buf;
|
2014-04-17 14:48:50 +08:00
|
|
|
buf->activate(dev, buf, next);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
} else {
|
2014-04-17 18:30:53 +08:00
|
|
|
list_add_tail(&buf->entry, &q->queue);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2014-04-17 18:30:53 +08:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_buffer_finish(struct saa7134_dev *dev,
|
|
|
|
struct saa7134_dmaqueue *q,
|
|
|
|
unsigned int state)
|
|
|
|
{
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_finish %p\n", q->curr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* finish current buffer */
|
2014-04-17 18:30:53 +08:00
|
|
|
v4l2_get_timestamp(&q->curr->vb2.v4l2_buf.timestamp);
|
|
|
|
q->curr->vb2.v4l2_buf.sequence = q->seq_nr++;
|
|
|
|
vb2_buffer_done(&q->curr->vb2, state);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->curr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_buffer_next(struct saa7134_dev *dev,
|
|
|
|
struct saa7134_dmaqueue *q)
|
|
|
|
{
|
|
|
|
struct saa7134_buf *buf,*next = NULL;
|
|
|
|
|
|
|
|
assert_spin_locked(&dev->slock);
|
|
|
|
BUG_ON(NULL != q->curr);
|
|
|
|
|
|
|
|
if (!list_empty(&q->queue)) {
|
|
|
|
/* activate next one from queue */
|
2014-04-17 18:30:53 +08:00
|
|
|
buf = list_entry(q->queue.next, struct saa7134_buf, entry);
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_next %p [prev=%p/next=%p]\n",
|
2014-04-17 14:48:50 +08:00
|
|
|
buf, q->queue.prev, q->queue.next);
|
2014-04-17 18:30:53 +08:00
|
|
|
list_del(&buf->entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!list_empty(&q->queue))
|
2014-04-17 18:30:53 +08:00
|
|
|
next = list_entry(q->queue.next, struct saa7134_buf, entry);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->curr = buf;
|
2014-04-17 14:48:50 +08:00
|
|
|
buf->activate(dev, buf, next);
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_next #2 prev=%p/next=%p\n",
|
2014-04-17 14:48:50 +08:00
|
|
|
q->queue.prev, q->queue.next);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/* nothing to do -- just stop DMA */
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_next %p\n", NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
saa7134_set_dmabits(dev);
|
|
|
|
del_timer(&q->timeout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_buffer_timeout(unsigned long data)
|
|
|
|
{
|
2014-04-17 14:48:50 +08:00
|
|
|
struct saa7134_dmaqueue *q = (struct saa7134_dmaqueue *)data;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct saa7134_dev *dev = q->dev;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2014-04-17 14:48:50 +08:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* try to reset the hardware (SWRST) */
|
|
|
|
saa_writeb(SAA7134_REGION_ENABLE, 0x00);
|
|
|
|
saa_writeb(SAA7134_REGION_ENABLE, 0x80);
|
|
|
|
saa_writeb(SAA7134_REGION_ENABLE, 0x00);
|
|
|
|
|
|
|
|
/* flag current buffer as failed,
|
|
|
|
try to start over with the next one. */
|
|
|
|
if (q->curr) {
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("timeout on %p\n", q->curr);
|
2014-04-17 18:30:53 +08:00
|
|
|
saa7134_buffer_finish(dev, q, VB2_BUF_STATE_ERROR);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2014-04-17 14:48:50 +08:00
|
|
|
saa7134_buffer_next(dev, q);
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2014-04-17 18:30:53 +08:00
|
|
|
void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
struct list_head *pos, *n;
|
|
|
|
struct saa7134_buf *tmp;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
|
|
|
if (!list_empty(&q->queue)) {
|
|
|
|
list_for_each_safe(pos, n, &q->queue) {
|
|
|
|
tmp = list_entry(pos, struct saa7134_buf, entry);
|
|
|
|
vb2_buffer_done(&tmp->vb2, VB2_BUF_STATE_ERROR);
|
|
|
|
list_del(pos);
|
|
|
|
tmp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
saa7134_buffer_timeout((unsigned long)q); /* also calls del_timer(&q->timeout) */
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(saa7134_stop_streaming);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
int saa7134_set_dmabits(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
u32 split, task=0, ctrl=0, irq=0;
|
|
|
|
enum v4l2_field cap = V4L2_FIELD_ANY;
|
|
|
|
enum v4l2_field ov = V4L2_FIELD_ANY;
|
|
|
|
|
|
|
|
assert_spin_locked(&dev->slock);
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
if (dev->insuspend)
|
2007-10-08 23:07:35 +08:00
|
|
|
return 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* video capture -- dma 0 + video task A */
|
|
|
|
if (dev->video_q.curr) {
|
|
|
|
task |= 0x01;
|
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE0;
|
|
|
|
irq |= SAA7134_IRQ1_INTE_RA0_1 |
|
|
|
|
SAA7134_IRQ1_INTE_RA0_0;
|
2014-04-17 18:30:53 +08:00
|
|
|
cap = dev->field;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* video capture -- dma 1+2 (planar modes) */
|
2014-04-17 16:00:39 +08:00
|
|
|
if (dev->video_q.curr && dev->fmt->planar) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE4 |
|
|
|
|
SAA7134_MAIN_CTRL_TE5;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* screen overlay -- dma 0 + video task B */
|
|
|
|
if (dev->ovenable) {
|
|
|
|
task |= 0x10;
|
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE1;
|
|
|
|
ov = dev->ovfield;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vbi capture -- dma 0 + vbi task A+B */
|
|
|
|
if (dev->vbi_q.curr) {
|
|
|
|
task |= 0x22;
|
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE2 |
|
|
|
|
SAA7134_MAIN_CTRL_TE3;
|
|
|
|
irq |= SAA7134_IRQ1_INTE_RA0_7 |
|
|
|
|
SAA7134_IRQ1_INTE_RA0_6 |
|
|
|
|
SAA7134_IRQ1_INTE_RA0_5 |
|
|
|
|
SAA7134_IRQ1_INTE_RA0_4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* audio capture -- dma 3 */
|
2005-11-09 13:38:54 +08:00
|
|
|
if (dev->dmasound.dma_running) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE6;
|
|
|
|
irq |= SAA7134_IRQ1_INTE_RA3_1 |
|
|
|
|
SAA7134_IRQ1_INTE_RA3_0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TS capture -- dma 5 */
|
|
|
|
if (dev->ts_q.curr) {
|
|
|
|
ctrl |= SAA7134_MAIN_CTRL_TE5;
|
2008-08-27 00:47:10 +08:00
|
|
|
irq |= SAA7134_IRQ1_INTE_RA2_1 |
|
2005-04-17 06:20:36 +08:00
|
|
|
SAA7134_IRQ1_INTE_RA2_0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set task conditions + field handling */
|
|
|
|
if (V4L2_FIELD_HAS_BOTH(cap) || V4L2_FIELD_HAS_BOTH(ov) || cap == ov) {
|
|
|
|
/* default config -- use full frames */
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0d);
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0d);
|
|
|
|
saa_writeb(SAA7134_FIELD_HANDLING(TASK_A), 0x02);
|
|
|
|
saa_writeb(SAA7134_FIELD_HANDLING(TASK_B), 0x02);
|
|
|
|
split = 0;
|
|
|
|
} else {
|
|
|
|
/* split fields between tasks */
|
|
|
|
if (V4L2_FIELD_TOP == cap) {
|
|
|
|
/* odd A, even B, repeat */
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0d);
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0e);
|
|
|
|
} else {
|
|
|
|
/* odd B, even A, repeat */
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_A), 0x0e);
|
|
|
|
saa_writeb(SAA7134_TASK_CONDITIONS(TASK_B), 0x0d);
|
|
|
|
}
|
|
|
|
saa_writeb(SAA7134_FIELD_HANDLING(TASK_A), 0x01);
|
|
|
|
saa_writeb(SAA7134_FIELD_HANDLING(TASK_B), 0x01);
|
|
|
|
split = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* irqs */
|
|
|
|
saa_writeb(SAA7134_REGION_ENABLE, task);
|
|
|
|
saa_writel(SAA7134_IRQ1, irq);
|
|
|
|
saa_andorl(SAA7134_MAIN_CTRL,
|
|
|
|
SAA7134_MAIN_CTRL_TE0 |
|
|
|
|
SAA7134_MAIN_CTRL_TE1 |
|
|
|
|
SAA7134_MAIN_CTRL_TE2 |
|
|
|
|
SAA7134_MAIN_CTRL_TE3 |
|
|
|
|
SAA7134_MAIN_CTRL_TE4 |
|
|
|
|
SAA7134_MAIN_CTRL_TE5 |
|
|
|
|
SAA7134_MAIN_CTRL_TE6,
|
|
|
|
ctrl);
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("dmabits: task=0x%02x ctrl=0x%02x irq=0x%x split=%s\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
task, ctrl, irq, split ? "no" : "yes");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* IRQ handler + helpers */
|
|
|
|
|
|
|
|
static char *irqbits[] = {
|
|
|
|
"DONE_RA0", "DONE_RA1", "DONE_RA2", "DONE_RA3",
|
|
|
|
"AR", "PE", "PWR_ON", "RDCAP", "INTL", "FIDT", "MMC",
|
|
|
|
"TRIG_ERR", "CONF_ERR", "LOAD_ERR",
|
2010-04-03 12:43:36 +08:00
|
|
|
"GPIO16", "GPIO18", "GPIO22", "GPIO23"
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
#define IRQBITS ARRAY_SIZE(irqbits)
|
|
|
|
|
|
|
|
static void print_irqstatus(struct saa7134_dev *dev, int loop,
|
|
|
|
unsigned long report, unsigned long status)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
irq_dbg(1, "[%d,%ld]: r=0x%lx s=0x%02lx",
|
|
|
|
loop, jiffies, report,status);
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < IRQBITS; i++) {
|
|
|
|
if (!(report & (1 << i)))
|
|
|
|
continue;
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
pr_cont(" %s",irqbits[i]);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (report & SAA7134_IRQ_REPORT_DONE_RA0) {
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
pr_cont(" | RA0=%s,%s,%s,%ld",
|
|
|
|
(status & 0x40) ? "vbi" : "video",
|
|
|
|
(status & 0x20) ? "b" : "a",
|
|
|
|
(status & 0x10) ? "odd" : "even",
|
|
|
|
(status & 0x0f));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
pr_cont("\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 21:55:46 +08:00
|
|
|
static irqreturn_t saa7134_irq(int irq, void *dev_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct saa7134_dev *dev = (struct saa7134_dev*) dev_id;
|
|
|
|
unsigned long report,status;
|
|
|
|
int loop, handled = 0;
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
if (dev->insuspend)
|
|
|
|
goto out;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (loop = 0; loop < 10; loop++) {
|
|
|
|
report = saa_readl(SAA7134_IRQ_REPORT);
|
|
|
|
status = saa_readl(SAA7134_IRQ_STATUS);
|
2005-11-09 13:38:53 +08:00
|
|
|
|
2007-12-01 00:27:26 +08:00
|
|
|
/* If dmasound support is active and we get a sound report,
|
|
|
|
* mask out the report and let the saa7134-alsa module deal
|
|
|
|
* with it */
|
2005-11-14 08:08:00 +08:00
|
|
|
if ((report & SAA7134_IRQ_REPORT_DONE_RA3) &&
|
|
|
|
(dev->dmasound.priv_data != NULL) )
|
|
|
|
{
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
irq_dbg(2, "preserving DMA sound interrupt\n");
|
2007-12-01 00:27:26 +08:00
|
|
|
report &= ~SAA7134_IRQ_REPORT_DONE_RA3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == report) {
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
irq_dbg(2,"no (more) work\n");
|
2005-11-09 13:38:53 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
handled = 1;
|
|
|
|
saa_writel(SAA7134_IRQ_REPORT,report);
|
|
|
|
if (irq_debug)
|
|
|
|
print_irqstatus(dev,loop,report,status);
|
|
|
|
|
|
|
|
|
2007-09-28 07:44:39 +08:00
|
|
|
if ((report & SAA7134_IRQ_REPORT_RDCAP) ||
|
|
|
|
(report & SAA7134_IRQ_REPORT_INTL))
|
|
|
|
saa7134_irq_video_signalchange(dev);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
|
|
|
|
(status & 0x60) == 0)
|
|
|
|
saa7134_irq_video_done(dev,status);
|
|
|
|
|
|
|
|
if ((report & SAA7134_IRQ_REPORT_DONE_RA0) &&
|
|
|
|
(status & 0x40) == 0x40)
|
|
|
|
saa7134_irq_vbi_done(dev,status);
|
|
|
|
|
|
|
|
if ((report & SAA7134_IRQ_REPORT_DONE_RA2) &&
|
2014-09-21 17:52:03 +08:00
|
|
|
card_has_mpeg(dev)) {
|
|
|
|
if (dev->mops->irq_ts_done != NULL)
|
|
|
|
dev->mops->irq_ts_done(dev, status);
|
|
|
|
else
|
|
|
|
saa7134_irq_ts_done(dev, status);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-01-10 04:21:23 +08:00
|
|
|
if (report & SAA7134_IRQ_REPORT_GPIO16) {
|
|
|
|
switch (dev->has_remote) {
|
|
|
|
case SAA7134_REMOTE_GPIO:
|
2006-04-07 21:04:56 +08:00
|
|
|
if (!dev->remote)
|
|
|
|
break;
|
2006-01-10 04:21:23 +08:00
|
|
|
if (dev->remote->mask_keydown & 0x10000) {
|
|
|
|
saa7134_input_irq(dev);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SAA7134_REMOTE_I2C:
|
|
|
|
break; /* FIXME: invoke I2C get_key() */
|
|
|
|
|
|
|
|
default: /* GPIO16 not used by IR remote */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-11-09 13:37:11 +08:00
|
|
|
|
2006-01-10 04:21:23 +08:00
|
|
|
if (report & SAA7134_IRQ_REPORT_GPIO18) {
|
|
|
|
switch (dev->has_remote) {
|
|
|
|
case SAA7134_REMOTE_GPIO:
|
2006-04-07 21:04:56 +08:00
|
|
|
if (!dev->remote)
|
|
|
|
break;
|
2006-01-10 04:21:23 +08:00
|
|
|
if ((dev->remote->mask_keydown & 0x40000) ||
|
|
|
|
(dev->remote->mask_keyup & 0x40000)) {
|
|
|
|
saa7134_input_irq(dev);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SAA7134_REMOTE_I2C:
|
|
|
|
break; /* FIXME: invoke I2C get_key() */
|
|
|
|
|
|
|
|
default: /* GPIO18 not used by IR remote */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (10 == loop) {
|
|
|
|
print_irqstatus(dev,loop,report,status);
|
|
|
|
if (report & SAA7134_IRQ_REPORT_PE) {
|
|
|
|
/* disable all parity error */
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_warn("%s/irq: looping -- "
|
2005-04-17 06:20:36 +08:00
|
|
|
"clearing PE (parity error!) enable bit\n",dev->name);
|
|
|
|
saa_clearl(SAA7134_IRQ2,SAA7134_IRQ2_INTE_PE);
|
2006-01-10 04:21:23 +08:00
|
|
|
} else if (report & SAA7134_IRQ_REPORT_GPIO16) {
|
|
|
|
/* disable gpio16 IRQ */
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_warn("%s/irq: looping -- "
|
2006-01-10 04:21:23 +08:00
|
|
|
"clearing GPIO16 enable bit\n",dev->name);
|
2010-04-03 12:43:36 +08:00
|
|
|
saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_P);
|
|
|
|
saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO16_N);
|
2006-01-10 04:21:23 +08:00
|
|
|
} else if (report & SAA7134_IRQ_REPORT_GPIO18) {
|
|
|
|
/* disable gpio18 IRQs */
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_warn("%s/irq: looping -- "
|
2006-01-10 04:21:23 +08:00
|
|
|
"clearing GPIO18 enable bit\n",dev->name);
|
2010-04-03 12:43:36 +08:00
|
|
|
saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_P);
|
|
|
|
saa_clearl(SAA7134_IRQ2, SAA7134_IRQ2_INTE_GPIO18_N);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/* disable all irqs */
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_warn("%s/irq: looping -- "
|
2005-04-17 06:20:36 +08:00
|
|
|
"clearing all enable bits\n",dev->name);
|
|
|
|
saa_writel(SAA7134_IRQ1,0);
|
|
|
|
saa_writel(SAA7134_IRQ2,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
/* early init (no i2c, no irq) */
|
2007-09-28 07:34:25 +08:00
|
|
|
|
|
|
|
static int saa7134_hw_enable1(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
/* RAM FIFO config */
|
|
|
|
saa_writel(SAA7134_FIFO_SIZE, 0x08070503);
|
|
|
|
saa_writel(SAA7134_THRESHOULD, 0x02020202);
|
|
|
|
|
|
|
|
/* enable audio + video processing */
|
|
|
|
saa_writel(SAA7134_MAIN_CTRL,
|
|
|
|
SAA7134_MAIN_CTRL_VPLLE |
|
|
|
|
SAA7134_MAIN_CTRL_APLLE |
|
|
|
|
SAA7134_MAIN_CTRL_EXOSC |
|
|
|
|
SAA7134_MAIN_CTRL_EVFE1 |
|
|
|
|
SAA7134_MAIN_CTRL_EVFE2 |
|
|
|
|
SAA7134_MAIN_CTRL_ESFE |
|
|
|
|
SAA7134_MAIN_CTRL_EBDAC);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize OSS _after_ enabling audio clock PLL and audio processing.
|
|
|
|
* OSS initialization writes to registers via the audio DSP; these
|
|
|
|
* writes will fail unless the audio clock has been started. At worst,
|
|
|
|
* audio will not work.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* enable peripheral devices */
|
|
|
|
saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
|
|
|
|
|
|
|
|
/* set vertical line numbering start (vbi needs this) */
|
|
|
|
saa_writeb(SAA7134_SOURCE_TIMING2, 0x20);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static int saa7134_hwinit1(struct saa7134_dev *dev)
|
|
|
|
{
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("hwinit1\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
saa_writel(SAA7134_IRQ1, 0);
|
|
|
|
saa_writel(SAA7134_IRQ2, 0);
|
2009-01-11 05:04:45 +08:00
|
|
|
|
|
|
|
/* Clear any stale IRQ reports */
|
|
|
|
saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT));
|
|
|
|
|
2006-02-07 16:49:14 +08:00
|
|
|
mutex_init(&dev->lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
spin_lock_init(&dev->slock);
|
|
|
|
|
|
|
|
saa7134_track_gpio(dev,"pre-init");
|
|
|
|
saa7134_video_init1(dev);
|
|
|
|
saa7134_vbi_init1(dev);
|
|
|
|
if (card_has_mpeg(dev))
|
|
|
|
saa7134_ts_init1(dev);
|
|
|
|
saa7134_input_init1(dev);
|
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_hw_enable1(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* late init (with i2c + irq) */
|
2007-09-28 07:34:25 +08:00
|
|
|
static int saa7134_hw_enable2(struct saa7134_dev *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
unsigned int irq2_mask;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* enable IRQ's */
|
2005-11-09 13:37:43 +08:00
|
|
|
irq2_mask =
|
2005-07-13 04:59:01 +08:00
|
|
|
SAA7134_IRQ2_INTE_DEC3 |
|
|
|
|
SAA7134_IRQ2_INTE_DEC2 |
|
|
|
|
SAA7134_IRQ2_INTE_DEC1 |
|
|
|
|
SAA7134_IRQ2_INTE_DEC0 |
|
|
|
|
SAA7134_IRQ2_INTE_PE |
|
|
|
|
SAA7134_IRQ2_INTE_AR;
|
|
|
|
|
2006-04-07 21:04:56 +08:00
|
|
|
if (dev->has_remote == SAA7134_REMOTE_GPIO && dev->remote) {
|
2006-01-10 04:21:23 +08:00
|
|
|
if (dev->remote->mask_keydown & 0x10000)
|
2010-04-03 12:43:36 +08:00
|
|
|
irq2_mask |= SAA7134_IRQ2_INTE_GPIO16_N;
|
V4L/DVB: saa7134: Add support for both positive and negative edge IRQ
The code that enables IRQ for the Remote Controller on saa7134 is a little
messy: it is outside saa7134-input, it checks if RC is GPIO based, and
it mixes both serial raw decode with parallel reads from a hardware-based
IR decoder.
Also, currently, it doesn't allow to trigger both transition edges at GPIO16
and GPIO18 lines. A rework on the code is needed to provide a better way
to specify what saa7134-input needs, maybe even moving part of the code from
saa7134-core and saa7134-cards into saa7134-input.
Yet, as a large rework is happening at RC core, it is better to wait until
the core changes stablize, in order to rework saa7134 RC internals.While
this don't happen, let's just change the logic a little bit to allow
enabling IRQ to be generated on both edge transitions, in order to better
support pulse/space raw decoders.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-04-03 22:26:01 +08:00
|
|
|
else { /* Allow enabling both IRQ edge triggers */
|
|
|
|
if (dev->remote->mask_keydown & 0x40000)
|
|
|
|
irq2_mask |= SAA7134_IRQ2_INTE_GPIO18_P;
|
|
|
|
if (dev->remote->mask_keyup & 0x40000)
|
|
|
|
irq2_mask |= SAA7134_IRQ2_INTE_GPIO18_N;
|
|
|
|
}
|
2006-01-10 04:21:23 +08:00
|
|
|
}
|
2005-07-13 04:59:01 +08:00
|
|
|
|
2008-09-29 13:25:40 +08:00
|
|
|
if (dev->has_remote == SAA7134_REMOTE_I2C) {
|
|
|
|
request_module("ir-kbd-i2c");
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
saa_writel(SAA7134_IRQ1, 0);
|
2005-07-13 04:59:01 +08:00
|
|
|
saa_writel(SAA7134_IRQ2, irq2_mask);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
static int saa7134_hwinit2(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("hwinit2\n");
|
2007-09-28 07:34:25 +08:00
|
|
|
|
|
|
|
saa7134_video_init2(dev);
|
|
|
|
saa7134_tvaudio_init2(dev);
|
|
|
|
|
|
|
|
saa7134_hw_enable2(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* shutdown */
|
|
|
|
static int saa7134_hwfini(struct saa7134_dev *dev)
|
|
|
|
{
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("hwfini\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (card_has_mpeg(dev))
|
|
|
|
saa7134_ts_fini(dev);
|
|
|
|
saa7134_input_fini(dev);
|
|
|
|
saa7134_vbi_fini(dev);
|
|
|
|
saa7134_tvaudio_fini(dev);
|
2013-12-14 19:28:23 +08:00
|
|
|
saa7134_video_fini(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:17:53 +08:00
|
|
|
static void must_configure_manually(int has_eeprom)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned int i,p;
|
|
|
|
|
2011-01-20 02:11:58 +08:00
|
|
|
if (!has_eeprom)
|
2015-04-30 17:55:53 +08:00
|
|
|
pr_warn("saa7134: <rant>\n"
|
|
|
|
"saa7134: Congratulations! Your TV card vendor saved a few\n"
|
|
|
|
"saa7134: cents for a eeprom, thus your pci board has no\n"
|
|
|
|
"saa7134: subsystem ID and I can't identify it automatically\n"
|
|
|
|
"saa7134: </rant>\n"
|
|
|
|
"saa7134: I feel better now. Ok, here are the good news:\n"
|
|
|
|
"saa7134: You can use the card=<nr> insmod option to specify\n"
|
|
|
|
"saa7134: which board do you have. The list:\n");
|
2011-01-20 02:11:58 +08:00
|
|
|
else
|
2015-04-30 17:55:53 +08:00
|
|
|
pr_warn("saa7134: Board is currently unknown. You might try to use the card=<nr>\n"
|
|
|
|
"saa7134: insmod option to specify which board do you have, but this is\n"
|
|
|
|
"saa7134: somewhat risky, as might damage your card. It is better to ask\n"
|
|
|
|
"saa7134: for support at linux-media@vger.kernel.org.\n"
|
|
|
|
"saa7134: The supported cards are:\n");
|
2011-01-20 02:11:58 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
for (i = 0; i < saa7134_bcount; i++) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_warn("saa7134: card=%d -> %-40.40s",
|
2005-04-17 06:20:36 +08:00
|
|
|
i,saa7134_boards[i].name);
|
|
|
|
for (p = 0; saa7134_pci_tbl[p].driver_data; p++) {
|
|
|
|
if (saa7134_pci_tbl[p].driver_data != i)
|
|
|
|
continue;
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
pr_cont(" %04x:%04x",
|
2005-04-17 06:20:36 +08:00
|
|
|
saa7134_pci_tbl[p].subvendor,
|
|
|
|
saa7134_pci_tbl[p].subdevice);
|
|
|
|
}
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
pr_cont("\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct video_device *vdev_init(struct saa7134_dev *dev,
|
|
|
|
struct video_device *template,
|
|
|
|
char *type)
|
|
|
|
{
|
|
|
|
struct video_device *vfd;
|
|
|
|
|
|
|
|
vfd = video_device_alloc();
|
|
|
|
if (NULL == vfd)
|
|
|
|
return NULL;
|
|
|
|
*vfd = *template;
|
2009-03-15 17:53:32 +08:00
|
|
|
vfd->v4l2_dev = &dev->v4l2_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
vfd->release = video_device_release;
|
|
|
|
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
|
|
|
|
dev->name, type, saa7134_boards[dev->board].name);
|
2009-12-10 21:44:04 +08:00
|
|
|
video_set_drvdata(vfd, dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
return vfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void saa7134_unregister_video(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
if (dev->video_dev) {
|
2009-11-28 00:57:30 +08:00
|
|
|
if (video_is_registered(dev->video_dev))
|
2005-04-17 06:20:36 +08:00
|
|
|
video_unregister_device(dev->video_dev);
|
|
|
|
else
|
|
|
|
video_device_release(dev->video_dev);
|
|
|
|
dev->video_dev = NULL;
|
|
|
|
}
|
|
|
|
if (dev->vbi_dev) {
|
2009-11-28 00:57:30 +08:00
|
|
|
if (video_is_registered(dev->vbi_dev))
|
2005-04-17 06:20:36 +08:00
|
|
|
video_unregister_device(dev->vbi_dev);
|
|
|
|
else
|
|
|
|
video_device_release(dev->vbi_dev);
|
|
|
|
dev->vbi_dev = NULL;
|
|
|
|
}
|
|
|
|
if (dev->radio_dev) {
|
2009-11-28 00:57:30 +08:00
|
|
|
if (video_is_registered(dev->radio_dev))
|
2005-04-17 06:20:36 +08:00
|
|
|
video_unregister_device(dev->radio_dev);
|
|
|
|
else
|
|
|
|
video_device_release(dev->radio_dev);
|
|
|
|
dev->radio_dev = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mpeg_ops_attach(struct saa7134_mpeg_ops *ops,
|
|
|
|
struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (NULL != dev->mops)
|
|
|
|
return;
|
|
|
|
if (saa7134_boards[dev->board].mpeg != ops->type)
|
|
|
|
return;
|
|
|
|
err = ops->init(dev);
|
|
|
|
if (0 != err)
|
|
|
|
return;
|
|
|
|
dev->mops = ops;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mpeg_ops_detach(struct saa7134_mpeg_ops *ops,
|
|
|
|
struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
if (NULL == dev->mops)
|
|
|
|
return;
|
|
|
|
if (dev->mops != ops)
|
|
|
|
return;
|
|
|
|
dev->mops->fini(dev);
|
|
|
|
dev->mops = NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:17:53 +08:00
|
|
|
static int saa7134_initdev(struct pci_dev *pci_dev,
|
|
|
|
const struct pci_device_id *pci_id)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct saa7134_dev *dev;
|
|
|
|
struct saa7134_mpeg_ops *mops;
|
|
|
|
int err;
|
|
|
|
|
2008-04-23 01:46:09 +08:00
|
|
|
if (saa7134_devcount == SAA7134_MAXBOARDS)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2006-01-12 05:40:56 +08:00
|
|
|
dev = kzalloc(sizeof(*dev),GFP_KERNEL);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (NULL == dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2009-01-17 23:17:14 +08:00
|
|
|
err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
|
|
|
|
if (err)
|
|
|
|
goto fail0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* pci init */
|
|
|
|
dev->pci = pci_dev;
|
|
|
|
if (pci_enable_device(pci_dev)) {
|
|
|
|
err = -EIO;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->nr = saa7134_devcount;
|
|
|
|
sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
|
|
|
|
|
|
|
|
/* pci quirks */
|
|
|
|
if (pci_pci_problems) {
|
|
|
|
if (pci_pci_problems & PCIPCI_TRITON)
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: PCIPCI_TRITON\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pci_pci_problems & PCIPCI_NATOMA)
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: PCIPCI_NATOMA\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pci_pci_problems & PCIPCI_VIAETBF)
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: PCIPCI_VIAETBF\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (pci_pci_problems & PCIPCI_VSFX)
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: PCIPCI_VSFX\n",dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef PCIPCI_ALIMAGIK
|
|
|
|
if (pci_pci_problems & PCIPCI_ALIMAGIK) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name);
|
|
|
|
latency = 0x0A;
|
|
|
|
}
|
|
|
|
#endif
|
2006-09-14 22:53:16 +08:00
|
|
|
if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: this driver and your "
|
2006-03-11 03:46:50 +08:00
|
|
|
"chipset may not work together"
|
|
|
|
" in overlay mode.\n",dev->name);
|
2006-03-18 07:54:32 +08:00
|
|
|
if (!saa7134_no_overlay) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: overlay "
|
2006-03-11 03:46:50 +08:00
|
|
|
"mode will be disabled.\n",
|
|
|
|
dev->name);
|
2006-03-18 07:54:32 +08:00
|
|
|
saa7134_no_overlay = 1;
|
2006-03-11 03:46:50 +08:00
|
|
|
} else {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: quirk: overlay "
|
2006-03-11 03:46:50 +08:00
|
|
|
"mode will be forced. Use this"
|
|
|
|
" option at your own risk.\n",
|
|
|
|
dev->name);
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (UNSET != latency) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: setting pci latency timer to %d\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name,latency);
|
|
|
|
pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* print pci info */
|
2011-03-21 22:35:56 +08:00
|
|
|
dev->pci_rev = pci_dev->revision;
|
2005-11-09 13:37:43 +08:00
|
|
|
pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: found at %s, rev: %d, irq: %d, "
|
2006-06-13 06:16:52 +08:00
|
|
|
"latency: %d, mmio: 0x%llx\n", dev->name,
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
|
2006-06-13 06:16:52 +08:00
|
|
|
dev->pci_lat,(unsigned long long)pci_resource_start(pci_dev,0));
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_set_master(pci_dev);
|
2009-04-07 10:01:15 +08:00
|
|
|
if (!pci_dma_supported(pci_dev, DMA_BIT_MASK(32))) {
|
2015-04-30 18:15:20 +08:00
|
|
|
pr_warn("%s: Oops: no 32bit PCI DMA ???\n", dev->name);
|
2005-04-17 06:20:36 +08:00
|
|
|
err = -EIO;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* board config */
|
|
|
|
dev->board = pci_id->driver_data;
|
2012-10-28 03:20:27 +08:00
|
|
|
if ((unsigned)card[dev->nr] < saa7134_bcount)
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->board = card[dev->nr];
|
2011-01-20 02:11:58 +08:00
|
|
|
if (SAA7134_BOARD_UNKNOWN == dev->board)
|
|
|
|
must_configure_manually(0);
|
|
|
|
else if (SAA7134_BOARD_NOAUTO == dev->board) {
|
|
|
|
must_configure_manually(1);
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->board = SAA7134_BOARD_UNKNOWN;
|
|
|
|
}
|
2006-10-31 06:56:59 +08:00
|
|
|
dev->autodetected = card[dev->nr] != dev->board;
|
2008-07-26 22:30:03 +08:00
|
|
|
dev->tuner_type = saa7134_boards[dev->board].tuner_type;
|
|
|
|
dev->tuner_addr = saa7134_boards[dev->board].tuner_addr;
|
2009-01-17 23:17:14 +08:00
|
|
|
dev->radio_type = saa7134_boards[dev->board].radio_type;
|
|
|
|
dev->radio_addr = saa7134_boards[dev->board].radio_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf;
|
|
|
|
if (UNSET != tuner[dev->nr])
|
|
|
|
dev->tuner_type = tuner[dev->nr];
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
|
2006-10-31 06:56:59 +08:00
|
|
|
dev->name,pci_dev->subsystem_vendor,
|
|
|
|
pci_dev->subsystem_device,saa7134_boards[dev->board].name,
|
|
|
|
dev->board, dev->autodetected ?
|
|
|
|
"autodetected" : "insmod option");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* get mmio */
|
|
|
|
if (!request_mem_region(pci_resource_start(pci_dev,0),
|
|
|
|
pci_resource_len(pci_dev,0),
|
|
|
|
dev->name)) {
|
|
|
|
err = -EBUSY;
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_err("%s: can't get MMIO memory @ 0x%llx\n",
|
2006-06-13 06:16:52 +08:00
|
|
|
dev->name,(unsigned long long)pci_resource_start(pci_dev,0));
|
2005-04-17 06:20:36 +08:00
|
|
|
goto fail1;
|
|
|
|
}
|
V4L/DVB (9356): [PATCH] saa7134: fix resource map sanity check conflict
Impact: driver could possibly stomp on resources outside of its scope
{mchehab@redhat.com: I got two versions of the same patch (identical,
except for whitespacing). One authored by Andy Burns and another
authored by Suresh Siddha. Due to that, I'm applying the one that has
less CodingStyle errors. I'm also adding both comments and the SOB's for
both patches, since they are both interesting}
Suresh Siddha commented:
Alexey Fisher reported:
> resource map sanity check conflict: 0xcfeff800 0xcff007ff 0xcfe00000
> 0xcfefffff PCI Bus 0000:01
BAR base is located in the middle of the 4K page and the hardcoded
size argument makes the request span two pages causing the conflict.
Fix the hard coded size argument in ioremap().
Andy Burns commented:
I have already sent this patch on the linux-dvb list, but it didn't get
much attention, so re-sending direct, I hope you all don't mind.
While attempting to run mythtv in a xen domU, I encountered problems
loading the driver for my saa7134 card, with an error from ioremap().
This error was due to the driver allocating an incorrectly sized mmio
area, which was trapped by xen's permission checks, but this would go
un-noticed on a kernel without xen.
My card has a 1K sized mmio area, I've had information that other cards
have 2K areas, perhaps others have different sizes, yet the driver
always attempts to map 4K. I realise that the granularity of mapping is
the page size, which typically would be 4K, but unless the card's base
address happens to fall on a 4K boundary (mine does not) then the
base+4K will end up spanning two pages, and this is when the error
occurs under xen.
My patch uses the pci_resource_len macro to determine the size required
for the user's particular card, instead of the hardcoded 4K value. I've
tested with a couple of printk() inside ioremap() that the start address
and size do get rounded to the closest page boundary.
With this patch I am able to successfully load the saa7134 driver and
run mythtv under xen with my card, subject to correct pollirq settings
in case of shared IRQ, I am still seeing occasional DMA panics, which I
think are related to swiotlb handling by dom0/domU, usually the panic
occurs when changing mux, once tuned to a mux, 12 hour continuous
recordings are possible without errors.
Reported-by: Alexey Fisher <bug-track@fisher-privat.net>
Tested-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Andy Burns <andy@burns.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2008-10-21 04:57:02 +08:00
|
|
|
dev->lmmio = ioremap(pci_resource_start(pci_dev, 0),
|
|
|
|
pci_resource_len(pci_dev, 0));
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->bmmio = (__u8 __iomem *)dev->lmmio;
|
|
|
|
if (NULL == dev->lmmio) {
|
|
|
|
err = -EIO;
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_err("%s: can't ioremap() MMIO memory\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name);
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize hardware #1 */
|
|
|
|
saa7134_board_init1(dev);
|
|
|
|
saa7134_hwinit1(dev);
|
|
|
|
|
2014-11-18 20:51:01 +08:00
|
|
|
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
|
|
|
|
if (IS_ERR(dev->alloc_ctx)) {
|
|
|
|
err = PTR_ERR(dev->alloc_ctx);
|
|
|
|
goto fail3;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
/* get irq */
|
|
|
|
err = request_irq(pci_dev->irq, saa7134_irq,
|
2013-10-13 13:49:29 +08:00
|
|
|
IRQF_SHARED, dev->name, dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (err < 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_err("%s: can't get IRQ %d\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name,pci_dev->irq);
|
2014-11-18 20:51:01 +08:00
|
|
|
goto fail4;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* wait a bit, register i2c bus */
|
|
|
|
msleep(100);
|
|
|
|
saa7134_i2c_register(dev);
|
|
|
|
saa7134_board_init2(dev);
|
2008-02-20 03:26:33 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
saa7134_hwinit2(dev);
|
|
|
|
|
|
|
|
/* load i2c helpers */
|
2005-11-09 13:37:43 +08:00
|
|
|
if (card_is_empress(dev)) {
|
2013-12-14 19:28:24 +08:00
|
|
|
dev->empress_sd =
|
2009-04-01 14:57:53 +08:00
|
|
|
v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
|
2010-09-24 21:16:44 +08:00
|
|
|
"saa6752hs",
|
2009-08-10 13:49:08 +08:00
|
|
|
saa7134_boards[dev->board].empress_addr, NULL);
|
2009-01-17 23:17:14 +08:00
|
|
|
|
2013-12-14 19:28:24 +08:00
|
|
|
if (dev->empress_sd)
|
|
|
|
dev->empress_sd->grp_id = GRP_EMPRESS;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-07-13 04:59:01 +08:00
|
|
|
|
2009-03-29 17:26:27 +08:00
|
|
|
if (saa7134_boards[dev->board].rds_addr) {
|
|
|
|
struct v4l2_subdev *sd;
|
|
|
|
|
2009-08-10 13:49:08 +08:00
|
|
|
sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
|
2010-09-24 21:16:44 +08:00
|
|
|
&dev->i2c_adap, "saa6588",
|
2009-08-10 13:49:08 +08:00
|
|
|
0, I2C_ADDRS(saa7134_boards[dev->board].rds_addr));
|
2009-06-20 17:09:52 +08:00
|
|
|
if (sd) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: found RDS decoder\n", dev->name);
|
2009-06-20 17:09:52 +08:00
|
|
|
dev->has_rds = 1;
|
|
|
|
}
|
2009-03-29 17:26:27 +08:00
|
|
|
}
|
|
|
|
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_lock(&saa7134_devlist_lock);
|
|
|
|
list_for_each_entry(mops, &mops_list, next)
|
|
|
|
mpeg_ops_attach(mops, dev);
|
|
|
|
list_add_tail(&dev->devlist, &saa7134_devlist);
|
|
|
|
mutex_unlock(&saa7134_devlist_lock);
|
|
|
|
|
|
|
|
/* check for signal */
|
|
|
|
saa7134_irq_video_signalchange(dev);
|
|
|
|
|
|
|
|
if (TUNER_ABSENT != dev->tuner_type)
|
2009-10-05 21:48:17 +08:00
|
|
|
saa_call_all(dev, core, s_power, 0);
|
2009-02-09 23:27:03 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* register v4l devices */
|
2008-07-26 19:26:43 +08:00
|
|
|
if (saa7134_no_overlay > 0)
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: Overlay support disabled.\n", dev->name);
|
2008-07-26 19:26:43 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
|
2013-12-14 19:28:24 +08:00
|
|
|
dev->video_dev->ctrl_handler = &dev->ctrl_handler;
|
2014-04-17 18:30:53 +08:00
|
|
|
dev->video_dev->lock = &dev->lock;
|
|
|
|
dev->video_dev->queue = &dev->video_vbq;
|
2005-04-17 06:20:36 +08:00
|
|
|
err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
|
|
|
|
video_nr[dev->nr]);
|
|
|
|
if (err < 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: can't register video device\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
dev->name);
|
2014-11-18 20:51:01 +08:00
|
|
|
goto fail5;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: registered device %s [v4l2]\n",
|
2009-11-28 00:57:15 +08:00
|
|
|
dev->name, video_device_node_name(dev->video_dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-12-11 23:05:06 +08:00
|
|
|
dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi");
|
2013-12-14 19:28:24 +08:00
|
|
|
dev->vbi_dev->ctrl_handler = &dev->ctrl_handler;
|
2014-04-17 18:30:53 +08:00
|
|
|
dev->vbi_dev->lock = &dev->lock;
|
|
|
|
dev->vbi_dev->queue = &dev->vbi_vbq;
|
2007-12-11 23:05:06 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
|
|
|
|
vbi_nr[dev->nr]);
|
|
|
|
if (err < 0)
|
2014-11-18 20:51:01 +08:00
|
|
|
goto fail5;
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: registered device %s\n",
|
2009-11-28 00:57:15 +08:00
|
|
|
dev->name, video_device_node_name(dev->vbi_dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (card_has_radio(dev)) {
|
|
|
|
dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio");
|
2013-12-14 19:28:24 +08:00
|
|
|
dev->radio_dev->ctrl_handler = &dev->radio_ctrl_handler;
|
2014-04-17 18:30:53 +08:00
|
|
|
dev->radio_dev->lock = &dev->lock;
|
2005-04-17 06:20:36 +08:00
|
|
|
err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
|
|
|
|
radio_nr[dev->nr]);
|
|
|
|
if (err < 0)
|
2014-11-18 20:51:01 +08:00
|
|
|
goto fail5;
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("%s: registered device %s\n",
|
2009-11-28 00:57:15 +08:00
|
|
|
dev->name, video_device_node_name(dev->radio_dev));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* everything worked */
|
|
|
|
saa7134_devcount++;
|
|
|
|
|
2009-02-09 23:27:03 +08:00
|
|
|
if (saa7134_dmasound_init && !dev->dmasound.priv_data)
|
2006-07-16 02:19:56 +08:00
|
|
|
saa7134_dmasound_init(dev);
|
2007-03-14 07:44:22 +08:00
|
|
|
|
2010-12-24 23:14:20 +08:00
|
|
|
request_submodules(dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
2014-11-18 20:51:01 +08:00
|
|
|
fail5:
|
2005-04-17 06:20:36 +08:00
|
|
|
saa7134_unregister_video(dev);
|
|
|
|
saa7134_i2c_unregister(dev);
|
|
|
|
free_irq(pci_dev->irq, dev);
|
2014-11-18 20:51:01 +08:00
|
|
|
fail4:
|
|
|
|
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
|
2005-04-17 06:20:36 +08:00
|
|
|
fail3:
|
|
|
|
saa7134_hwfini(dev);
|
|
|
|
iounmap(dev->lmmio);
|
|
|
|
fail2:
|
|
|
|
release_mem_region(pci_resource_start(pci_dev,0),
|
|
|
|
pci_resource_len(pci_dev,0));
|
|
|
|
fail1:
|
2009-01-17 23:17:14 +08:00
|
|
|
v4l2_device_unregister(&dev->v4l2_dev);
|
|
|
|
fail0:
|
2005-04-17 06:20:36 +08:00
|
|
|
kfree(dev);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2012-12-22 05:17:53 +08:00
|
|
|
static void saa7134_finidev(struct pci_dev *pci_dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-01-17 23:17:14 +08:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
struct saa7134_mpeg_ops *mops;
|
|
|
|
|
2010-12-24 23:14:20 +08:00
|
|
|
flush_request_submodules(dev);
|
|
|
|
|
2005-12-01 16:51:20 +08:00
|
|
|
/* Release DMA sound modules if present */
|
2006-07-16 02:19:56 +08:00
|
|
|
if (saa7134_dmasound_exit && dev->dmasound.priv_data) {
|
|
|
|
saa7134_dmasound_exit(dev);
|
2005-12-01 16:51:20 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* debugging ... */
|
|
|
|
if (irq_debug) {
|
|
|
|
u32 report = saa_readl(SAA7134_IRQ_REPORT);
|
|
|
|
u32 status = saa_readl(SAA7134_IRQ_STATUS);
|
|
|
|
print_irqstatus(dev,42,report,status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disable peripheral devices */
|
|
|
|
saa_writeb(SAA7134_SPECIAL_MODE,0);
|
|
|
|
|
|
|
|
/* shutdown hardware */
|
|
|
|
saa_writel(SAA7134_IRQ1,0);
|
|
|
|
saa_writel(SAA7134_IRQ2,0);
|
|
|
|
saa_writel(SAA7134_MAIN_CTRL,0);
|
|
|
|
|
|
|
|
/* shutdown subsystems */
|
|
|
|
saa7134_hwfini(dev);
|
|
|
|
|
|
|
|
/* unregister */
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_lock(&saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_del(&dev->devlist);
|
2007-10-10 16:37:42 +08:00
|
|
|
list_for_each_entry(mops, &mops_list, next)
|
2005-04-17 06:20:36 +08:00
|
|
|
mpeg_ops_detach(mops, dev);
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_unlock(&saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
saa7134_devcount--;
|
|
|
|
|
|
|
|
saa7134_i2c_unregister(dev);
|
|
|
|
saa7134_unregister_video(dev);
|
|
|
|
|
2005-12-01 16:51:20 +08:00
|
|
|
|
2005-11-14 08:08:00 +08:00
|
|
|
/* the DMA sound modules should be unloaded before reaching
|
|
|
|
this, but just in case they are still present... */
|
|
|
|
if (dev->dmasound.priv_data != NULL) {
|
|
|
|
free_irq(pci_dev->irq, &dev->dmasound);
|
|
|
|
dev->dmasound.priv_data = NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-01 16:51:20 +08:00
|
|
|
|
2005-11-14 08:08:00 +08:00
|
|
|
/* release resources */
|
2005-04-17 06:20:36 +08:00
|
|
|
free_irq(pci_dev->irq, dev);
|
2014-11-18 20:51:01 +08:00
|
|
|
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
|
2005-04-17 06:20:36 +08:00
|
|
|
iounmap(dev->lmmio);
|
|
|
|
release_mem_region(pci_resource_start(pci_dev,0),
|
|
|
|
pci_resource_len(pci_dev,0));
|
|
|
|
|
2009-01-17 23:17:14 +08:00
|
|
|
|
|
|
|
v4l2_device_unregister(&dev->v4l2_dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* free memory */
|
|
|
|
kfree(dev);
|
|
|
|
}
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
#ifdef CONFIG_PM
|
2008-08-21 07:44:54 +08:00
|
|
|
|
|
|
|
/* resends a current buffer in queue after resume */
|
|
|
|
static int saa7134_buffer_requeue(struct saa7134_dev *dev,
|
|
|
|
struct saa7134_dmaqueue *q)
|
|
|
|
{
|
|
|
|
struct saa7134_buf *buf, *next;
|
|
|
|
|
|
|
|
assert_spin_locked(&dev->slock);
|
|
|
|
|
|
|
|
buf = q->curr;
|
|
|
|
next = buf;
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_requeue\n");
|
2008-08-21 07:44:54 +08:00
|
|
|
|
|
|
|
if (!buf)
|
|
|
|
return 0;
|
|
|
|
|
[media] saa7134: better handle core debug messages
On media drivers, debugging messages should be grouped into
categories, as this makes easier to debug the driver.
In the case of saa7134, the core has 2 debug categories, one
for IRQ, and another one for the core itself. The IRQ have
actually 2 levels of debug.
So, instead of using pr_dbg(), where everything would be in
the same box, let's define two macros that use pr_fmt(),
one for the core, and another one for irq.
With that, we can replace the remaining printk() occurrences
at the core to use either core_dbg() or irq_dbg(), depending
on the group of debug macros that need to be enabled.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 19:03:30 +08:00
|
|
|
core_dbg("buffer_requeue : resending active buffers \n");
|
2008-08-21 07:44:54 +08:00
|
|
|
|
|
|
|
if (!list_empty(&q->queue))
|
|
|
|
next = list_entry(q->queue.next, struct saa7134_buf,
|
2014-04-17 18:30:53 +08:00
|
|
|
entry);
|
2008-08-21 07:44:54 +08:00
|
|
|
buf->activate(dev, buf, next);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
|
|
|
|
{
|
2009-01-17 23:17:14 +08:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
|
2007-10-08 23:07:35 +08:00
|
|
|
/* disable overlay - apps should enable it explicitly on resume*/
|
|
|
|
dev->ovenable = 0;
|
|
|
|
|
|
|
|
/* Disable interrupts, DMA, and rest of the chip*/
|
2007-09-28 07:34:25 +08:00
|
|
|
saa_writel(SAA7134_IRQ1, 0);
|
|
|
|
saa_writel(SAA7134_IRQ2, 0);
|
2007-10-08 23:07:35 +08:00
|
|
|
saa_writel(SAA7134_MAIN_CTRL, 0);
|
2007-09-28 07:34:25 +08:00
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
dev->insuspend = 1;
|
2007-11-05 06:34:23 +08:00
|
|
|
synchronize_irq(pci_dev->irq);
|
|
|
|
|
|
|
|
/* ACK interrupts once more, just in case,
|
|
|
|
since the IRQ handler won't ack them anymore*/
|
|
|
|
|
|
|
|
saa_writel(SAA7134_IRQ_REPORT, saa_readl(SAA7134_IRQ_REPORT));
|
2007-10-12 11:57:15 +08:00
|
|
|
|
|
|
|
/* Disable timeout timers - if we have active buffers, we will
|
|
|
|
fill them on resume*/
|
|
|
|
|
|
|
|
del_timer(&dev->video_q.timeout);
|
|
|
|
del_timer(&dev->vbi_q.timeout);
|
|
|
|
del_timer(&dev->ts_q.timeout);
|
2007-10-19 01:58:11 +08:00
|
|
|
|
|
|
|
if (dev->remote)
|
|
|
|
saa7134_ir_stop(dev);
|
2007-10-12 11:57:15 +08:00
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
pci_save_state(pci_dev);
|
2007-11-05 04:59:28 +08:00
|
|
|
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
|
2007-09-28 07:34:25 +08:00
|
|
|
|
2007-11-05 04:59:28 +08:00
|
|
|
return 0;
|
2007-09-28 07:34:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int saa7134_resume(struct pci_dev *pci_dev)
|
|
|
|
{
|
2009-01-17 23:17:14 +08:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
|
2008-01-18 04:52:05 +08:00
|
|
|
unsigned long flags;
|
2007-09-28 07:34:25 +08:00
|
|
|
|
|
|
|
pci_set_power_state(pci_dev, PCI_D0);
|
2007-11-05 04:59:28 +08:00
|
|
|
pci_restore_state(pci_dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
|
|
|
|
/* Do things that are done in saa7134_initdev ,
|
|
|
|
except of initializing memory structures.*/
|
|
|
|
|
|
|
|
saa7134_board_init1(dev);
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
/* saa7134_hwinit1 */
|
2007-09-28 07:34:25 +08:00
|
|
|
if (saa7134_boards[dev->board].video_out)
|
|
|
|
saa7134_videoport_init(dev);
|
|
|
|
if (card_has_mpeg(dev))
|
|
|
|
saa7134_ts_init_hw(dev);
|
2007-10-12 11:57:15 +08:00
|
|
|
if (dev->remote)
|
2010-04-01 01:40:35 +08:00
|
|
|
saa7134_ir_start(dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_hw_enable1(dev);
|
2007-10-12 11:57:15 +08:00
|
|
|
|
2007-11-05 05:21:25 +08:00
|
|
|
msleep(100);
|
2007-10-12 11:57:15 +08:00
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_board_init2(dev);
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
/*saa7134_hwinit2*/
|
|
|
|
saa7134_set_tvnorm_hw(dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_tvaudio_setmute(dev);
|
|
|
|
saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
|
2007-10-23 11:58:59 +08:00
|
|
|
saa7134_tvaudio_init(dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_enable_i2s(dev);
|
2007-10-12 11:57:15 +08:00
|
|
|
saa7134_hw_enable2(dev);
|
2007-09-28 07:34:25 +08:00
|
|
|
|
2007-11-05 05:21:25 +08:00
|
|
|
saa7134_irq_video_signalchange(dev);
|
|
|
|
|
2007-10-08 23:07:35 +08:00
|
|
|
/*resume unfinished buffer(s)*/
|
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2007-09-28 07:34:25 +08:00
|
|
|
saa7134_buffer_requeue(dev, &dev->video_q);
|
|
|
|
saa7134_buffer_requeue(dev, &dev->vbi_q);
|
|
|
|
saa7134_buffer_requeue(dev, &dev->ts_q);
|
|
|
|
|
2007-10-12 11:57:15 +08:00
|
|
|
/* FIXME: Disable DMA audio sound - temporary till proper support
|
|
|
|
is implemented*/
|
|
|
|
|
|
|
|
dev->dmasound.dma_running = 0;
|
|
|
|
|
2007-10-08 23:07:35 +08:00
|
|
|
/* start DMA now*/
|
2007-10-12 11:57:15 +08:00
|
|
|
dev->insuspend = 0;
|
2007-11-05 06:34:23 +08:00
|
|
|
smp_wmb();
|
2007-10-08 23:07:35 +08:00
|
|
|
saa7134_set_dmabits(dev);
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
|
2007-09-28 07:34:25 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2007-10-12 11:57:15 +08:00
|
|
|
#endif
|
2007-09-28 07:34:25 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
|
|
|
|
{
|
|
|
|
struct saa7134_dev *dev;
|
|
|
|
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_lock(&saa7134_devlist_lock);
|
2007-10-10 16:37:42 +08:00
|
|
|
list_for_each_entry(dev, &saa7134_devlist, devlist)
|
2005-04-17 06:20:36 +08:00
|
|
|
mpeg_ops_attach(ops, dev);
|
|
|
|
list_add_tail(&ops->next,&mops_list);
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_unlock(&saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
|
|
|
|
{
|
|
|
|
struct saa7134_dev *dev;
|
|
|
|
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_lock(&saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
list_del(&ops->next);
|
2007-10-10 16:37:42 +08:00
|
|
|
list_for_each_entry(dev, &saa7134_devlist, devlist)
|
2005-04-17 06:20:36 +08:00
|
|
|
mpeg_ops_detach(ops, dev);
|
2009-02-09 23:27:03 +08:00
|
|
|
mutex_unlock(&saa7134_devlist_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(saa7134_ts_register);
|
|
|
|
EXPORT_SYMBOL(saa7134_ts_unregister);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
static struct pci_driver saa7134_pci_driver = {
|
2005-11-09 13:37:43 +08:00
|
|
|
.name = "saa7134",
|
|
|
|
.id_table = saa7134_pci_tbl,
|
|
|
|
.probe = saa7134_initdev,
|
2012-12-22 05:17:53 +08:00
|
|
|
.remove = saa7134_finidev,
|
2007-10-12 11:57:15 +08:00
|
|
|
#ifdef CONFIG_PM
|
2007-09-28 07:34:25 +08:00
|
|
|
.suspend = saa7134_suspend,
|
|
|
|
.resume = saa7134_resume
|
2007-10-12 11:57:15 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-11-05 02:28:33 +08:00
|
|
|
static int __init saa7134_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
INIT_LIST_HEAD(&saa7134_devlist);
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 17:46:34 +08:00
|
|
|
pr_info("saa7130/34: v4l2 driver version %s loaded\n",
|
[media] Stop using linux/version.h on most video drivers
All the modified drivers didn't have any version increment since
Jan, 1 2011. Several of them didn't have any version increment
for a long time, even having new features and important bug fixes
happening.
As we're now filling the QUERYCAP version with the current Kernel
Release, we don't need to maintain a per-driver version control
anymore. So, let's just use the default.
In order to preserve the Kernel module version history, a
KERNEL_VERSION() macro were added to all modified drivers, and
the extraver number were incremented.
I opted to preserve the per-driver version control to a few
pwc, pvrusb2, s2255, s5p-fimc and sh_vou.
A few drivers are still using the legacy way to handle ioctl's.
So, we can't do such change on them, otherwise, they'll break.
Those are: uvc, et61x251 and sn9c102.
The rationale is that the per-driver version control seems to be
actively maintained on those.
Yet, I think that the better for them would be to just use the
default version numbering, instead of doing that by themselves.
While here, removed a few uneeded include linux/version.h
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2011-06-25 01:45:49 +08:00
|
|
|
SAA7134_VERSION);
|
2006-01-10 01:25:17 +08:00
|
|
|
return pci_register_driver(&saa7134_pci_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-11-05 02:28:33 +08:00
|
|
|
static void __exit saa7134_fini(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
pci_unregister_driver(&saa7134_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(saa7134_init);
|
|
|
|
module_exit(saa7134_fini);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
2007-04-27 23:31:12 +08:00
|
|
|
EXPORT_SYMBOL(saa7134_set_gpio);
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT_SYMBOL(saa7134_boards);
|
|
|
|
|
2005-11-14 08:08:00 +08:00
|
|
|
/* ----------------- for the DMA sound modules --------------- */
|
2005-11-09 13:38:53 +08:00
|
|
|
|
2006-07-16 02:19:56 +08:00
|
|
|
EXPORT_SYMBOL(saa7134_dmasound_init);
|
|
|
|
EXPORT_SYMBOL(saa7134_dmasound_exit);
|
2005-11-09 13:38:53 +08:00
|
|
|
EXPORT_SYMBOL(saa7134_pgtable_free);
|
|
|
|
EXPORT_SYMBOL(saa7134_pgtable_build);
|
|
|
|
EXPORT_SYMBOL(saa7134_pgtable_alloc);
|
|
|
|
EXPORT_SYMBOL(saa7134_set_dmabits);
|