linux/drivers/media/pci/ivtv/ivtv-driver.c

/*
    ivtv driver initialization and card probing
    Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
    Copyright (C) 2004  Chris Kennedy <[email protected]>
    Copyright (C) 2005-2007  Hans Verkuil <[email protected]>

    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* Main Driver file for the ivtv project:
 * Driver for the Conexant CX23415/CX23416 chip.
 * Author: Kevin Thayer (nufan_wfk at yahoo.com)
 * License: GPL
 *
 * -----
 * MPG600/MPG160 support by  T.Adachi <[email protected]>
 *                      and Takeru KOMORIYA<[email protected]>
 *
 * AVerMedia M179 GPIO info by Chris Pinkham <[email protected]>
 *                using information provided by Jiun-Kuei Jung @ AVerMedia.
 *
 * Kurouto Sikou CX23416GYC-STVLP tested by K.Ohta <[email protected]>
 *                using information from T.Adachi,Takeru KOMORIYA and others :-)
 *
 * Nagase TRANSGEAR 5000TV, Aopen VA2000MAX-STN6 and I/O data GV-MVP/RX
 *                version by T.Adachi. Special thanks  Mr.Suzuki
 */

#include "ivtv-driver.h"
#include "ivtv-version.h"
#include "ivtv-fileops.h"
#include "ivtv-i2c.h"
#include "ivtv-firmware.h"
#include "ivtv-queue.h"
#include "ivtv-udma.h"
#include "ivtv-irq.h"
#include "ivtv-mailbox.h"
#include "ivtv-streams.h"
#include "ivtv-ioctl.h"
#include "ivtv-cards.h"
#include "ivtv-vbi.h"
#include "ivtv-routing.h"
#include "ivtv-controls.h"
#include "ivtv-gpio.h"
#include <linux/dma-mapping.h>
#include <media/tveeprom.h>
#include <media/i2c/saa7115.h>
#include "xc2028.h"
#include <uapi/linux/sched/types.h>

/* If you have already X v4l cards, then set this to X. This way
   the device numbers stay matched. Example: you have a WinTV card
   without radio and a PVR-350 with. Normally this would give a
   video1 device together with a radio0 device for the PVR. By
   setting this to 1 you ensure that radio0 is now also radio1. */
int ivtv_first_minor;

/* Callback for registering extensions */
int (*ivtv_ext_init)(struct ivtv *);
EXPORT_SYMBOL();

/* add your revision and whatnot here */
static const struct pci_device_id ivtv_pci_tbl[] =;

MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);

/* ivtv instance counter */
static atomic_t ivtv_instance =;

/* Parameter declarations */
static int cardtype[IVTV_MAX_CARDS];
static int tuner[IVTV_MAX_CARDS] =;
static int radio[IVTV_MAX_CARDS] =;
static int i2c_clock_period[IVTV_MAX_CARDS] =;

static unsigned int cardtype_c =;
static unsigned int tuner_c =;
static int radio_c =;
static unsigned int i2c_clock_period_c =;
static char pal[] =;
static char secam[] =;
static char ntsc[] =;

/* Buffers */

/* DMA Buffers, Default size in MB allocated */
#define IVTV_DEFAULT_ENC_MPG_BUFFERS
#define IVTV_DEFAULT_ENC_YUV_BUFFERS
#define IVTV_DEFAULT_ENC_VBI_BUFFERS
/* Exception: size in kB for this stream (MB is overkill) */
#define IVTV_DEFAULT_ENC_PCM_BUFFERS
#define IVTV_DEFAULT_DEC_MPG_BUFFERS
#define IVTV_DEFAULT_DEC_YUV_BUFFERS
/* Exception: size in kB for this stream (MB is way overkill) */
#define IVTV_DEFAULT_DEC_VBI_BUFFERS

static int enc_mpg_buffers =;
static int enc_yuv_buffers =;
static int enc_vbi_buffers =;
static int enc_pcm_buffers =;
static int dec_mpg_buffers =;
static int dec_yuv_buffers =;
static int dec_vbi_buffers =;

static int ivtv_yuv_mode;
static int ivtv_yuv_threshold =;
static int ivtv_pci_latency =;

int ivtv_debug;
#ifdef CONFIG_VIDEO_ADV_DEBUG
int ivtv_fw_debug;
#endif

static int tunertype =;
static int newi2c =;

module_param_array();
module_param_array();
module_param_array();
module_param_string();
module_param_string();
module_param_string();
module_param_named(debug,ivtv_debug, int, 0644);
#ifdef CONFIG_VIDEO_ADV_DEBUG
module_param_named(fw_debug, ivtv_fw_debug, int, 0644);
#endif
module_param(ivtv_pci_latency, int, 0644);
module_param(ivtv_yuv_mode, int, 0644);
module_param(ivtv_yuv_threshold, int, 0644);
module_param(ivtv_first_minor, int, 0644);

module_param(enc_mpg_buffers, int, 0644);
module_param(enc_yuv_buffers, int, 0644);
module_param(enc_vbi_buffers, int, 0644);
module_param(enc_pcm_buffers, int, 0644);
module_param(dec_mpg_buffers, int, 0644);
module_param(dec_yuv_buffers, int, 0644);
module_param(dec_vbi_buffers, int, 0644);

module_param(tunertype, int, 0644);
module_param(newi2c, int, 0644);
module_param_array();

MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
#ifdef CONFIG_VIDEO_ADV_DEBUG
MODULE_PARM_DESC();
#endif
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();

MODULE_PARM_DESC();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

MODULE_VERSION();

#if defined(CONFIG_MODULES) && defined(MODULE)
static void request_module_async(struct work_struct *work)
{
	struct ivtv *dev = container_of(work, struct ivtv, request_module_wk);

	/* Make sure ivtv-alsa module is loaded */
	request_module("ivtv-alsa");

	/* Initialize ivtv-alsa for this instance of the cx18 device */
	if (ivtv_ext_init != NULL)
		ivtv_ext_init(dev);
}

static void request_modules(struct ivtv *dev)
{
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct ivtv *dev)
{
	flush_work(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */

void ivtv_clear_irq_mask(struct ivtv *itv, u32 mask)
{}

void ivtv_set_irq_mask(struct ivtv *itv, u32 mask)
{}

int ivtv_set_output_mode(struct ivtv *itv, int mode)
{}

struct ivtv_stream *ivtv_get_output_stream(struct ivtv *itv)
{}

int ivtv_waitq(wait_queue_head_t *waitq)
{}

/* Generic utility functions */
int ivtv_msleep_timeout(unsigned int msecs, int intr)
{}

/* Hauppauge card? get values from tveeprom */
void ivtv_read_eeprom(struct ivtv *itv, struct tveeprom *tv)
{}

static void ivtv_process_eeprom(struct ivtv *itv)
{}

static v4l2_std_id ivtv_parse_std(struct ivtv *itv)
{}

static void ivtv_process_options(struct ivtv *itv)
{}

/* Precondition: the ivtv structure has been memset to 0. Only
   the dev and num fields have been filled in.
   No assumptions on the card type may be made here (see ivtv_init_struct2
   for that).
 */
static int ivtv_init_struct1(struct ivtv *itv)
{}

/* Second initialization part. Here the card type has been
   autodetected. */
static void ivtv_init_struct2(struct ivtv *itv)
{}

static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *pdev,
			  const struct pci_device_id *pci_id)
{}

static void ivtv_load_and_init_modules(struct ivtv *itv)
{}

static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
{}

int ivtv_init_on_first_open(struct ivtv *itv)
{}

static void ivtv_remove(struct pci_dev *pdev)
{}

/* define a pci_driver for card detection */
static struct pci_driver ivtv_pci_driver =;

static int __init module_start(void)
{}

static void __exit module_cleanup(void)
{}

/* Note: These symbols are exported because they are used by the ivtvfb
   framebuffer module and an infrared module for the IR-blaster. */
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
#ifdef CONFIG_VIDEO_ADV_DEBUG
EXPORT_SYMBOL();
#endif
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();
EXPORT_SYMBOL();

module_init();
module_exit(module_cleanup);