/*
* i2c tv tuner chip device driver
* core core, i.e. kernel interfaces, registering and so on
*
* Copyright(c) by Ralph Metzler, Gerd Knorr, Gunther Mayer
*
* Copyright(c) 2005-2011 by Mauro Carvalho Chehab
* - Added support for a separate Radio tuner
* - Major rework and cleanups at the code
*
* This driver supports many devices and the idea is to let the driver
* detect which device is present. So rather than listing all supported
* devices here, we pretend to support a single, fake device type that will
* handle both radio and analog TV tuning.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/poll.h>
#include <linux/i2c.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/videodev2.h>
#include <media/tuner.h>
#include <media/tuner-types.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include "mt20xx.h"
#include "tda8290.h"
#include "tea5761.h"
#include "tea5767.h"
#include "tuner-xc2028.h"
#include "tuner-simple.h"
#include "tda9887.h"
#include "xc5000.h"
#include "tda18271.h"
#define UNSET (-1U)
#define PREFIX (t->i2c->driver->driver.name)
/*
* Driver modprobe parameters
*/
/* insmod options used at init time => read/only */
static unsigned int addr;
static unsigned int no_autodetect;
static unsigned int show_i2c;
module_param(addr, int, 0444);
module_param(no_autodetect, int, 0444);
module_param(show_i2c, int, 0444);
/* insmod options used at runtime => read/write */
static int tuner_debug;
static unsigned int tv_range[2] = { 44, 958 };
static unsigned int radio_range[2] = { 65, 108 };
static char pal[] = "--";
static char secam[] = "--";
static char ntsc[] = "-";
module_param_named(debug, tuner_debug, int, 0644);
module_param_array(tv_range, int, NULL, 0644);
module_param_array(radio_range, int, NULL, 0644);
module_param_string(pal, pal, sizeof(pal), 0644);
module_param_string(secam, secam, sizeof(secam), 0644);
module_param_string(ntsc, ntsc, sizeof(ntsc), 0644);
/*
* Static vars
*/
static LIST_HEAD(tuner_list);
static const struct v4l2_subdev_ops tuner_ops;
/*
* Debug macros
*/
#define tuner_warn(fmt, arg...) do { \
printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_info(fmt, arg...) do { \
printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_err(fmt, arg...) do { \
printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_dbg(fmt, arg...) do { \
if (tuner_debug) \
printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
/*
* Int