forked from Minki/linux
Merge branch 'topic/cx25821' into patchwork
* topic/cx25821: (31 commits) [media] cx25821: remove cx25821-audio-upstream.c from the Makefile [media] cx25821: replace custom ioctls with write() [media] cx25821: drop cx25821-video-upstream-ch2.c/h [media] cx25821: add output format ioctls [media] cx25821: prepare querycap for output support [media] cx25821: group all fmt functions together [media] cx25821: setup output nodes correctly [media] cx25821: remove references to subdevices that aren't there [media] cx25821: remove custom ioctls that duplicate v4l2 ioctls [media] cx25821: g/s/try/enum_fmt related fixes and cleanups [media] cx25821: switch to v4l2_fh, add event and prio handling [media] cx25821: replace resource management functions with fh ownership [media] cx25821: move vidq from cx25821_fh to cx25821_channel [media] cx25821: remove 'type' field from cx25821_fh [media] cx25821: use core locking [media] cx25821: remove unnecessary debug messages [media] cx25821: remove TRUE/FALSE/STATUS_(UN)SUCCESSFUL defines [media] cx25821: convert to the control framework [media] cx25821: embed video_device, clean up some kernel log spam [media] cx25821: remove bogus dependencies ...
This commit is contained in:
commit
a5d0568e2a
@ -1,14 +1,9 @@
|
||||
config VIDEO_CX25821
|
||||
tristate "Conexant cx25821 support"
|
||||
depends on DVB_CORE && VIDEO_DEV && PCI && I2C
|
||||
depends on VIDEO_DEV && PCI && I2C
|
||||
select I2C_ALGOBIT
|
||||
select VIDEO_BTCX
|
||||
select VIDEO_TVEEPROM
|
||||
depends on RC_CORE
|
||||
select VIDEOBUF_DVB
|
||||
select VIDEOBUF_DMA_SG
|
||||
select VIDEO_CX25840
|
||||
select VIDEO_CX2341X
|
||||
---help---
|
||||
This is a video4linux driver for Conexant 25821 based
|
||||
TV cards.
|
||||
|
@ -1,14 +1,9 @@
|
||||
cx25821-y := cx25821-core.o cx25821-cards.o cx25821-i2c.o \
|
||||
cx25821-gpio.o cx25821-medusa-video.o \
|
||||
cx25821-video.o cx25821-video-upstream.o \
|
||||
cx25821-video-upstream-ch2.o \
|
||||
cx25821-audio-upstream.o
|
||||
cx25821-video.o cx25821-video-upstream.o
|
||||
|
||||
obj-$(CONFIG_VIDEO_CX25821) += cx25821.o
|
||||
obj-$(CONFIG_VIDEO_CX25821_ALSA) += cx25821-alsa.o
|
||||
|
||||
ccflags-y += -Idrivers/media/i2c
|
||||
ccflags-y += -Idrivers/media/common
|
||||
ccflags-y += -Idrivers/media/tuners
|
||||
ccflags-y += -Idrivers/media/dvb-core
|
||||
ccflags-y += -Idrivers/media/dvb-frontends
|
||||
|
@ -59,7 +59,6 @@ do { \
|
||||
Data type declarations - Can be moded to a header file later
|
||||
****************************************************************************/
|
||||
|
||||
static struct snd_card *snd_cx25821_cards[SNDRV_CARDS];
|
||||
static int devno;
|
||||
|
||||
struct cx25821_audio_buffer {
|
||||
@ -151,7 +150,7 @@ static int _cx25821_start_audio_dma(struct cx25821_audio_dev *chip)
|
||||
{
|
||||
struct cx25821_audio_buffer *buf = chip->buf;
|
||||
struct cx25821_dev *dev = chip->dev;
|
||||
struct sram_channel *audio_ch =
|
||||
const struct sram_channel *audio_ch =
|
||||
&cx25821_sram_channels[AUDIO_SRAM_CHANNEL];
|
||||
u32 tmp = 0;
|
||||
|
||||
@ -626,34 +625,6 @@ static DEFINE_PCI_DEVICE_TABLE(cx25821_audio_pci_tbl) = {
|
||||
|
||||
MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl);
|
||||
|
||||
/*
|
||||
* Not used in the function snd_cx25821_dev_free so removing
|
||||
* from the file.
|
||||
*/
|
||||
/*
|
||||
static int snd_cx25821_free(struct cx25821_audio_dev *chip)
|
||||
{
|
||||
if (chip->irq >= 0)
|
||||
free_irq(chip->irq, chip);
|
||||
|
||||
cx25821_dev_unregister(chip->dev);
|
||||
pci_disable_device(chip->pci);
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Component Destructor
|
||||
*/
|
||||
static void snd_cx25821_dev_free(struct snd_card *card)
|
||||
{
|
||||
struct cx25821_audio_dev *chip = card->private_data;
|
||||
|
||||
/* snd_cx25821_free(chip); */
|
||||
snd_card_free(chip->card);
|
||||
}
|
||||
|
||||
/*
|
||||
* Alsa Constructor - Component probe
|
||||
*/
|
||||
@ -685,7 +656,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
|
||||
strcpy(card->driver, "cx25821");
|
||||
|
||||
/* Card "creation" */
|
||||
card->private_free = snd_cx25821_dev_free;
|
||||
chip = card->private_data;
|
||||
spin_lock_init(&chip->reg_lock);
|
||||
|
||||
@ -729,8 +699,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev)
|
||||
goto error;
|
||||
}
|
||||
|
||||
snd_cx25821_cards[devno] = card;
|
||||
|
||||
dev->card = card;
|
||||
devno++;
|
||||
return 0;
|
||||
|
||||
@ -742,9 +711,31 @@ error:
|
||||
/****************************************************************************
|
||||
LINUX MODULE INIT
|
||||
****************************************************************************/
|
||||
|
||||
static int cx25821_alsa_exit_callback(struct device *dev, void *data)
|
||||
{
|
||||
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
|
||||
struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
|
||||
|
||||
snd_card_free(cxdev->card);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cx25821_audio_fini(void)
|
||||
{
|
||||
snd_card_free(snd_cx25821_cards[0]);
|
||||
struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
|
||||
int ret;
|
||||
|
||||
ret = driver_for_each_device(drv, NULL, NULL, cx25821_alsa_exit_callback);
|
||||
}
|
||||
|
||||
static int cx25821_alsa_init_callback(struct device *dev, void *data)
|
||||
{
|
||||
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
|
||||
struct cx25821_dev *cxdev = get_cx25821(v4l2_dev);
|
||||
|
||||
cx25821_audio_initdev(cxdev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -756,29 +747,11 @@ static void cx25821_audio_fini(void)
|
||||
*/
|
||||
static int cx25821_alsa_init(void)
|
||||
{
|
||||
struct cx25821_dev *dev = NULL;
|
||||
struct list_head *list;
|
||||
struct device_driver *drv = driver_find("cx25821", &pci_bus_type);
|
||||
|
||||
mutex_lock(&cx25821_devlist_mutex);
|
||||
list_for_each(list, &cx25821_devlist) {
|
||||
dev = list_entry(list, struct cx25821_dev, devlist);
|
||||
cx25821_audio_initdev(dev);
|
||||
}
|
||||
mutex_unlock(&cx25821_devlist_mutex);
|
||||
|
||||
if (dev == NULL)
|
||||
pr_info("ERROR ALSA: no cx25821 cards found\n");
|
||||
|
||||
return 0;
|
||||
return driver_for_each_device(drv, NULL, NULL, cx25821_alsa_init_callback);
|
||||
|
||||
}
|
||||
|
||||
late_initcall(cx25821_alsa_init);
|
||||
module_exit(cx25821_audio_fini);
|
||||
|
||||
/* ----------------------------------------------------------- */
|
||||
/*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* End:
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF |
|
||||
FLD_AUD_SRC_SYNC | FLD_AUD_SRC_OPC_ERR;
|
||||
|
||||
static int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc)
|
||||
{
|
||||
unsigned int i, lines;
|
||||
@ -106,7 +106,7 @@ static __le32 *cx25821_risc_field_upstream_audio(struct cx25821_dev *dev,
|
||||
int fifo_enable)
|
||||
{
|
||||
unsigned int line;
|
||||
struct sram_channel *sram_ch =
|
||||
const struct sram_channel *sram_ch =
|
||||
dev->channels[dev->_audio_upstream_channel].sram_channels;
|
||||
int offset = 0;
|
||||
|
||||
@ -215,7 +215,7 @@ static void cx25821_free_memory_audio(struct cx25821_dev *dev)
|
||||
|
||||
void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
|
||||
{
|
||||
struct sram_channel *sram_ch =
|
||||
const struct sram_channel *sram_ch =
|
||||
dev->channels[AUDIO_UPSTREAM_SRAM_CHANNEL_B].sram_channels;
|
||||
u32 tmp = 0;
|
||||
|
||||
@ -257,7 +257,7 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
|
||||
}
|
||||
|
||||
static int cx25821_get_audio_data(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
const struct sram_channel *sram_ch)
|
||||
{
|
||||
struct file *myfile;
|
||||
int frame_index_temp = dev->_audioframe_index;
|
||||
@ -352,7 +352,7 @@ static void cx25821_audioups_handler(struct work_struct *work)
|
||||
}
|
||||
|
||||
static int cx25821_openfile_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
const struct sram_channel *sram_ch)
|
||||
{
|
||||
struct file *myfile;
|
||||
int i = 0, j = 0;
|
||||
@ -433,7 +433,7 @@ static int cx25821_openfile_audio(struct cx25821_dev *dev,
|
||||
}
|
||||
|
||||
static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch,
|
||||
const struct sram_channel *sram_ch,
|
||||
int bpl)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -495,7 +495,7 @@ static int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
{
|
||||
int i = 0;
|
||||
u32 int_msk_tmp;
|
||||
struct sram_channel *channel = dev->channels[chan_num].sram_channels;
|
||||
const struct sram_channel *channel = dev->channels[chan_num].sram_channels;
|
||||
dma_addr_t risc_phys_jump_addr;
|
||||
__le32 *rp;
|
||||
|
||||
@ -587,7 +587,7 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
|
||||
struct cx25821_dev *dev = dev_id;
|
||||
u32 audio_status;
|
||||
int handled = 0;
|
||||
struct sram_channel *sram_ch;
|
||||
const struct sram_channel *sram_ch;
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
@ -611,7 +611,7 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
|
||||
}
|
||||
|
||||
static void cx25821_wait_fifo_enable(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
const struct sram_channel *sram_ch)
|
||||
{
|
||||
int count = 0;
|
||||
u32 tmp;
|
||||
@ -635,7 +635,7 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev,
|
||||
}
|
||||
|
||||
static int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
const struct sram_channel *sram_ch)
|
||||
{
|
||||
u32 tmp = 0;
|
||||
int err = 0;
|
||||
@ -699,7 +699,7 @@ fail_irq:
|
||||
|
||||
int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
|
||||
{
|
||||
struct sram_channel *sram_ch;
|
||||
const struct sram_channel *sram_ch;
|
||||
int err = 0;
|
||||
|
||||
if (dev->_audio_is_running) {
|
||||
|
@ -26,11 +26,8 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
#include <media/cx25840.h>
|
||||
|
||||
#include "cx25821.h"
|
||||
#include "tuner-xc2028.h"
|
||||
|
||||
/* board config info */
|
||||
|
||||
@ -45,28 +42,8 @@ struct cx25821_board cx25821_boards[] = {
|
||||
.name = "CX25821",
|
||||
.portb = CX25821_RAW,
|
||||
.portc = CX25821_264,
|
||||
.input[0].type = CX25821_VMUX_COMPOSITE,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const unsigned int cx25821_bcount = ARRAY_SIZE(cx25821_boards);
|
||||
|
||||
struct cx25821_subid cx25821_subids[] = {
|
||||
{
|
||||
.subvendor = 0x14f1,
|
||||
.subdevice = 0x0920,
|
||||
.card = CX25821_BOARD,
|
||||
},
|
||||
};
|
||||
|
||||
void cx25821_card_setup(struct cx25821_dev *dev)
|
||||
{
|
||||
static u8 eeprom[256];
|
||||
|
||||
if (dev->i2c_bus[0].i2c_rc == 0) {
|
||||
dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
|
||||
tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
|
||||
sizeof(eeprom));
|
||||
}
|
||||
}
|
||||
|
@ -41,14 +41,7 @@ static unsigned int card[] = {[0 ... (CX25821_MAXBOARDS - 1)] = UNSET };
|
||||
module_param_array(card, int, NULL, 0444);
|
||||
MODULE_PARM_DESC(card, "card type");
|
||||
|
||||
static unsigned int cx25821_devcount;
|
||||
|
||||
DEFINE_MUTEX(cx25821_devlist_mutex);
|
||||
EXPORT_SYMBOL(cx25821_devlist_mutex);
|
||||
LIST_HEAD(cx25821_devlist);
|
||||
EXPORT_SYMBOL(cx25821_devlist);
|
||||
|
||||
struct sram_channel cx25821_sram_channels[] = {
|
||||
const struct sram_channel cx25821_sram_channels[] = {
|
||||
[SRAM_CH00] = {
|
||||
.i = SRAM_CH00,
|
||||
.name = "VID A",
|
||||
@ -317,20 +310,6 @@ struct sram_channel cx25821_sram_channels[] = {
|
||||
};
|
||||
EXPORT_SYMBOL(cx25821_sram_channels);
|
||||
|
||||
struct sram_channel *channel0 = &cx25821_sram_channels[SRAM_CH00];
|
||||
struct sram_channel *channel1 = &cx25821_sram_channels[SRAM_CH01];
|
||||
struct sram_channel *channel2 = &cx25821_sram_channels[SRAM_CH02];
|
||||
struct sram_channel *channel3 = &cx25821_sram_channels[SRAM_CH03];
|
||||
struct sram_channel *channel4 = &cx25821_sram_channels[SRAM_CH04];
|
||||
struct sram_channel *channel5 = &cx25821_sram_channels[SRAM_CH05];
|
||||
struct sram_channel *channel6 = &cx25821_sram_channels[SRAM_CH06];
|
||||
struct sram_channel *channel7 = &cx25821_sram_channels[SRAM_CH07];
|
||||
struct sram_channel *channel9 = &cx25821_sram_channels[SRAM_CH09];
|
||||
struct sram_channel *channel10 = &cx25821_sram_channels[SRAM_CH10];
|
||||
struct sram_channel *channel11 = &cx25821_sram_channels[SRAM_CH11];
|
||||
|
||||
struct cx25821_dmaqueue mpegq;
|
||||
|
||||
static int cx25821_risc_decode(u32 risc)
|
||||
{
|
||||
static const char * const instr[16] = {
|
||||
@ -457,7 +436,7 @@ static void cx25821_registers_init(struct cx25821_dev *dev)
|
||||
}
|
||||
|
||||
int cx25821_sram_channel_setup(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc)
|
||||
{
|
||||
unsigned int i, lines;
|
||||
@ -523,10 +502,9 @@ int cx25821_sram_channel_setup(struct cx25821_dev *dev,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(cx25821_sram_channel_setup);
|
||||
|
||||
int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc)
|
||||
{
|
||||
unsigned int i, lines;
|
||||
@ -592,7 +570,7 @@ int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
|
||||
}
|
||||
EXPORT_SYMBOL(cx25821_sram_channel_setup_audio);
|
||||
|
||||
void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch)
|
||||
void cx25821_sram_channel_dump(struct cx25821_dev *dev, const struct sram_channel *ch)
|
||||
{
|
||||
static char *name[] = {
|
||||
"init risc lo",
|
||||
@ -652,10 +630,9 @@ void cx25821_sram_channel_dump(struct cx25821_dev *dev, struct sram_channel *ch)
|
||||
pr_warn(" : cnt2_reg: 0x%08x\n",
|
||||
cx_read(ch->cnt2_reg));
|
||||
}
|
||||
EXPORT_SYMBOL(cx25821_sram_channel_dump);
|
||||
|
||||
void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch)
|
||||
const struct sram_channel *ch)
|
||||
{
|
||||
static const char * const name[] = {
|
||||
"init risc lo",
|
||||
@ -798,12 +775,12 @@ void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel_select,
|
||||
if (channel_select <= 7 && channel_select >= 0) {
|
||||
cx_write(dev->channels[channel_select].sram_channels->pix_frmt,
|
||||
format);
|
||||
dev->channels[channel_select].pixel_formats = format;
|
||||
}
|
||||
dev->channels[channel_select].pixel_formats = format;
|
||||
}
|
||||
|
||||
static void cx25821_set_vip_mode(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch)
|
||||
const struct sram_channel *ch)
|
||||
{
|
||||
cx_write(ch->pix_frmt, PIXEL_FRMT_422);
|
||||
cx_write(ch->vip_ctl, PIXEL_ENGINE_VIP1);
|
||||
@ -837,12 +814,13 @@ static void cx25821_initialize(struct cx25821_dev *dev)
|
||||
cx25821_sram_channel_setup(dev, dev->channels[i].sram_channels,
|
||||
1440, 0);
|
||||
dev->channels[i].pixel_formats = PIXEL_FRMT_422;
|
||||
dev->channels[i].use_cif_resolution = FALSE;
|
||||
dev->channels[i].use_cif_resolution = 0;
|
||||
}
|
||||
|
||||
/* Probably only affect Downstream */
|
||||
for (i = VID_UPSTREAM_SRAM_CHANNEL_I;
|
||||
i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) {
|
||||
dev->channels[i].pixel_formats = PIXEL_FRMT_422;
|
||||
cx25821_set_vip_mode(dev, dev->channels[i].sram_channels);
|
||||
}
|
||||
|
||||
@ -868,8 +846,7 @@ static void cx25821_dev_checkrevision(struct cx25821_dev *dev)
|
||||
{
|
||||
dev->hwrevision = cx_read(RDR_CFG2) & 0xff;
|
||||
|
||||
pr_info("%s(): Hardware revision = 0x%02x\n",
|
||||
__func__, dev->hwrevision);
|
||||
pr_info("Hardware revision = 0x%02x\n", dev->hwrevision);
|
||||
}
|
||||
|
||||
static void cx25821_iounmap(struct cx25821_dev *dev)
|
||||
@ -879,7 +856,6 @@ static void cx25821_iounmap(struct cx25821_dev *dev)
|
||||
|
||||
/* Releasing IO memory */
|
||||
if (dev->lmmio != NULL) {
|
||||
CX25821_INFO("Releasing lmmio.\n");
|
||||
iounmap(dev->lmmio);
|
||||
dev->lmmio = NULL;
|
||||
}
|
||||
@ -887,23 +863,14 @@ static void cx25821_iounmap(struct cx25821_dev *dev)
|
||||
|
||||
static int cx25821_dev_setup(struct cx25821_dev *dev)
|
||||
{
|
||||
static unsigned int cx25821_devcount;
|
||||
int i;
|
||||
|
||||
pr_info("\n***********************************\n");
|
||||
pr_info("cx25821 set up\n");
|
||||
pr_info("***********************************\n\n");
|
||||
|
||||
mutex_init(&dev->lock);
|
||||
|
||||
atomic_inc(&dev->refcount);
|
||||
|
||||
dev->nr = ++cx25821_devcount;
|
||||
sprintf(dev->name, "cx25821[%d]", dev->nr);
|
||||
|
||||
mutex_lock(&cx25821_devlist_mutex);
|
||||
list_add_tail(&dev->devlist, &cx25821_devlist);
|
||||
mutex_unlock(&cx25821_devlist_mutex);
|
||||
|
||||
if (dev->pci->device != 0x8210) {
|
||||
pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
|
||||
__func__, dev->pci->device);
|
||||
@ -914,8 +881,11 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
|
||||
|
||||
/* Apply a sensible clock frequency for the PCIe bridge */
|
||||
dev->clk_freq = 28000000;
|
||||
for (i = 0; i < MAX_VID_CHANNEL_NUM; i++)
|
||||
for (i = 0; i < MAX_VID_CHANNEL_NUM; i++) {
|
||||
dev->channels[i].dev = dev;
|
||||
dev->channels[i].id = i;
|
||||
dev->channels[i].sram_channels = &cx25821_sram_channels[i];
|
||||
}
|
||||
|
||||
if (dev->nr > 1)
|
||||
CX25821_INFO("dev->nr > 1!");
|
||||
@ -978,63 +948,15 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
|
||||
/* cx25821_i2c_register(&dev->i2c_bus[1]);
|
||||
* cx25821_i2c_register(&dev->i2c_bus[2]); */
|
||||
|
||||
CX25821_INFO("i2c register! bus->i2c_rc = %d\n",
|
||||
dev->i2c_bus[0].i2c_rc);
|
||||
|
||||
cx25821_card_setup(dev);
|
||||
|
||||
if (medusa_video_init(dev) < 0)
|
||||
CX25821_ERR("%s(): Failed to initialize medusa!\n", __func__);
|
||||
|
||||
cx25821_video_register(dev);
|
||||
|
||||
/* register IOCTL device */
|
||||
dev->ioctl_dev = cx25821_vdev_init(dev, dev->pci,
|
||||
&cx25821_videoioctl_template, "video");
|
||||
|
||||
if (video_register_device
|
||||
(dev->ioctl_dev, VFL_TYPE_GRABBER, VIDEO_IOCTL_CH) < 0) {
|
||||
cx25821_videoioctl_unregister(dev);
|
||||
pr_err("%s(): Failed to register video adapter for IOCTL, so unregistering videoioctl device\n",
|
||||
__func__);
|
||||
}
|
||||
|
||||
cx25821_dev_checkrevision(dev);
|
||||
CX25821_INFO("setup done!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct *up_data)
|
||||
{
|
||||
dev->_isNTSC = !strcmp(dev->vid_stdname, "NTSC") ? 1 : 0;
|
||||
|
||||
dev->tvnorm = !dev->_isNTSC ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M;
|
||||
medusa_set_videostandard(dev);
|
||||
|
||||
cx25821_vidupstream_init_ch1(dev, dev->channel_select,
|
||||
dev->pixel_format);
|
||||
}
|
||||
|
||||
void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct *up_data)
|
||||
{
|
||||
dev->_isNTSC_ch2 = !strcmp(dev->vid_stdname_ch2, "NTSC") ? 1 : 0;
|
||||
|
||||
dev->tvnorm = !dev->_isNTSC_ch2 ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M;
|
||||
medusa_set_videostandard(dev);
|
||||
|
||||
cx25821_vidupstream_init_ch2(dev, dev->channel_select_ch2,
|
||||
dev->pixel_format_ch2);
|
||||
}
|
||||
|
||||
void cx25821_start_upstream_audio(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct *up_data)
|
||||
{
|
||||
cx25821_audio_upstream_init(dev, AUDIO_UPSTREAM_SRAM_CHANNEL_B);
|
||||
}
|
||||
|
||||
void cx25821_dev_unregister(struct cx25821_dev *dev)
|
||||
{
|
||||
int i;
|
||||
@ -1042,25 +964,16 @@ void cx25821_dev_unregister(struct cx25821_dev *dev)
|
||||
if (!dev->base_io_addr)
|
||||
return;
|
||||
|
||||
cx25821_free_mem_upstream_ch1(dev);
|
||||
cx25821_free_mem_upstream_ch2(dev);
|
||||
cx25821_free_mem_upstream_audio(dev);
|
||||
|
||||
release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0));
|
||||
|
||||
if (!atomic_dec_and_test(&dev->refcount))
|
||||
return;
|
||||
|
||||
for (i = 0; i < VID_CHANNEL_NUM; i++)
|
||||
cx25821_video_unregister(dev, i);
|
||||
|
||||
for (i = VID_UPSTREAM_SRAM_CHANNEL_I;
|
||||
i <= AUDIO_UPSTREAM_SRAM_CHANNEL_B; i++) {
|
||||
for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) {
|
||||
if (i == SRAM_CH08) /* audio channel */
|
||||
continue;
|
||||
if (i == SRAM_CH09 || i == SRAM_CH10)
|
||||
cx25821_free_mem_upstream(&dev->channels[i]);
|
||||
cx25821_video_unregister(dev, i);
|
||||
}
|
||||
|
||||
cx25821_videoioctl_unregister(dev);
|
||||
|
||||
cx25821_i2c_unregister(&dev->i2c_bus[0]);
|
||||
cx25821_iounmap(dev);
|
||||
}
|
||||
@ -1385,8 +1298,6 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
|
||||
goto fail_unregister_device;
|
||||
}
|
||||
|
||||
pr_info("Athena pci enable !\n");
|
||||
|
||||
err = cx25821_dev_setup(dev);
|
||||
if (err) {
|
||||
if (err == -EBUSY)
|
||||
@ -1445,10 +1356,6 @@ static void cx25821_finidev(struct pci_dev *pci_dev)
|
||||
if (pci_dev->irq)
|
||||
free_irq(pci_dev->irq, dev);
|
||||
|
||||
mutex_lock(&cx25821_devlist_mutex);
|
||||
list_del(&dev->devlist);
|
||||
mutex_unlock(&cx25821_devlist_mutex);
|
||||
|
||||
cx25821_dev_unregister(dev);
|
||||
v4l2_device_unregister(v4l2_dev);
|
||||
kfree(dev);
|
||||
|
@ -20,6 +20,7 @@
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "cx25821.h"
|
||||
|
||||
/********************* GPIO stuffs *********************/
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include "cx25821.h"
|
||||
#include <linux/module.h>
|
||||
#include <linux/i2c.h>
|
||||
#include "cx25821.h"
|
||||
|
||||
static unsigned int i2c_debug;
|
||||
module_param(i2c_debug, int, 0644);
|
||||
|
@ -94,8 +94,6 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
|
||||
u32 value = 0;
|
||||
u32 tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
for (i = 0; i < MAX_DECODERS; i++) {
|
||||
/* set video format NTSC-M */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
||||
@ -222,8 +220,6 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
|
||||
value |= 0x00080200;
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -265,8 +261,6 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
|
||||
u32 value = 0;
|
||||
u32 tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
for (i = 0; i < MAX_DECODERS; i++) {
|
||||
/* set video format PAL-BDGHI */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0],
|
||||
@ -397,14 +391,12 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
|
||||
value &= 0xFFF7FDFF;
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
int medusa_set_videostandard(struct cx25821_dev *dev)
|
||||
{
|
||||
int status = STATUS_SUCCESS;
|
||||
int status = 0;
|
||||
u32 value = 0, tmp = 0;
|
||||
|
||||
if (dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
|
||||
@ -434,8 +426,6 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width,
|
||||
u32 vscale = 0x0;
|
||||
const int MAX_WIDTH = 720;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
/* validate the width */
|
||||
if (width > MAX_WIDTH) {
|
||||
pr_info("%s(): width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH\n",
|
||||
@ -485,8 +475,6 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width,
|
||||
cx25821_i2c_write(&dev->i2c_bus[0],
|
||||
VSCALE_CTRL + (0x200 * decoder), vscale);
|
||||
}
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
}
|
||||
|
||||
static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
|
||||
@ -496,11 +484,8 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
|
||||
u32 tmp = 0;
|
||||
u32 disp_cnt_reg = DISP_AB_CNT;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
/* no support */
|
||||
if (decoder < VDEC_A || decoder > VDEC_H) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -535,8 +520,6 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder,
|
||||
}
|
||||
|
||||
cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
}
|
||||
|
||||
/* Map to Medusa register setting */
|
||||
@ -587,10 +570,8 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
|
||||
int value = 0;
|
||||
u32 val = 0, tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
if ((brightness > VIDEO_PROCAMP_MAX) ||
|
||||
(brightness < VIDEO_PROCAMP_MIN)) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -1;
|
||||
}
|
||||
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness,
|
||||
@ -601,7 +582,6 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
|
||||
val &= 0xFFFFFF00;
|
||||
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
||||
VDEC_A_BRITE_CTRL + (0x200 * decoder), val | value);
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -611,10 +591,7 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
|
||||
int value = 0;
|
||||
u32 val = 0, tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
if ((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN)) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -626,7 +603,6 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
|
||||
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
||||
VDEC_A_CNTRST_CTRL + (0x200 * decoder), val | value);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -636,10 +612,7 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
|
||||
int value = 0;
|
||||
u32 val = 0, tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
if ((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN)) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -654,7 +627,6 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
|
||||
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
||||
VDEC_A_HUE_CTRL + (0x200 * decoder), val | value);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -664,11 +636,8 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
|
||||
int value = 0;
|
||||
u32 val = 0, tmp = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
if ((saturation > VIDEO_PROCAMP_MAX) ||
|
||||
(saturation < VIDEO_PROCAMP_MIN)) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -687,7 +656,6 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
|
||||
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0],
|
||||
VDEC_A_VSAT_CTRL + (0x200 * decoder), val | value);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@ -699,8 +667,6 @@ int medusa_video_init(struct cx25821_dev *dev)
|
||||
int ret_val = 0;
|
||||
int i = 0;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
_num_decoders = dev->_max_num_decoders;
|
||||
|
||||
/* disable Auto source selection on all video decoders */
|
||||
@ -719,13 +685,9 @@ int medusa_video_init(struct cx25821_dev *dev)
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
for (i = 0; i < _num_decoders; i++)
|
||||
medusa_set_decoderduration(dev, i, _display_field_cnt[i]);
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
/* Select monitor as DENC A input, power up the DAC */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp);
|
||||
value &= 0xFF70FF70;
|
||||
@ -774,14 +736,8 @@ int medusa_video_init(struct cx25821_dev *dev)
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
ret_val = medusa_set_videostandard(dev);
|
||||
|
||||
return ret_val;
|
||||
|
||||
error:
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
@ -1,800 +0,0 @@
|
||||
/*
|
||||
* Driver for the Conexant CX25821 PCIe bridge
|
||||
*
|
||||
* Copyright (C) 2009 Conexant Systems Inc.
|
||||
* Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include "cx25821-video.h"
|
||||
#include "cx25821-video-upstream-ch2.h"
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
|
||||
MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC |
|
||||
FLD_VID_SRC_OPC_ERR;
|
||||
|
||||
static __le32 *cx25821_update_riscprogram_ch2(struct cx25821_dev *dev,
|
||||
__le32 *rp, unsigned int offset,
|
||||
unsigned int bpl, u32 sync_line,
|
||||
unsigned int lines,
|
||||
int fifo_enable, int field_type)
|
||||
{
|
||||
unsigned int line, i;
|
||||
int dist_betwn_starts = bpl * 2;
|
||||
|
||||
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
|
||||
|
||||
if (USE_RISC_NOOP_VIDEO) {
|
||||
for (i = 0; i < NUM_NO_OPS; i++)
|
||||
*(rp++) = cpu_to_le32(RISC_NOOP);
|
||||
}
|
||||
|
||||
/* scan lines */
|
||||
for (line = 0; line < lines; line++) {
|
||||
*(rp++) = cpu_to_le32(RISC_READ | RISC_SOL | RISC_EOL | bpl);
|
||||
*(rp++) = cpu_to_le32(dev->_data_buf_phys_addr_ch2 + offset);
|
||||
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
||||
|
||||
if ((lines <= NTSC_FIELD_HEIGHT) ||
|
||||
(line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC_ch2)) {
|
||||
offset += dist_betwn_starts;
|
||||
}
|
||||
}
|
||||
|
||||
return rp;
|
||||
}
|
||||
|
||||
static __le32 *cx25821_risc_field_upstream_ch2(struct cx25821_dev *dev,
|
||||
__le32 *rp,
|
||||
dma_addr_t databuf_phys_addr,
|
||||
unsigned int offset,
|
||||
u32 sync_line, unsigned int bpl,
|
||||
unsigned int lines,
|
||||
int fifo_enable, int field_type)
|
||||
{
|
||||
unsigned int line, i;
|
||||
struct sram_channel *sram_ch =
|
||||
dev->channels[dev->_channel2_upstream_select].sram_channels;
|
||||
int dist_betwn_starts = bpl * 2;
|
||||
|
||||
/* sync instruction */
|
||||
if (sync_line != NO_SYNC_LINE)
|
||||
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
|
||||
|
||||
if (USE_RISC_NOOP_VIDEO) {
|
||||
for (i = 0; i < NUM_NO_OPS; i++)
|
||||
*(rp++) = cpu_to_le32(RISC_NOOP);
|
||||
}
|
||||
|
||||
/* scan lines */
|
||||
for (line = 0; line < lines; line++) {
|
||||
*(rp++) = cpu_to_le32(RISC_READ | RISC_SOL | RISC_EOL | bpl);
|
||||
*(rp++) = cpu_to_le32(databuf_phys_addr + offset);
|
||||
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
||||
|
||||
if ((lines <= NTSC_FIELD_HEIGHT) ||
|
||||
(line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC_ch2)) {
|
||||
offset += dist_betwn_starts;
|
||||
}
|
||||
|
||||
/*
|
||||
check if we need to enable the FIFO after the first 4 lines
|
||||
For the upstream video channel, the risc engine will enable
|
||||
the FIFO.
|
||||
*/
|
||||
if (fifo_enable && line == 3) {
|
||||
*(rp++) = RISC_WRITECR;
|
||||
*(rp++) = sram_ch->dma_ctl;
|
||||
*(rp++) = FLD_VID_FIFO_EN;
|
||||
*(rp++) = 0x00000001;
|
||||
}
|
||||
}
|
||||
|
||||
return rp;
|
||||
}
|
||||
|
||||
static int cx25821_risc_buffer_upstream_ch2(struct cx25821_dev *dev,
|
||||
struct pci_dev *pci,
|
||||
unsigned int top_offset,
|
||||
unsigned int bpl,
|
||||
unsigned int lines)
|
||||
{
|
||||
__le32 *rp;
|
||||
int fifo_enable = 0;
|
||||
int singlefield_lines = lines >> 1; /*get line count for single field */
|
||||
int odd_num_lines = singlefield_lines;
|
||||
int frame = 0;
|
||||
int frame_size = 0;
|
||||
int databuf_offset = 0;
|
||||
int risc_program_size = 0;
|
||||
int risc_flag = RISC_CNT_RESET;
|
||||
unsigned int bottom_offset = bpl;
|
||||
dma_addr_t risc_phys_jump_addr;
|
||||
|
||||
if (dev->_isNTSC_ch2) {
|
||||
odd_num_lines = singlefield_lines + 1;
|
||||
risc_program_size = FRAME1_VID_PROG_SIZE;
|
||||
if (bpl == Y411_LINE_SZ)
|
||||
frame_size = FRAME_SIZE_NTSC_Y411;
|
||||
else
|
||||
frame_size = FRAME_SIZE_NTSC_Y422;
|
||||
} else {
|
||||
risc_program_size = PAL_VID_PROG_SIZE;
|
||||
if (bpl == Y411_LINE_SZ)
|
||||
frame_size = FRAME_SIZE_PAL_Y411;
|
||||
else
|
||||
frame_size = FRAME_SIZE_PAL_Y422;
|
||||
}
|
||||
|
||||
/* Virtual address of Risc buffer program */
|
||||
rp = dev->_dma_virt_addr_ch2;
|
||||
|
||||
for (frame = 0; frame < NUM_FRAMES; frame++) {
|
||||
databuf_offset = frame_size * frame;
|
||||
|
||||
if (UNSET != top_offset) {
|
||||
fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE;
|
||||
rp = cx25821_risc_field_upstream_ch2(dev, rp,
|
||||
dev->_data_buf_phys_addr_ch2 + databuf_offset,
|
||||
top_offset, 0, bpl, odd_num_lines, fifo_enable,
|
||||
ODD_FIELD);
|
||||
}
|
||||
|
||||
fifo_enable = FIFO_DISABLE;
|
||||
|
||||
/* Even field */
|
||||
rp = cx25821_risc_field_upstream_ch2(dev, rp,
|
||||
dev->_data_buf_phys_addr_ch2 + databuf_offset,
|
||||
bottom_offset, 0x200, bpl, singlefield_lines,
|
||||
fifo_enable, EVEN_FIELD);
|
||||
|
||||
if (frame == 0) {
|
||||
risc_flag = RISC_CNT_RESET;
|
||||
risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2 +
|
||||
risc_program_size;
|
||||
} else {
|
||||
risc_flag = RISC_CNT_INC;
|
||||
risc_phys_jump_addr = dev->_dma_phys_start_addr_ch2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop to 2ndFrameRISC or to Start of
|
||||
* Risc program & generate IRQ
|
||||
*/
|
||||
*(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | risc_flag);
|
||||
*(rp++) = cpu_to_le32(risc_phys_jump_addr);
|
||||
*(rp++) = cpu_to_le32(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
|
||||
{
|
||||
struct sram_channel *sram_ch =
|
||||
dev->channels[VID_UPSTREAM_SRAM_CHANNEL_J].sram_channels;
|
||||
u32 tmp = 0;
|
||||
|
||||
if (!dev->_is_running_ch2) {
|
||||
pr_info("No video file is currently running so return!\n");
|
||||
return;
|
||||
}
|
||||
/* Disable RISC interrupts */
|
||||
tmp = cx_read(sram_ch->int_msk);
|
||||
cx_write(sram_ch->int_msk, tmp & ~_intr_msk);
|
||||
|
||||
/* Turn OFF risc and fifo */
|
||||
tmp = cx_read(sram_ch->dma_ctl);
|
||||
cx_write(sram_ch->dma_ctl, tmp & ~(FLD_VID_FIFO_EN | FLD_VID_RISC_EN));
|
||||
|
||||
/* Clear data buffer memory */
|
||||
if (dev->_data_buf_virt_addr_ch2)
|
||||
memset(dev->_data_buf_virt_addr_ch2, 0,
|
||||
dev->_data_buf_size_ch2);
|
||||
|
||||
dev->_is_running_ch2 = 0;
|
||||
dev->_is_first_frame_ch2 = 0;
|
||||
dev->_frame_count_ch2 = 0;
|
||||
dev->_file_status_ch2 = END_OF_FILE;
|
||||
|
||||
kfree(dev->_irq_queues_ch2);
|
||||
dev->_irq_queues_ch2 = NULL;
|
||||
|
||||
kfree(dev->_filename_ch2);
|
||||
|
||||
tmp = cx_read(VID_CH_MODE_SEL);
|
||||
cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
|
||||
}
|
||||
|
||||
void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev)
|
||||
{
|
||||
if (dev->_is_running_ch2)
|
||||
cx25821_stop_upstream_video_ch2(dev);
|
||||
|
||||
if (dev->_dma_virt_addr_ch2) {
|
||||
pci_free_consistent(dev->pci, dev->_risc_size_ch2,
|
||||
dev->_dma_virt_addr_ch2,
|
||||
dev->_dma_phys_addr_ch2);
|
||||
dev->_dma_virt_addr_ch2 = NULL;
|
||||
}
|
||||
|
||||
if (dev->_data_buf_virt_addr_ch2) {
|
||||
pci_free_consistent(dev->pci, dev->_data_buf_size_ch2,
|
||||
dev->_data_buf_virt_addr_ch2,
|
||||
dev->_data_buf_phys_addr_ch2);
|
||||
dev->_data_buf_virt_addr_ch2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int cx25821_get_frame_ch2(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
{
|
||||
struct file *myfile;
|
||||
int frame_index_temp = dev->_frame_index_ch2;
|
||||
int i = 0;
|
||||
int line_size = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ?
|
||||
Y411_LINE_SZ : Y422_LINE_SZ;
|
||||
int frame_size = 0;
|
||||
int frame_offset = 0;
|
||||
ssize_t vfs_read_retval = 0;
|
||||
char mybuf[line_size];
|
||||
loff_t file_offset;
|
||||
loff_t pos;
|
||||
mm_segment_t old_fs;
|
||||
|
||||
if (dev->_file_status_ch2 == END_OF_FILE)
|
||||
return 0;
|
||||
|
||||
if (dev->_isNTSC_ch2) {
|
||||
frame_size = (line_size == Y411_LINE_SZ) ?
|
||||
FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
|
||||
} else {
|
||||
frame_size = (line_size == Y411_LINE_SZ) ?
|
||||
FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
|
||||
}
|
||||
|
||||
frame_offset = (frame_index_temp > 0) ? frame_size : 0;
|
||||
file_offset = dev->_frame_count_ch2 * frame_size;
|
||||
|
||||
myfile = filp_open(dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0);
|
||||
if (IS_ERR(myfile)) {
|
||||
const int open_errno = -PTR_ERR(myfile);
|
||||
pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
|
||||
__func__, dev->_filename_ch2, open_errno);
|
||||
return PTR_ERR(myfile);
|
||||
} else {
|
||||
if (!(myfile->f_op)) {
|
||||
pr_err("%s(): File has no file operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!myfile->f_op->read) {
|
||||
pr_err("%s(): File has no READ operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pos = myfile->f_pos;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
for (i = 0; i < dev->_lines_count_ch2; i++) {
|
||||
pos = file_offset;
|
||||
|
||||
vfs_read_retval = vfs_read(myfile, mybuf, line_size,
|
||||
&pos);
|
||||
|
||||
if (vfs_read_retval > 0 && vfs_read_retval == line_size
|
||||
&& dev->_data_buf_virt_addr_ch2 != NULL) {
|
||||
memcpy((void *)(dev->_data_buf_virt_addr_ch2 +
|
||||
frame_offset / 4), mybuf,
|
||||
vfs_read_retval);
|
||||
}
|
||||
|
||||
file_offset += vfs_read_retval;
|
||||
frame_offset += vfs_read_retval;
|
||||
|
||||
if (vfs_read_retval < line_size) {
|
||||
pr_info("Done: exit %s() since no more bytes to read from Video file\n",
|
||||
__func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
dev->_frame_count_ch2++;
|
||||
|
||||
dev->_file_status_ch2 = (vfs_read_retval == line_size) ?
|
||||
IN_PROGRESS : END_OF_FILE;
|
||||
|
||||
set_fs(old_fs);
|
||||
filp_close(myfile, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cx25821_vidups_handler_ch2(struct work_struct *work)
|
||||
{
|
||||
struct cx25821_dev *dev = container_of(work, struct cx25821_dev,
|
||||
_irq_work_entry_ch2);
|
||||
|
||||
if (!dev) {
|
||||
pr_err("ERROR %s(): since container_of(work_struct) FAILED!\n",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
cx25821_get_frame_ch2(dev, dev->channels[dev->
|
||||
_channel2_upstream_select].sram_channels);
|
||||
}
|
||||
|
||||
static int cx25821_openfile_ch2(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
{
|
||||
struct file *myfile;
|
||||
int i = 0, j = 0;
|
||||
int line_size = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ?
|
||||
Y411_LINE_SZ : Y422_LINE_SZ;
|
||||
ssize_t vfs_read_retval = 0;
|
||||
char mybuf[line_size];
|
||||
loff_t pos;
|
||||
loff_t offset = (unsigned long)0;
|
||||
mm_segment_t old_fs;
|
||||
|
||||
myfile = filp_open(dev->_filename_ch2, O_RDONLY | O_LARGEFILE, 0);
|
||||
|
||||
if (IS_ERR(myfile)) {
|
||||
const int open_errno = -PTR_ERR(myfile);
|
||||
pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
|
||||
__func__, dev->_filename_ch2, open_errno);
|
||||
return PTR_ERR(myfile);
|
||||
} else {
|
||||
if (!(myfile->f_op)) {
|
||||
pr_err("%s(): File has no file operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!myfile->f_op->read) {
|
||||
pr_err("%s(): File has no READ operations registered! Returning\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pos = myfile->f_pos;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
for (j = 0; j < NUM_FRAMES; j++) {
|
||||
for (i = 0; i < dev->_lines_count_ch2; i++) {
|
||||
pos = offset;
|
||||
|
||||
vfs_read_retval = vfs_read(myfile, mybuf,
|
||||
line_size, &pos);
|
||||
|
||||
if (vfs_read_retval > 0 &&
|
||||
vfs_read_retval == line_size &&
|
||||
dev->_data_buf_virt_addr_ch2 != NULL) {
|
||||
memcpy((void *)(dev->
|
||||
_data_buf_virt_addr_ch2
|
||||
+ offset / 4), mybuf,
|
||||
vfs_read_retval);
|
||||
}
|
||||
|
||||
offset += vfs_read_retval;
|
||||
|
||||
if (vfs_read_retval < line_size) {
|
||||
pr_info("Done: exit %s() since no more bytes to read from Video file\n",
|
||||
__func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
dev->_frame_count_ch2++;
|
||||
|
||||
if (vfs_read_retval < line_size)
|
||||
break;
|
||||
}
|
||||
|
||||
dev->_file_status_ch2 = (vfs_read_retval == line_size) ?
|
||||
IN_PROGRESS : END_OF_FILE;
|
||||
|
||||
set_fs(old_fs);
|
||||
myfile->f_pos = 0;
|
||||
filp_close(myfile, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch,
|
||||
int bpl)
|
||||
{
|
||||
int ret = 0;
|
||||
dma_addr_t dma_addr;
|
||||
dma_addr_t data_dma_addr;
|
||||
|
||||
if (dev->_dma_virt_addr_ch2 != NULL) {
|
||||
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size_ch2,
|
||||
dev->_dma_virt_addr_ch2,
|
||||
dev->_dma_phys_addr_ch2);
|
||||
}
|
||||
|
||||
dev->_dma_virt_addr_ch2 = pci_alloc_consistent(dev->pci,
|
||||
dev->upstream_riscbuf_size_ch2, &dma_addr);
|
||||
dev->_dma_virt_start_addr_ch2 = dev->_dma_virt_addr_ch2;
|
||||
dev->_dma_phys_start_addr_ch2 = dma_addr;
|
||||
dev->_dma_phys_addr_ch2 = dma_addr;
|
||||
dev->_risc_size_ch2 = dev->upstream_riscbuf_size_ch2;
|
||||
|
||||
if (!dev->_dma_virt_addr_ch2) {
|
||||
pr_err("FAILED to allocate memory for Risc buffer! Returning\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Iniitize at this address until n bytes to 0 */
|
||||
memset(dev->_dma_virt_addr_ch2, 0, dev->_risc_size_ch2);
|
||||
|
||||
if (dev->_data_buf_virt_addr_ch2 != NULL) {
|
||||
pci_free_consistent(dev->pci, dev->upstream_databuf_size_ch2,
|
||||
dev->_data_buf_virt_addr_ch2,
|
||||
dev->_data_buf_phys_addr_ch2);
|
||||
}
|
||||
/* For Video Data buffer allocation */
|
||||
dev->_data_buf_virt_addr_ch2 = pci_alloc_consistent(dev->pci,
|
||||
dev->upstream_databuf_size_ch2, &data_dma_addr);
|
||||
dev->_data_buf_phys_addr_ch2 = data_dma_addr;
|
||||
dev->_data_buf_size_ch2 = dev->upstream_databuf_size_ch2;
|
||||
|
||||
if (!dev->_data_buf_virt_addr_ch2) {
|
||||
pr_err("FAILED to allocate memory for data buffer! Returning\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Initialize at this address until n bytes to 0 */
|
||||
memset(dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_ch2);
|
||||
|
||||
ret = cx25821_openfile_ch2(dev, sram_ch);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Creating RISC programs */
|
||||
ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl,
|
||||
dev->_lines_count_ch2);
|
||||
if (ret < 0) {
|
||||
pr_info("Failed creating Video Upstream Risc programs!\n");
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev,
|
||||
int chan_num,
|
||||
u32 status)
|
||||
{
|
||||
u32 int_msk_tmp;
|
||||
struct sram_channel *channel = dev->channels[chan_num].sram_channels;
|
||||
int singlefield_lines = NTSC_FIELD_HEIGHT;
|
||||
int line_size_in_bytes = Y422_LINE_SZ;
|
||||
int odd_risc_prog_size = 0;
|
||||
dma_addr_t risc_phys_jump_addr;
|
||||
__le32 *rp;
|
||||
|
||||
if (status & FLD_VID_SRC_RISC1) {
|
||||
/* We should only process one program per call */
|
||||
u32 prog_cnt = cx_read(channel->gpcnt);
|
||||
|
||||
/*
|
||||
* Since we've identified our IRQ, clear our bits from the
|
||||
* interrupt mask and interrupt status registers
|
||||
*/
|
||||
int_msk_tmp = cx_read(channel->int_msk);
|
||||
cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk);
|
||||
cx_write(channel->int_stat, _intr_msk);
|
||||
|
||||
spin_lock(&dev->slock);
|
||||
|
||||
dev->_frame_index_ch2 = prog_cnt;
|
||||
|
||||
queue_work(dev->_irq_queues_ch2, &dev->_irq_work_entry_ch2);
|
||||
|
||||
if (dev->_is_first_frame_ch2) {
|
||||
dev->_is_first_frame_ch2 = 0;
|
||||
|
||||
if (dev->_isNTSC_ch2) {
|
||||
singlefield_lines += 1;
|
||||
odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE;
|
||||
} else {
|
||||
singlefield_lines = PAL_FIELD_HEIGHT;
|
||||
odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE;
|
||||
}
|
||||
|
||||
if (dev->_dma_virt_start_addr_ch2 != NULL) {
|
||||
if (dev->_pixel_format_ch2 == PIXEL_FRMT_411)
|
||||
line_size_in_bytes = Y411_LINE_SZ;
|
||||
else
|
||||
line_size_in_bytes = Y422_LINE_SZ;
|
||||
risc_phys_jump_addr =
|
||||
dev->_dma_phys_start_addr_ch2 +
|
||||
odd_risc_prog_size;
|
||||
|
||||
rp = cx25821_update_riscprogram_ch2(dev,
|
||||
dev->_dma_virt_start_addr_ch2,
|
||||
TOP_OFFSET, line_size_in_bytes,
|
||||
0x0, singlefield_lines,
|
||||
FIFO_DISABLE, ODD_FIELD);
|
||||
|
||||
/* Jump to Even Risc program of 1st Frame */
|
||||
*(rp++) = cpu_to_le32(RISC_JUMP);
|
||||
*(rp++) = cpu_to_le32(risc_phys_jump_addr);
|
||||
*(rp++) = cpu_to_le32(0);
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock(&dev->slock);
|
||||
}
|
||||
|
||||
if (dev->_file_status_ch2 == END_OF_FILE) {
|
||||
pr_info("EOF Channel 2 Framecount = %d\n",
|
||||
dev->_frame_count_ch2);
|
||||
return -1;
|
||||
}
|
||||
/* ElSE, set the interrupt mask register, re-enable irq. */
|
||||
int_msk_tmp = cx_read(channel->int_msk);
|
||||
cx_write(channel->int_msk, int_msk_tmp |= _intr_msk);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id)
|
||||
{
|
||||
struct cx25821_dev *dev = dev_id;
|
||||
u32 vid_status;
|
||||
int handled = 0;
|
||||
int channel_num = 0;
|
||||
struct sram_channel *sram_ch;
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
|
||||
channel_num = VID_UPSTREAM_SRAM_CHANNEL_J;
|
||||
sram_ch = dev->channels[channel_num].sram_channels;
|
||||
|
||||
vid_status = cx_read(sram_ch->int_stat);
|
||||
|
||||
/* Only deal with our interrupt */
|
||||
if (vid_status)
|
||||
handled = cx25821_video_upstream_irq_ch2(dev, channel_num,
|
||||
vid_status);
|
||||
|
||||
if (handled < 0)
|
||||
cx25821_stop_upstream_video_ch2(dev);
|
||||
else
|
||||
handled += handled;
|
||||
|
||||
return IRQ_RETVAL(handled);
|
||||
}
|
||||
|
||||
static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch, int pix_format)
|
||||
{
|
||||
int width = WIDTH_D1;
|
||||
int height = dev->_lines_count_ch2;
|
||||
int num_lines, odd_num_lines;
|
||||
u32 value;
|
||||
int vip_mode = PIXEL_ENGINE_VIP1;
|
||||
|
||||
value = ((pix_format & 0x3) << 12) | (vip_mode & 0x7);
|
||||
value &= 0xFFFFFFEF;
|
||||
value |= dev->_isNTSC_ch2 ? 0 : 0x10;
|
||||
cx_write(ch->vid_fmt_ctl, value);
|
||||
|
||||
/*
|
||||
* set number of active pixels in each line. Default is 720
|
||||
* pixels in both NTSC and PAL format
|
||||
*/
|
||||
cx_write(ch->vid_active_ctl1, width);
|
||||
|
||||
num_lines = (height / 2) & 0x3FF;
|
||||
odd_num_lines = num_lines;
|
||||
|
||||
if (dev->_isNTSC_ch2)
|
||||
odd_num_lines += 1;
|
||||
|
||||
value = (num_lines << 16) | odd_num_lines;
|
||||
|
||||
/* set number of active lines in field 0 (top) and field 1 (bottom) */
|
||||
cx_write(ch->vid_active_ctl2, value);
|
||||
|
||||
cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3);
|
||||
}
|
||||
|
||||
static int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
{
|
||||
u32 tmp = 0;
|
||||
int err = 0;
|
||||
|
||||
/*
|
||||
* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface
|
||||
* for channel A-C
|
||||
*/
|
||||
tmp = cx_read(VID_CH_MODE_SEL);
|
||||
cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF);
|
||||
|
||||
/*
|
||||
* Set the physical start address of the RISC program in the initial
|
||||
* program counter(IPC) member of the cmds.
|
||||
*/
|
||||
cx_write(sram_ch->cmds_start + 0, dev->_dma_phys_addr_ch2);
|
||||
cx_write(sram_ch->cmds_start + 4, 0); /* Risc IPC High 64 bits 63-32 */
|
||||
|
||||
/* reset counter */
|
||||
cx_write(sram_ch->gpcnt_ctl, 3);
|
||||
|
||||
/* Clear our bits from the interrupt status register. */
|
||||
cx_write(sram_ch->int_stat, _intr_msk);
|
||||
|
||||
/* Set the interrupt mask register, enable irq. */
|
||||
cx_set(PCI_INT_MSK, cx_read(PCI_INT_MSK) | (1 << sram_ch->irq_bit));
|
||||
tmp = cx_read(sram_ch->int_msk);
|
||||
cx_write(sram_ch->int_msk, tmp |= _intr_msk);
|
||||
|
||||
err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2,
|
||||
IRQF_SHARED, dev->name, dev);
|
||||
if (err < 0) {
|
||||
pr_err("%s: can't get upstream IRQ %d\n",
|
||||
dev->name, dev->pci->irq);
|
||||
goto fail_irq;
|
||||
}
|
||||
/* Start the DMA engine */
|
||||
tmp = cx_read(sram_ch->dma_ctl);
|
||||
cx_set(sram_ch->dma_ctl, tmp | FLD_VID_RISC_EN);
|
||||
|
||||
dev->_is_running_ch2 = 1;
|
||||
dev->_is_first_frame_ch2 = 1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail_irq:
|
||||
cx25821_dev_unregister(dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select,
|
||||
int pixel_format)
|
||||
{
|
||||
struct sram_channel *sram_ch;
|
||||
u32 tmp;
|
||||
int err = 0;
|
||||
int data_frame_size = 0;
|
||||
int risc_buffer_size = 0;
|
||||
|
||||
if (dev->_is_running_ch2) {
|
||||
pr_info("Video Channel is still running so return!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev->_channel2_upstream_select = channel_select;
|
||||
sram_ch = dev->channels[channel_select].sram_channels;
|
||||
|
||||
INIT_WORK(&dev->_irq_work_entry_ch2, cx25821_vidups_handler_ch2);
|
||||
dev->_irq_queues_ch2 =
|
||||
create_singlethread_workqueue("cx25821_workqueue2");
|
||||
|
||||
if (!dev->_irq_queues_ch2) {
|
||||
pr_err("create_singlethread_workqueue() for Video FAILED!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
/*
|
||||
* 656/VIP SRC Upstream Channel I & J and 7 -
|
||||
* Host Bus Interface for channel A-C
|
||||
*/
|
||||
tmp = cx_read(VID_CH_MODE_SEL);
|
||||
cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF);
|
||||
|
||||
dev->_is_running_ch2 = 0;
|
||||
dev->_frame_count_ch2 = 0;
|
||||
dev->_file_status_ch2 = RESET_STATUS;
|
||||
dev->_lines_count_ch2 = dev->_isNTSC_ch2 ? 480 : 576;
|
||||
dev->_pixel_format_ch2 = pixel_format;
|
||||
dev->_line_size_ch2 = (dev->_pixel_format_ch2 == PIXEL_FRMT_422) ?
|
||||
(WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2;
|
||||
data_frame_size = dev->_isNTSC_ch2 ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ;
|
||||
risc_buffer_size = dev->_isNTSC_ch2 ?
|
||||
NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE;
|
||||
|
||||
if (dev->input_filename_ch2)
|
||||
dev->_filename_ch2 = kstrdup(dev->input_filename_ch2,
|
||||
GFP_KERNEL);
|
||||
else
|
||||
dev->_filename_ch2 = kstrdup(dev->_defaultname_ch2,
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!dev->_filename_ch2) {
|
||||
err = -ENOENT;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Default if filename is empty string */
|
||||
if (strcmp(dev->_filename_ch2, "") == 0) {
|
||||
if (dev->_isNTSC_ch2) {
|
||||
dev->_filename_ch2 = (dev->_pixel_format_ch2 ==
|
||||
PIXEL_FRMT_411) ? "/root/vid411.yuv" :
|
||||
"/root/vidtest.yuv";
|
||||
} else {
|
||||
dev->_filename_ch2 = (dev->_pixel_format_ch2 ==
|
||||
PIXEL_FRMT_411) ? "/root/pal411.yuv" :
|
||||
"/root/pal422.yuv";
|
||||
}
|
||||
}
|
||||
|
||||
err = cx25821_sram_channel_setup_upstream(dev, sram_ch,
|
||||
dev->_line_size_ch2, 0);
|
||||
|
||||
/* setup fifo + format */
|
||||
cx25821_set_pixelengine_ch2(dev, sram_ch, dev->_pixel_format_ch2);
|
||||
|
||||
dev->upstream_riscbuf_size_ch2 = risc_buffer_size * 2;
|
||||
dev->upstream_databuf_size_ch2 = data_frame_size * 2;
|
||||
|
||||
/* Allocating buffers and prepare RISC program */
|
||||
err = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch,
|
||||
dev->_line_size_ch2);
|
||||
if (err < 0) {
|
||||
pr_err("%s: Failed to set up Video upstream buffers!\n",
|
||||
dev->name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cx25821_start_video_dma_upstream_ch2(dev, sram_ch);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
cx25821_dev_unregister(dev);
|
||||
|
||||
return err;
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Driver for the Conexant CX25821 PCIe bridge
|
||||
*
|
||||
* Copyright (C) 2009 Conexant Systems Inc.
|
||||
* Authors <hiep.huynh@conexant.com>, <shu.lin@conexant.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
#define OPEN_FILE_1 0
|
||||
#define NUM_PROGS 8
|
||||
#define NUM_FRAMES 2
|
||||
#define ODD_FIELD 0
|
||||
#define EVEN_FIELD 1
|
||||
#define TOP_OFFSET 0
|
||||
#define FIFO_DISABLE 0
|
||||
#define FIFO_ENABLE 1
|
||||
#define TEST_FRAMES 5
|
||||
#define END_OF_FILE 0
|
||||
#define IN_PROGRESS 1
|
||||
#define RESET_STATUS -1
|
||||
#define NUM_NO_OPS 5
|
||||
|
||||
/* PAL and NTSC line sizes and number of lines. */
|
||||
#define WIDTH_D1 720
|
||||
#define NTSC_LINES_PER_FRAME 480
|
||||
#define PAL_LINES_PER_FRAME 576
|
||||
#define PAL_LINE_SZ 1440
|
||||
#define Y422_LINE_SZ 1440
|
||||
#define Y411_LINE_SZ 1080
|
||||
#define NTSC_FIELD_HEIGHT 240
|
||||
#define NTSC_ODD_FLD_LINES 241
|
||||
#define PAL_FIELD_HEIGHT 288
|
||||
|
||||
#define FRAME_SIZE_NTSC_Y422 (NTSC_LINES_PER_FRAME * Y422_LINE_SZ)
|
||||
#define FRAME_SIZE_NTSC_Y411 (NTSC_LINES_PER_FRAME * Y411_LINE_SZ)
|
||||
#define FRAME_SIZE_PAL_Y422 (PAL_LINES_PER_FRAME * Y422_LINE_SZ)
|
||||
#define FRAME_SIZE_PAL_Y411 (PAL_LINES_PER_FRAME * Y411_LINE_SZ)
|
||||
|
||||
#define NTSC_DATA_BUF_SZ (Y422_LINE_SZ * NTSC_LINES_PER_FRAME)
|
||||
#define PAL_DATA_BUF_SZ (Y422_LINE_SZ * PAL_LINES_PER_FRAME)
|
||||
|
||||
#define RISC_WRITECR_INSTRUCTION_SIZE 16
|
||||
#define RISC_SYNC_INSTRUCTION_SIZE 4
|
||||
#define JUMP_INSTRUCTION_SIZE 12
|
||||
#define MAXSIZE_NO_OPS 36
|
||||
#define DWORD_SIZE 4
|
||||
|
||||
#define USE_RISC_NOOP_VIDEO 1
|
||||
|
||||
#ifdef USE_RISC_NOOP_VIDEO
|
||||
#define PAL_US_VID_PROG_SIZE \
|
||||
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE + RISC_SYNC_INSTRUCTION_SIZE + \
|
||||
NUM_NO_OPS * DWORD_SIZE)
|
||||
|
||||
#define PAL_RISC_BUF_SIZE (2 * PAL_US_VID_PROG_SIZE)
|
||||
|
||||
#define PAL_VID_PROG_SIZE \
|
||||
((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \
|
||||
2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
|
||||
JUMP_INSTRUCTION_SIZE + 2 * NUM_NO_OPS * DWORD_SIZE)
|
||||
|
||||
#define ODD_FLD_PAL_PROG_SIZE \
|
||||
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
|
||||
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
|
||||
NUM_NO_OPS * DWORD_SIZE)
|
||||
|
||||
#define NTSC_US_VID_PROG_SIZE \
|
||||
((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \
|
||||
NUM_NO_OPS * DWORD_SIZE)
|
||||
|
||||
#define NTSC_RISC_BUF_SIZE \
|
||||
(2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE))
|
||||
|
||||
#define FRAME1_VID_PROG_SIZE \
|
||||
((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \
|
||||
3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + \
|
||||
2 * NUM_NO_OPS * DWORD_SIZE)
|
||||
|
||||
#define ODD_FLD_NTSC_PROG_SIZE \
|
||||
(NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \
|
||||
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
|
||||
NUM_NO_OPS * DWORD_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef USE_RISC_NOOP_VIDEO
|
||||
#define PAL_US_VID_PROG_SIZE \
|
||||
((PAL_FIELD_HEIGHT + 1) * 3 * DWORD_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE)
|
||||
|
||||
#define PAL_RISC_BUF_SIZE \
|
||||
(2 * (RISC_SYNC_INSTRUCTION_SIZE + PAL_US_VID_PROG_SIZE))
|
||||
|
||||
#define PAL_VID_PROG_SIZE \
|
||||
((PAL_FIELD_HEIGHT * 2) * 3 * DWORD_SIZE + \
|
||||
2 * RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
|
||||
JUMP_INSTRUCTION_SIZE)
|
||||
|
||||
#define ODD_FLD_PAL_PROG_SIZE \
|
||||
(PAL_FIELD_HEIGHT * 3 * DWORD_SIZE + \
|
||||
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE)
|
||||
|
||||
#define ODD_FLD_NTSC_PROG_SIZE \
|
||||
(NTSC_ODD_FLD_LINES * 3 * DWORD_SIZE + \
|
||||
RISC_SYNC_INSTRUCTION_SIZE + RISC_WRITECR_INSTRUCTION_SIZE)
|
||||
|
||||
#define NTSC_US_VID_PROG_SIZE \
|
||||
((NTSC_ODD_FLD_LINES + 1) * 3 * DWORD_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
|
||||
|
||||
#define NTSC_RISC_BUF_SIZE \
|
||||
(2 * (RISC_SYNC_INSTRUCTION_SIZE + NTSC_US_VID_PROG_SIZE))
|
||||
|
||||
#define FRAME1_VID_PROG_SIZE \
|
||||
((NTSC_ODD_FLD_LINES + NTSC_FIELD_HEIGHT) * \
|
||||
3 * DWORD_SIZE + 2 * RISC_SYNC_INSTRUCTION_SIZE + \
|
||||
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
|
||||
|
||||
#endif
|
@ -25,16 +25,11 @@
|
||||
#include "cx25821-video.h"
|
||||
#include "cx25821-video-upstream.h"
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/syscalls.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
|
||||
MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
|
||||
@ -44,7 +39,7 @@ static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC |
|
||||
FLD_VID_SRC_OPC_ERR;
|
||||
|
||||
int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc)
|
||||
{
|
||||
unsigned int i, lines;
|
||||
@ -97,12 +92,13 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __le32 *cx25821_update_riscprogram(struct cx25821_dev *dev,
|
||||
static __le32 *cx25821_update_riscprogram(struct cx25821_channel *chan,
|
||||
__le32 *rp, unsigned int offset,
|
||||
unsigned int bpl, u32 sync_line,
|
||||
unsigned int lines, int fifo_enable,
|
||||
int field_type)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
unsigned int line, i;
|
||||
int dist_betwn_starts = bpl * 2;
|
||||
|
||||
@ -116,11 +112,11 @@ static __le32 *cx25821_update_riscprogram(struct cx25821_dev *dev,
|
||||
/* scan lines */
|
||||
for (line = 0; line < lines; line++) {
|
||||
*(rp++) = cpu_to_le32(RISC_READ | RISC_SOL | RISC_EOL | bpl);
|
||||
*(rp++) = cpu_to_le32(dev->_data_buf_phys_addr + offset);
|
||||
*(rp++) = cpu_to_le32(out->_data_buf_phys_addr + offset);
|
||||
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
||||
|
||||
if ((lines <= NTSC_FIELD_HEIGHT)
|
||||
|| (line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC)) {
|
||||
|| (line < (NTSC_FIELD_HEIGHT - 1)) || !(out->is_60hz)) {
|
||||
offset += dist_betwn_starts;
|
||||
}
|
||||
}
|
||||
@ -128,15 +124,15 @@ static __le32 *cx25821_update_riscprogram(struct cx25821_dev *dev,
|
||||
return rp;
|
||||
}
|
||||
|
||||
static __le32 *cx25821_risc_field_upstream(struct cx25821_dev *dev, __le32 * rp,
|
||||
static __le32 *cx25821_risc_field_upstream(struct cx25821_channel *chan, __le32 *rp,
|
||||
dma_addr_t databuf_phys_addr,
|
||||
unsigned int offset, u32 sync_line,
|
||||
unsigned int bpl, unsigned int lines,
|
||||
int fifo_enable, int field_type)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
unsigned int line, i;
|
||||
struct sram_channel *sram_ch =
|
||||
dev->channels[dev->_channel_upstream_select].sram_channels;
|
||||
const struct sram_channel *sram_ch = chan->sram_channels;
|
||||
int dist_betwn_starts = bpl * 2;
|
||||
|
||||
/* sync instruction */
|
||||
@ -155,7 +151,7 @@ static __le32 *cx25821_risc_field_upstream(struct cx25821_dev *dev, __le32 * rp,
|
||||
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
||||
|
||||
if ((lines <= NTSC_FIELD_HEIGHT)
|
||||
|| (line < (NTSC_FIELD_HEIGHT - 1)) || !(dev->_isNTSC))
|
||||
|| (line < (NTSC_FIELD_HEIGHT - 1)) || !(out->is_60hz))
|
||||
/* to skip the other field line */
|
||||
offset += dist_betwn_starts;
|
||||
|
||||
@ -173,11 +169,12 @@ static __le32 *cx25821_risc_field_upstream(struct cx25821_dev *dev, __le32 * rp,
|
||||
return rp;
|
||||
}
|
||||
|
||||
static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
|
||||
static int cx25821_risc_buffer_upstream(struct cx25821_channel *chan,
|
||||
struct pci_dev *pci,
|
||||
unsigned int top_offset,
|
||||
unsigned int bpl, unsigned int lines)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
__le32 *rp;
|
||||
int fifo_enable = 0;
|
||||
/* get line count for single field */
|
||||
@ -191,7 +188,7 @@ static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
|
||||
unsigned int bottom_offset = bpl;
|
||||
dma_addr_t risc_phys_jump_addr;
|
||||
|
||||
if (dev->_isNTSC) {
|
||||
if (out->is_60hz) {
|
||||
odd_num_lines = singlefield_lines + 1;
|
||||
risc_program_size = FRAME1_VID_PROG_SIZE;
|
||||
frame_size = (bpl == Y411_LINE_SZ) ?
|
||||
@ -203,15 +200,15 @@ static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
|
||||
}
|
||||
|
||||
/* Virtual address of Risc buffer program */
|
||||
rp = dev->_dma_virt_addr;
|
||||
rp = out->_dma_virt_addr;
|
||||
|
||||
for (frame = 0; frame < NUM_FRAMES; frame++) {
|
||||
databuf_offset = frame_size * frame;
|
||||
|
||||
if (UNSET != top_offset) {
|
||||
fifo_enable = (frame == 0) ? FIFO_ENABLE : FIFO_DISABLE;
|
||||
rp = cx25821_risc_field_upstream(dev, rp,
|
||||
dev->_data_buf_phys_addr +
|
||||
rp = cx25821_risc_field_upstream(chan, rp,
|
||||
out->_data_buf_phys_addr +
|
||||
databuf_offset, top_offset, 0, bpl,
|
||||
odd_num_lines, fifo_enable, ODD_FIELD);
|
||||
}
|
||||
@ -219,18 +216,18 @@ static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
|
||||
fifo_enable = FIFO_DISABLE;
|
||||
|
||||
/* Even Field */
|
||||
rp = cx25821_risc_field_upstream(dev, rp,
|
||||
dev->_data_buf_phys_addr +
|
||||
rp = cx25821_risc_field_upstream(chan, rp,
|
||||
out->_data_buf_phys_addr +
|
||||
databuf_offset, bottom_offset,
|
||||
0x200, bpl, singlefield_lines,
|
||||
fifo_enable, EVEN_FIELD);
|
||||
|
||||
if (frame == 0) {
|
||||
risc_flag = RISC_CNT_RESET;
|
||||
risc_phys_jump_addr = dev->_dma_phys_start_addr +
|
||||
risc_phys_jump_addr = out->_dma_phys_start_addr +
|
||||
risc_program_size;
|
||||
} else {
|
||||
risc_phys_jump_addr = dev->_dma_phys_start_addr;
|
||||
risc_phys_jump_addr = out->_dma_phys_start_addr;
|
||||
risc_flag = RISC_CNT_INC;
|
||||
}
|
||||
|
||||
@ -245,16 +242,21 @@ static int cx25821_risc_buffer_upstream(struct cx25821_dev *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
|
||||
void cx25821_stop_upstream_video(struct cx25821_channel *chan)
|
||||
{
|
||||
struct sram_channel *sram_ch =
|
||||
dev->channels[VID_UPSTREAM_SRAM_CHANNEL_I].sram_channels;
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
const struct sram_channel *sram_ch = chan->sram_channels;
|
||||
u32 tmp = 0;
|
||||
|
||||
if (!dev->_is_running) {
|
||||
if (!out->_is_running) {
|
||||
pr_info("No video file is currently running so return!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the interrupt mask register, disable irq. */
|
||||
cx_set(PCI_INT_MSK, cx_read(PCI_INT_MSK) & ~(1 << sram_ch->irq_bit));
|
||||
|
||||
/* Disable RISC interrupts */
|
||||
tmp = cx_read(sram_ch->int_msk);
|
||||
cx_write(sram_ch->int_msk, tmp & ~_intr_msk);
|
||||
@ -263,283 +265,133 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
|
||||
tmp = cx_read(sram_ch->dma_ctl);
|
||||
cx_write(sram_ch->dma_ctl, tmp & ~(FLD_VID_FIFO_EN | FLD_VID_RISC_EN));
|
||||
|
||||
free_irq(dev->pci->irq, chan);
|
||||
|
||||
/* Clear data buffer memory */
|
||||
if (dev->_data_buf_virt_addr)
|
||||
memset(dev->_data_buf_virt_addr, 0, dev->_data_buf_size);
|
||||
if (out->_data_buf_virt_addr)
|
||||
memset(out->_data_buf_virt_addr, 0, out->_data_buf_size);
|
||||
|
||||
dev->_is_running = 0;
|
||||
dev->_is_first_frame = 0;
|
||||
dev->_frame_count = 0;
|
||||
dev->_file_status = END_OF_FILE;
|
||||
|
||||
kfree(dev->_irq_queues);
|
||||
dev->_irq_queues = NULL;
|
||||
|
||||
kfree(dev->_filename);
|
||||
out->_is_running = 0;
|
||||
out->_is_first_frame = 0;
|
||||
out->_frame_count = 0;
|
||||
out->_file_status = END_OF_FILE;
|
||||
|
||||
tmp = cx_read(VID_CH_MODE_SEL);
|
||||
cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
|
||||
}
|
||||
|
||||
void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev)
|
||||
void cx25821_free_mem_upstream(struct cx25821_channel *chan)
|
||||
{
|
||||
if (dev->_is_running)
|
||||
cx25821_stop_upstream_video_ch1(dev);
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
|
||||
if (dev->_dma_virt_addr) {
|
||||
pci_free_consistent(dev->pci, dev->_risc_size,
|
||||
dev->_dma_virt_addr, dev->_dma_phys_addr);
|
||||
dev->_dma_virt_addr = NULL;
|
||||
if (out->_is_running)
|
||||
cx25821_stop_upstream_video(chan);
|
||||
|
||||
if (out->_dma_virt_addr) {
|
||||
pci_free_consistent(dev->pci, out->_risc_size,
|
||||
out->_dma_virt_addr, out->_dma_phys_addr);
|
||||
out->_dma_virt_addr = NULL;
|
||||
}
|
||||
|
||||
if (dev->_data_buf_virt_addr) {
|
||||
pci_free_consistent(dev->pci, dev->_data_buf_size,
|
||||
dev->_data_buf_virt_addr,
|
||||
dev->_data_buf_phys_addr);
|
||||
dev->_data_buf_virt_addr = NULL;
|
||||
if (out->_data_buf_virt_addr) {
|
||||
pci_free_consistent(dev->pci, out->_data_buf_size,
|
||||
out->_data_buf_virt_addr,
|
||||
out->_data_buf_phys_addr);
|
||||
out->_data_buf_virt_addr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int cx25821_get_frame(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
int cx25821_write_frame(struct cx25821_channel *chan,
|
||||
const char __user *data, size_t count)
|
||||
{
|
||||
struct file *myfile;
|
||||
int frame_index_temp = dev->_frame_index;
|
||||
int i = 0;
|
||||
int line_size = (dev->_pixel_format == PIXEL_FRMT_411) ?
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
int line_size = (out->_pixel_format == PIXEL_FRMT_411) ?
|
||||
Y411_LINE_SZ : Y422_LINE_SZ;
|
||||
int frame_size = 0;
|
||||
int frame_offset = 0;
|
||||
ssize_t vfs_read_retval = 0;
|
||||
char mybuf[line_size];
|
||||
loff_t file_offset;
|
||||
loff_t pos;
|
||||
mm_segment_t old_fs;
|
||||
int curpos = out->curpos;
|
||||
|
||||
if (dev->_file_status == END_OF_FILE)
|
||||
return 0;
|
||||
|
||||
if (dev->_isNTSC)
|
||||
if (out->is_60hz)
|
||||
frame_size = (line_size == Y411_LINE_SZ) ?
|
||||
FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
|
||||
else
|
||||
frame_size = (line_size == Y411_LINE_SZ) ?
|
||||
FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
|
||||
|
||||
frame_offset = (frame_index_temp > 0) ? frame_size : 0;
|
||||
file_offset = dev->_frame_count * frame_size;
|
||||
|
||||
myfile = filp_open(dev->_filename, O_RDONLY | O_LARGEFILE, 0);
|
||||
|
||||
if (IS_ERR(myfile)) {
|
||||
const int open_errno = -PTR_ERR(myfile);
|
||||
pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
|
||||
__func__, dev->_filename, open_errno);
|
||||
return PTR_ERR(myfile);
|
||||
} else {
|
||||
if (!(myfile->f_op)) {
|
||||
pr_err("%s(): File has no file operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!myfile->f_op->read) {
|
||||
pr_err("%s(): File has no READ operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pos = myfile->f_pos;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
for (i = 0; i < dev->_lines_count; i++) {
|
||||
pos = file_offset;
|
||||
|
||||
vfs_read_retval = vfs_read(myfile, mybuf, line_size,
|
||||
&pos);
|
||||
|
||||
if (vfs_read_retval > 0 && vfs_read_retval == line_size
|
||||
&& dev->_data_buf_virt_addr != NULL) {
|
||||
memcpy((void *)(dev->_data_buf_virt_addr +
|
||||
frame_offset / 4), mybuf,
|
||||
vfs_read_retval);
|
||||
}
|
||||
|
||||
file_offset += vfs_read_retval;
|
||||
frame_offset += vfs_read_retval;
|
||||
|
||||
if (vfs_read_retval < line_size) {
|
||||
pr_info("Done: exit %s() since no more bytes to read from Video file\n",
|
||||
__func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
dev->_frame_count++;
|
||||
|
||||
dev->_file_status = (vfs_read_retval == line_size) ?
|
||||
IN_PROGRESS : END_OF_FILE;
|
||||
|
||||
set_fs(old_fs);
|
||||
filp_close(myfile, NULL);
|
||||
if (curpos == 0) {
|
||||
out->cur_frame_index = out->_frame_index;
|
||||
if (wait_event_interruptible(out->waitq, out->cur_frame_index != out->_frame_index))
|
||||
return -EINTR;
|
||||
out->cur_frame_index = out->_frame_index;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
frame_offset = out->cur_frame_index ? frame_size : 0;
|
||||
|
||||
static void cx25821_vidups_handler(struct work_struct *work)
|
||||
{
|
||||
struct cx25821_dev *dev = container_of(work, struct cx25821_dev,
|
||||
_irq_work_entry);
|
||||
|
||||
if (!dev) {
|
||||
pr_err("ERROR %s(): since container_of(work_struct) FAILED!\n",
|
||||
__func__);
|
||||
return;
|
||||
if (frame_size - curpos < count)
|
||||
count = frame_size - curpos;
|
||||
memcpy((char *)out->_data_buf_virt_addr + frame_offset + curpos,
|
||||
data, count);
|
||||
curpos += count;
|
||||
if (curpos == frame_size) {
|
||||
out->_frame_count++;
|
||||
curpos = 0;
|
||||
}
|
||||
out->curpos = curpos;
|
||||
|
||||
cx25821_get_frame(dev, dev->channels[dev->_channel_upstream_select].
|
||||
sram_channels);
|
||||
return count;
|
||||
}
|
||||
|
||||
static int cx25821_openfile(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
{
|
||||
struct file *myfile;
|
||||
int i = 0, j = 0;
|
||||
int line_size = (dev->_pixel_format == PIXEL_FRMT_411) ?
|
||||
Y411_LINE_SZ : Y422_LINE_SZ;
|
||||
ssize_t vfs_read_retval = 0;
|
||||
char mybuf[line_size];
|
||||
loff_t pos;
|
||||
loff_t offset = (unsigned long)0;
|
||||
mm_segment_t old_fs;
|
||||
|
||||
myfile = filp_open(dev->_filename, O_RDONLY | O_LARGEFILE, 0);
|
||||
|
||||
if (IS_ERR(myfile)) {
|
||||
const int open_errno = -PTR_ERR(myfile);
|
||||
pr_err("%s(): ERROR opening file(%s) with errno = %d!\n",
|
||||
__func__, dev->_filename, open_errno);
|
||||
return PTR_ERR(myfile);
|
||||
} else {
|
||||
if (!(myfile->f_op)) {
|
||||
pr_err("%s(): File has no file operations registered!\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!myfile->f_op->read) {
|
||||
pr_err("%s(): File has no READ operations registered! Returning\n",
|
||||
__func__);
|
||||
filp_close(myfile, NULL);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
pos = myfile->f_pos;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
for (j = 0; j < NUM_FRAMES; j++) {
|
||||
for (i = 0; i < dev->_lines_count; i++) {
|
||||
pos = offset;
|
||||
|
||||
vfs_read_retval = vfs_read(myfile, mybuf,
|
||||
line_size, &pos);
|
||||
|
||||
if (vfs_read_retval > 0
|
||||
&& vfs_read_retval == line_size
|
||||
&& dev->_data_buf_virt_addr != NULL) {
|
||||
memcpy((void *)(dev->
|
||||
_data_buf_virt_addr +
|
||||
offset / 4), mybuf,
|
||||
vfs_read_retval);
|
||||
}
|
||||
|
||||
offset += vfs_read_retval;
|
||||
|
||||
if (vfs_read_retval < line_size) {
|
||||
pr_info("Done: exit %s() since no more bytes to read from Video file\n",
|
||||
__func__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
dev->_frame_count++;
|
||||
|
||||
if (vfs_read_retval < line_size)
|
||||
break;
|
||||
}
|
||||
|
||||
dev->_file_status = (vfs_read_retval == line_size) ?
|
||||
IN_PROGRESS : END_OF_FILE;
|
||||
|
||||
set_fs(old_fs);
|
||||
myfile->f_pos = 0;
|
||||
filp_close(myfile, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch,
|
||||
static int cx25821_upstream_buffer_prepare(struct cx25821_channel *chan,
|
||||
const struct sram_channel *sram_ch,
|
||||
int bpl)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
int ret = 0;
|
||||
dma_addr_t dma_addr;
|
||||
dma_addr_t data_dma_addr;
|
||||
|
||||
if (dev->_dma_virt_addr != NULL)
|
||||
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size,
|
||||
dev->_dma_virt_addr, dev->_dma_phys_addr);
|
||||
if (out->_dma_virt_addr != NULL)
|
||||
pci_free_consistent(dev->pci, out->upstream_riscbuf_size,
|
||||
out->_dma_virt_addr, out->_dma_phys_addr);
|
||||
|
||||
dev->_dma_virt_addr = pci_alloc_consistent(dev->pci,
|
||||
dev->upstream_riscbuf_size, &dma_addr);
|
||||
dev->_dma_virt_start_addr = dev->_dma_virt_addr;
|
||||
dev->_dma_phys_start_addr = dma_addr;
|
||||
dev->_dma_phys_addr = dma_addr;
|
||||
dev->_risc_size = dev->upstream_riscbuf_size;
|
||||
out->_dma_virt_addr = pci_alloc_consistent(dev->pci,
|
||||
out->upstream_riscbuf_size, &dma_addr);
|
||||
out->_dma_virt_start_addr = out->_dma_virt_addr;
|
||||
out->_dma_phys_start_addr = dma_addr;
|
||||
out->_dma_phys_addr = dma_addr;
|
||||
out->_risc_size = out->upstream_riscbuf_size;
|
||||
|
||||
if (!dev->_dma_virt_addr) {
|
||||
if (!out->_dma_virt_addr) {
|
||||
pr_err("FAILED to allocate memory for Risc buffer! Returning\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Clear memory at address */
|
||||
memset(dev->_dma_virt_addr, 0, dev->_risc_size);
|
||||
memset(out->_dma_virt_addr, 0, out->_risc_size);
|
||||
|
||||
if (dev->_data_buf_virt_addr != NULL)
|
||||
pci_free_consistent(dev->pci, dev->upstream_databuf_size,
|
||||
dev->_data_buf_virt_addr,
|
||||
dev->_data_buf_phys_addr);
|
||||
if (out->_data_buf_virt_addr != NULL)
|
||||
pci_free_consistent(dev->pci, out->upstream_databuf_size,
|
||||
out->_data_buf_virt_addr,
|
||||
out->_data_buf_phys_addr);
|
||||
/* For Video Data buffer allocation */
|
||||
dev->_data_buf_virt_addr = pci_alloc_consistent(dev->pci,
|
||||
dev->upstream_databuf_size, &data_dma_addr);
|
||||
dev->_data_buf_phys_addr = data_dma_addr;
|
||||
dev->_data_buf_size = dev->upstream_databuf_size;
|
||||
out->_data_buf_virt_addr = pci_alloc_consistent(dev->pci,
|
||||
out->upstream_databuf_size, &data_dma_addr);
|
||||
out->_data_buf_phys_addr = data_dma_addr;
|
||||
out->_data_buf_size = out->upstream_databuf_size;
|
||||
|
||||
if (!dev->_data_buf_virt_addr) {
|
||||
if (!out->_data_buf_virt_addr) {
|
||||
pr_err("FAILED to allocate memory for data buffer! Returning\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Clear memory at address */
|
||||
memset(dev->_data_buf_virt_addr, 0, dev->_data_buf_size);
|
||||
|
||||
ret = cx25821_openfile(dev, sram_ch);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
memset(out->_data_buf_virt_addr, 0, out->_data_buf_size);
|
||||
|
||||
/* Create RISC programs */
|
||||
ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl,
|
||||
dev->_lines_count);
|
||||
ret = cx25821_risc_buffer_upstream(chan, dev->pci, 0, bpl,
|
||||
out->_lines_count);
|
||||
if (ret < 0) {
|
||||
pr_info("Failed creating Video Upstream Risc programs!\n");
|
||||
goto error;
|
||||
@ -551,11 +403,12 @@ error:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
u32 status)
|
||||
static int cx25821_video_upstream_irq(struct cx25821_channel *chan, u32 status)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
u32 int_msk_tmp;
|
||||
struct sram_channel *channel = dev->channels[chan_num].sram_channels;
|
||||
const struct sram_channel *channel = chan->sram_channels;
|
||||
int singlefield_lines = NTSC_FIELD_HEIGHT;
|
||||
int line_size_in_bytes = Y422_LINE_SZ;
|
||||
int odd_risc_prog_size = 0;
|
||||
@ -572,16 +425,16 @@ static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
cx_write(channel->int_msk, int_msk_tmp & ~_intr_msk);
|
||||
cx_write(channel->int_stat, _intr_msk);
|
||||
|
||||
wake_up(&out->waitq);
|
||||
|
||||
spin_lock(&dev->slock);
|
||||
|
||||
dev->_frame_index = prog_cnt;
|
||||
out->_frame_index = prog_cnt;
|
||||
|
||||
queue_work(dev->_irq_queues, &dev->_irq_work_entry);
|
||||
if (out->_is_first_frame) {
|
||||
out->_is_first_frame = 0;
|
||||
|
||||
if (dev->_is_first_frame) {
|
||||
dev->_is_first_frame = 0;
|
||||
|
||||
if (dev->_isNTSC) {
|
||||
if (out->is_60hz) {
|
||||
singlefield_lines += 1;
|
||||
odd_risc_prog_size = ODD_FLD_NTSC_PROG_SIZE;
|
||||
} else {
|
||||
@ -589,17 +442,17 @@ static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
odd_risc_prog_size = ODD_FLD_PAL_PROG_SIZE;
|
||||
}
|
||||
|
||||
if (dev->_dma_virt_start_addr != NULL) {
|
||||
if (out->_dma_virt_start_addr != NULL) {
|
||||
line_size_in_bytes =
|
||||
(dev->_pixel_format ==
|
||||
(out->_pixel_format ==
|
||||
PIXEL_FRMT_411) ? Y411_LINE_SZ :
|
||||
Y422_LINE_SZ;
|
||||
risc_phys_jump_addr =
|
||||
dev->_dma_phys_start_addr +
|
||||
out->_dma_phys_start_addr +
|
||||
odd_risc_prog_size;
|
||||
|
||||
rp = cx25821_update_riscprogram(dev,
|
||||
dev->_dma_virt_start_addr, TOP_OFFSET,
|
||||
rp = cx25821_update_riscprogram(chan,
|
||||
out->_dma_virt_start_addr, TOP_OFFSET,
|
||||
line_size_in_bytes, 0x0,
|
||||
singlefield_lines, FIFO_DISABLE,
|
||||
ODD_FIELD);
|
||||
@ -626,8 +479,8 @@ static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (dev->_file_status == END_OF_FILE) {
|
||||
pr_err("EOF Channel 1 Framecount = %d\n", dev->_frame_count);
|
||||
if (out->_file_status == END_OF_FILE) {
|
||||
pr_err("EOF Channel 1 Framecount = %d\n", out->_frame_count);
|
||||
return -1;
|
||||
}
|
||||
/* ElSE, set the interrupt mask register, re-enable irq. */
|
||||
@ -639,47 +492,41 @@ static int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num,
|
||||
|
||||
static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct cx25821_dev *dev = dev_id;
|
||||
struct cx25821_channel *chan = dev_id;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
u32 vid_status;
|
||||
int handled = 0;
|
||||
int channel_num = 0;
|
||||
struct sram_channel *sram_ch;
|
||||
const struct sram_channel *sram_ch;
|
||||
|
||||
if (!dev)
|
||||
return -1;
|
||||
|
||||
channel_num = VID_UPSTREAM_SRAM_CHANNEL_I;
|
||||
|
||||
sram_ch = dev->channels[channel_num].sram_channels;
|
||||
sram_ch = chan->sram_channels;
|
||||
|
||||
vid_status = cx_read(sram_ch->int_stat);
|
||||
|
||||
/* Only deal with our interrupt */
|
||||
if (vid_status)
|
||||
handled = cx25821_video_upstream_irq(dev, channel_num,
|
||||
vid_status);
|
||||
|
||||
if (handled < 0)
|
||||
cx25821_stop_upstream_video_ch1(dev);
|
||||
else
|
||||
handled += handled;
|
||||
handled = cx25821_video_upstream_irq(chan, vid_status);
|
||||
|
||||
return IRQ_RETVAL(handled);
|
||||
}
|
||||
|
||||
static void cx25821_set_pixelengine(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
static void cx25821_set_pixelengine(struct cx25821_channel *chan,
|
||||
const struct sram_channel *ch,
|
||||
int pix_format)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
int width = WIDTH_D1;
|
||||
int height = dev->_lines_count;
|
||||
int height = out->_lines_count;
|
||||
int num_lines, odd_num_lines;
|
||||
u32 value;
|
||||
int vip_mode = OUTPUT_FRMT_656;
|
||||
|
||||
value = ((pix_format & 0x3) << 12) | (vip_mode & 0x7);
|
||||
value &= 0xFFFFFFEF;
|
||||
value |= dev->_isNTSC ? 0 : 0x10;
|
||||
value |= out->is_60hz ? 0 : 0x10;
|
||||
cx_write(ch->vid_fmt_ctl, value);
|
||||
|
||||
/* set number of active pixels in each line.
|
||||
@ -689,7 +536,7 @@ static void cx25821_set_pixelengine(struct cx25821_dev *dev,
|
||||
num_lines = (height / 2) & 0x3FF;
|
||||
odd_num_lines = num_lines;
|
||||
|
||||
if (dev->_isNTSC)
|
||||
if (out->is_60hz)
|
||||
odd_num_lines += 1;
|
||||
|
||||
value = (num_lines << 16) | odd_num_lines;
|
||||
@ -700,9 +547,11 @@ static void cx25821_set_pixelengine(struct cx25821_dev *dev,
|
||||
cx_write(ch->vid_cdt_size, VID_CDT_SIZE >> 3);
|
||||
}
|
||||
|
||||
static int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
|
||||
struct sram_channel *sram_ch)
|
||||
static int cx25821_start_video_dma_upstream(struct cx25821_channel *chan,
|
||||
const struct sram_channel *sram_ch)
|
||||
{
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
u32 tmp = 0;
|
||||
int err = 0;
|
||||
|
||||
@ -715,7 +564,7 @@ static int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
|
||||
/* Set the physical start address of the RISC program in the initial
|
||||
* program counter(IPC) member of the cmds.
|
||||
*/
|
||||
cx_write(sram_ch->cmds_start + 0, dev->_dma_phys_addr);
|
||||
cx_write(sram_ch->cmds_start + 0, out->_dma_phys_addr);
|
||||
/* Risc IPC High 64 bits 63-32 */
|
||||
cx_write(sram_ch->cmds_start + 4, 0);
|
||||
|
||||
@ -731,7 +580,7 @@ static int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
|
||||
cx_write(sram_ch->int_msk, tmp |= _intr_msk);
|
||||
|
||||
err = request_irq(dev->pci->irq, cx25821_upstream_irq,
|
||||
IRQF_SHARED, dev->name, dev);
|
||||
IRQF_SHARED, dev->name, chan);
|
||||
if (err < 0) {
|
||||
pr_err("%s: can't get upstream IRQ %d\n",
|
||||
dev->name, dev->pci->irq);
|
||||
@ -742,8 +591,8 @@ static int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
|
||||
tmp = cx_read(sram_ch->dma_ctl);
|
||||
cx_set(sram_ch->dma_ctl, tmp | FLD_VID_RISC_EN);
|
||||
|
||||
dev->_is_running = 1;
|
||||
dev->_is_first_frame = 1;
|
||||
out->_is_running = 1;
|
||||
out->_is_first_frame = 1;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -752,107 +601,71 @@ fail_irq:
|
||||
return err;
|
||||
}
|
||||
|
||||
int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select,
|
||||
int cx25821_vidupstream_init(struct cx25821_channel *chan,
|
||||
int pixel_format)
|
||||
{
|
||||
struct sram_channel *sram_ch;
|
||||
struct cx25821_video_out_data *out = chan->out;
|
||||
struct cx25821_dev *dev = chan->dev;
|
||||
const struct sram_channel *sram_ch;
|
||||
u32 tmp;
|
||||
int err = 0;
|
||||
int data_frame_size = 0;
|
||||
int risc_buffer_size = 0;
|
||||
int str_length = 0;
|
||||
|
||||
if (dev->_is_running) {
|
||||
if (out->_is_running) {
|
||||
pr_info("Video Channel is still running so return!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
dev->_channel_upstream_select = channel_select;
|
||||
sram_ch = dev->channels[channel_select].sram_channels;
|
||||
sram_ch = chan->sram_channels;
|
||||
|
||||
INIT_WORK(&dev->_irq_work_entry, cx25821_vidups_handler);
|
||||
dev->_irq_queues = create_singlethread_workqueue("cx25821_workqueue");
|
||||
out->is_60hz = dev->tvnorm & V4L2_STD_525_60;
|
||||
|
||||
if (!dev->_irq_queues) {
|
||||
pr_err("create_singlethread_workqueue() for Video FAILED!\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
/* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for
|
||||
* channel A-C
|
||||
*/
|
||||
tmp = cx_read(VID_CH_MODE_SEL);
|
||||
cx_write(VID_CH_MODE_SEL, tmp | 0x1B0001FF);
|
||||
|
||||
dev->_is_running = 0;
|
||||
dev->_frame_count = 0;
|
||||
dev->_file_status = RESET_STATUS;
|
||||
dev->_lines_count = dev->_isNTSC ? 480 : 576;
|
||||
dev->_pixel_format = pixel_format;
|
||||
dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ?
|
||||
out->_is_running = 0;
|
||||
out->_frame_count = 0;
|
||||
out->_file_status = RESET_STATUS;
|
||||
out->_lines_count = out->is_60hz ? 480 : 576;
|
||||
out->_pixel_format = pixel_format;
|
||||
out->_line_size = (out->_pixel_format == PIXEL_FRMT_422) ?
|
||||
(WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2;
|
||||
data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ;
|
||||
risc_buffer_size = dev->_isNTSC ?
|
||||
data_frame_size = out->is_60hz ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ;
|
||||
risc_buffer_size = out->is_60hz ?
|
||||
NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE;
|
||||
|
||||
if (dev->input_filename) {
|
||||
str_length = strlen(dev->input_filename);
|
||||
dev->_filename = kmemdup(dev->input_filename, str_length + 1,
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!dev->_filename) {
|
||||
err = -ENOENT;
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
str_length = strlen(dev->_defaultname);
|
||||
dev->_filename = kmemdup(dev->_defaultname, str_length + 1,
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!dev->_filename) {
|
||||
err = -ENOENT;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Default if filename is empty string */
|
||||
if (strcmp(dev->_filename, "") == 0) {
|
||||
if (dev->_isNTSC) {
|
||||
dev->_filename =
|
||||
(dev->_pixel_format == PIXEL_FRMT_411) ?
|
||||
"/root/vid411.yuv" : "/root/vidtest.yuv";
|
||||
} else {
|
||||
dev->_filename =
|
||||
(dev->_pixel_format == PIXEL_FRMT_411) ?
|
||||
"/root/pal411.yuv" : "/root/pal422.yuv";
|
||||
}
|
||||
}
|
||||
|
||||
dev->_is_running = 0;
|
||||
dev->_frame_count = 0;
|
||||
dev->_file_status = RESET_STATUS;
|
||||
dev->_lines_count = dev->_isNTSC ? 480 : 576;
|
||||
dev->_pixel_format = pixel_format;
|
||||
dev->_line_size = (dev->_pixel_format == PIXEL_FRMT_422) ?
|
||||
out->_is_running = 0;
|
||||
out->_frame_count = 0;
|
||||
out->_file_status = RESET_STATUS;
|
||||
out->_lines_count = out->is_60hz ? 480 : 576;
|
||||
out->_pixel_format = pixel_format;
|
||||
out->_line_size = (out->_pixel_format == PIXEL_FRMT_422) ?
|
||||
(WIDTH_D1 * 2) : (WIDTH_D1 * 3) / 2;
|
||||
out->curpos = 0;
|
||||
init_waitqueue_head(&out->waitq);
|
||||
|
||||
err = cx25821_sram_channel_setup_upstream(dev, sram_ch,
|
||||
dev->_line_size, 0);
|
||||
out->_line_size, 0);
|
||||
|
||||
/* setup fifo + format */
|
||||
cx25821_set_pixelengine(dev, sram_ch, dev->_pixel_format);
|
||||
cx25821_set_pixelengine(chan, sram_ch, out->_pixel_format);
|
||||
|
||||
dev->upstream_riscbuf_size = risc_buffer_size * 2;
|
||||
dev->upstream_databuf_size = data_frame_size * 2;
|
||||
out->upstream_riscbuf_size = risc_buffer_size * 2;
|
||||
out->upstream_databuf_size = data_frame_size * 2;
|
||||
|
||||
/* Allocating buffers and prepare RISC program */
|
||||
err = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size);
|
||||
err = cx25821_upstream_buffer_prepare(chan, sram_ch, out->_line_size);
|
||||
if (err < 0) {
|
||||
pr_err("%s: Failed to set up Video upstream buffers!\n",
|
||||
dev->name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
cx25821_start_video_dma_upstream(dev, sram_ch);
|
||||
cx25821_start_video_dma_upstream(chan, sram_ch);
|
||||
|
||||
return 0;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,8 +39,7 @@
|
||||
#include "cx25821.h"
|
||||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
|
||||
#define TUNER_FLAG
|
||||
#include <media/v4l2-event.h>
|
||||
|
||||
#define VIDEO_DEBUG 0
|
||||
|
||||
@ -50,137 +49,17 @@ do { \
|
||||
printk(KERN_DEBUG "%s/0: " fmt, dev->name, ##arg); \
|
||||
} while (0)
|
||||
|
||||
/* For IOCTL to identify running upstream */
|
||||
#define UPSTREAM_START_VIDEO 700
|
||||
#define UPSTREAM_STOP_VIDEO 701
|
||||
#define UPSTREAM_START_AUDIO 702
|
||||
#define UPSTREAM_STOP_AUDIO 703
|
||||
#define UPSTREAM_DUMP_REGISTERS 702
|
||||
#define SET_VIDEO_STD 800
|
||||
#define SET_PIXEL_FORMAT 1000
|
||||
#define ENABLE_CIF_RESOLUTION 1001
|
||||
|
||||
#define REG_READ 900
|
||||
#define REG_WRITE 901
|
||||
#define MEDUSA_READ 910
|
||||
#define MEDUSA_WRITE 911
|
||||
|
||||
extern struct sram_channel *channel0;
|
||||
extern struct sram_channel *channel1;
|
||||
extern struct sram_channel *channel2;
|
||||
extern struct sram_channel *channel3;
|
||||
extern struct sram_channel *channel4;
|
||||
extern struct sram_channel *channel5;
|
||||
extern struct sram_channel *channel6;
|
||||
extern struct sram_channel *channel7;
|
||||
extern struct sram_channel *channel9;
|
||||
extern struct sram_channel *channel10;
|
||||
extern struct sram_channel *channel11;
|
||||
extern struct video_device cx25821_videoioctl_template;
|
||||
/* extern const u32 *ctrl_classes[]; */
|
||||
|
||||
extern unsigned int vid_limit;
|
||||
|
||||
#define FORMAT_FLAGS_PACKED 0x01
|
||||
extern struct cx25821_fmt formats[];
|
||||
extern struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc);
|
||||
extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
|
||||
|
||||
extern void cx25821_video_wakeup(struct cx25821_dev *dev,
|
||||
struct cx25821_dmaqueue *q, u32 count);
|
||||
|
||||
#ifdef TUNER_FLAG
|
||||
extern int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm);
|
||||
#endif
|
||||
|
||||
extern int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
|
||||
unsigned int bit);
|
||||
extern int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit);
|
||||
extern int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit);
|
||||
extern void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
|
||||
unsigned int bits);
|
||||
extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input);
|
||||
extern int cx25821_start_video_dma(struct cx25821_dev *dev,
|
||||
struct cx25821_dmaqueue *q,
|
||||
struct cx25821_buffer *buf,
|
||||
struct sram_channel *channel);
|
||||
const struct sram_channel *channel);
|
||||
|
||||
extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width,
|
||||
unsigned int height, enum v4l2_field field);
|
||||
extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status);
|
||||
extern void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num);
|
||||
extern int cx25821_video_register(struct cx25821_dev *dev);
|
||||
extern int cx25821_get_format_size(void);
|
||||
|
||||
extern int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
|
||||
unsigned int *size);
|
||||
extern int cx25821_buffer_prepare(struct videobuf_queue *q,
|
||||
struct videobuf_buffer *vb,
|
||||
enum v4l2_field field);
|
||||
extern void cx25821_buffer_release(struct videobuf_queue *q,
|
||||
struct videobuf_buffer *vb);
|
||||
extern struct videobuf_queue *get_queue(struct cx25821_fh *fh);
|
||||
extern int cx25821_get_resource(struct cx25821_fh *fh, int resource);
|
||||
extern int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma);
|
||||
extern int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
|
||||
struct v4l2_format *f);
|
||||
extern int cx25821_vidioc_querycap(struct file *file, void *priv,
|
||||
struct v4l2_capability *cap);
|
||||
extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f);
|
||||
extern int cx25821_vidioc_reqbufs(struct file *file, void *priv,
|
||||
struct v4l2_requestbuffers *p);
|
||||
extern int cx25821_vidioc_querybuf(struct file *file, void *priv,
|
||||
struct v4l2_buffer *p);
|
||||
extern int cx25821_vidioc_qbuf(struct file *file, void *priv,
|
||||
struct v4l2_buffer *p);
|
||||
extern int cx25821_vidioc_s_std(struct file *file, void *priv,
|
||||
v4l2_std_id tvnorms);
|
||||
extern int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i);
|
||||
extern int cx25821_vidioc_enum_input(struct file *file, void *priv,
|
||||
struct v4l2_input *i);
|
||||
extern int cx25821_vidioc_g_input(struct file *file, void *priv,
|
||||
unsigned int *i);
|
||||
extern int cx25821_vidioc_s_input(struct file *file, void *priv,
|
||||
unsigned int i);
|
||||
extern int cx25821_vidioc_g_ctrl(struct file *file, void *priv,
|
||||
struct v4l2_control *ctl);
|
||||
extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
|
||||
struct v4l2_format *f);
|
||||
extern int cx25821_vidioc_g_frequency(struct file *file, void *priv,
|
||||
struct v4l2_frequency *f);
|
||||
extern int cx25821_set_freq(struct cx25821_dev *dev, const struct v4l2_frequency *f);
|
||||
extern int cx25821_vidioc_s_frequency(struct file *file, void *priv,
|
||||
const struct v4l2_frequency *f);
|
||||
extern int cx25821_vidioc_g_register(struct file *file, void *fh,
|
||||
struct v4l2_dbg_register *reg);
|
||||
extern int cx25821_vidioc_s_register(struct file *file, void *fh,
|
||||
const struct v4l2_dbg_register *reg);
|
||||
extern int cx25821_vidioc_g_tuner(struct file *file, void *priv,
|
||||
struct v4l2_tuner *t);
|
||||
extern int cx25821_vidioc_s_tuner(struct file *file, void *priv,
|
||||
const struct v4l2_tuner *t);
|
||||
|
||||
extern int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm);
|
||||
extern int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm);
|
||||
|
||||
extern int cx25821_vidioc_g_priority(struct file *file, void *f,
|
||||
enum v4l2_priority *p);
|
||||
extern int cx25821_vidioc_s_priority(struct file *file, void *f,
|
||||
enum v4l2_priority prio);
|
||||
|
||||
extern int cx25821_vidioc_queryctrl(struct file *file, void *priv,
|
||||
struct v4l2_queryctrl *qctrl);
|
||||
extern int cx25821_set_control(struct cx25821_dev *dev,
|
||||
struct v4l2_control *ctrl, int chan_num);
|
||||
|
||||
extern int cx25821_vidioc_cropcap(struct file *file, void *fh,
|
||||
struct v4l2_cropcap *cropcap);
|
||||
extern int cx25821_vidioc_s_crop(struct file *file, void *priv,
|
||||
const struct v4l2_crop *crop);
|
||||
extern int cx25821_vidioc_g_crop(struct file *file, void *priv,
|
||||
struct v4l2_crop *crop);
|
||||
|
||||
extern int cx25821_vidioc_querystd(struct file *file, void *priv,
|
||||
v4l2_std_id *norm);
|
||||
#endif
|
||||
|
@ -33,17 +33,14 @@
|
||||
|
||||
#include <media/v4l2-common.h>
|
||||
#include <media/v4l2-device.h>
|
||||
#include <media/tuner.h>
|
||||
#include <media/tveeprom.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/videobuf-dma-sg.h>
|
||||
#include <media/videobuf-dvb.h>
|
||||
|
||||
#include "btcx-risc.h"
|
||||
#include "cx25821-reg.h"
|
||||
#include "cx25821-medusa-reg.h"
|
||||
#include "cx25821-sram.h"
|
||||
#include "cx25821-audio.h"
|
||||
#include "media/cx2341x.h"
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/mutex.h>
|
||||
@ -55,8 +52,6 @@
|
||||
|
||||
#define CX25821_MAXBOARDS 2
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define LINE_SIZE_D1 1440
|
||||
|
||||
/* Number of decoders and encoders */
|
||||
@ -67,7 +62,6 @@
|
||||
|
||||
/* Max number of inputs by card */
|
||||
#define MAX_CX25821_INPUT 8
|
||||
#define INPUT(nr) (&cx25821_boards[dev->board].input[nr])
|
||||
#define RESOURCE_VIDEO0 1
|
||||
#define RESOURCE_VIDEO1 2
|
||||
#define RESOURCE_VIDEO2 4
|
||||
@ -80,7 +74,6 @@
|
||||
#define RESOURCE_VIDEO9 512
|
||||
#define RESOURCE_VIDEO10 1024
|
||||
#define RESOURCE_VIDEO11 2048
|
||||
#define RESOURCE_VIDEO_IOCTL 4096
|
||||
|
||||
#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */
|
||||
|
||||
@ -97,7 +90,6 @@
|
||||
#define CX25821_BOARD_CONEXANT_ATHENA10 1
|
||||
#define MAX_VID_CHANNEL_NUM 12
|
||||
#define VID_CHANNEL_NUM 8
|
||||
#define CX25821_NR_INPUT 2
|
||||
|
||||
struct cx25821_fmt {
|
||||
char *name;
|
||||
@ -107,14 +99,6 @@ struct cx25821_fmt {
|
||||
u32 cxformat;
|
||||
};
|
||||
|
||||
struct cx25821_ctrl {
|
||||
struct v4l2_queryctrl v;
|
||||
u32 off;
|
||||
u32 reg;
|
||||
u32 mask;
|
||||
u32 shift;
|
||||
};
|
||||
|
||||
struct cx25821_tvnorm {
|
||||
char *name;
|
||||
v4l2_std_id id;
|
||||
@ -122,40 +106,6 @@ struct cx25821_tvnorm {
|
||||
u32 cxoformat;
|
||||
};
|
||||
|
||||
struct cx25821_fh {
|
||||
struct cx25821_dev *dev;
|
||||
enum v4l2_buf_type type;
|
||||
int radio;
|
||||
u32 resources;
|
||||
|
||||
enum v4l2_priority prio;
|
||||
|
||||
/* video overlay */
|
||||
struct v4l2_window win;
|
||||
struct v4l2_clip *clips;
|
||||
unsigned int nclips;
|
||||
|
||||
/* video capture */
|
||||
struct cx25821_fmt *fmt;
|
||||
unsigned int width, height;
|
||||
int channel_id;
|
||||
|
||||
/* vbi capture */
|
||||
struct videobuf_queue vidq;
|
||||
struct videobuf_queue vbiq;
|
||||
|
||||
/* H264 Encoder specifics ONLY */
|
||||
struct videobuf_queue mpegq;
|
||||
atomic_t v4l_reading;
|
||||
};
|
||||
|
||||
enum cx25821_itype {
|
||||
CX25821_VMUX_COMPOSITE = 1,
|
||||
CX25821_VMUX_SVIDEO,
|
||||
CX25821_VMUX_DEBUG,
|
||||
CX25821_RADIO,
|
||||
};
|
||||
|
||||
enum cx25821_src_sel_type {
|
||||
CX25821_SRC_SEL_EXT_656_VIDEO = 0,
|
||||
CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO
|
||||
@ -169,16 +119,10 @@ struct cx25821_buffer {
|
||||
/* cx25821 specific */
|
||||
unsigned int bpl;
|
||||
struct btcx_riscmem risc;
|
||||
struct cx25821_fmt *fmt;
|
||||
const struct cx25821_fmt *fmt;
|
||||
u32 count;
|
||||
};
|
||||
|
||||
struct cx25821_input {
|
||||
enum cx25821_itype type;
|
||||
unsigned int vmux;
|
||||
u32 gpio0, gpio1, gpio2, gpio3;
|
||||
};
|
||||
|
||||
enum port {
|
||||
CX25821_UNDEFINED = 0,
|
||||
CX25821_RAW,
|
||||
@ -190,19 +134,8 @@ struct cx25821_board {
|
||||
enum port porta;
|
||||
enum port portb;
|
||||
enum port portc;
|
||||
unsigned int tuner_type;
|
||||
unsigned int radio_type;
|
||||
unsigned char tuner_addr;
|
||||
unsigned char radio_addr;
|
||||
|
||||
u32 clk_freq;
|
||||
struct cx25821_input input[CX25821_NR_INPUT];
|
||||
};
|
||||
|
||||
struct cx25821_subid {
|
||||
u16 subvendor;
|
||||
u16 subdevice;
|
||||
u32 card;
|
||||
};
|
||||
|
||||
struct cx25821_i2c {
|
||||
@ -234,34 +167,70 @@ struct cx25821_dmaqueue {
|
||||
|
||||
struct cx25821_data {
|
||||
struct cx25821_dev *dev;
|
||||
struct sram_channel *channel;
|
||||
const struct sram_channel *channel;
|
||||
};
|
||||
|
||||
struct cx25821_dev;
|
||||
|
||||
struct cx25821_channel;
|
||||
|
||||
struct cx25821_video_out_data {
|
||||
struct cx25821_channel *chan;
|
||||
int _line_size;
|
||||
int _prog_cnt;
|
||||
int _pixel_format;
|
||||
int _is_first_frame;
|
||||
int _is_running;
|
||||
int _file_status;
|
||||
int _lines_count;
|
||||
int _frame_count;
|
||||
unsigned int _risc_size;
|
||||
|
||||
__le32 *_dma_virt_start_addr;
|
||||
__le32 *_dma_virt_addr;
|
||||
dma_addr_t _dma_phys_addr;
|
||||
dma_addr_t _dma_phys_start_addr;
|
||||
|
||||
unsigned int _data_buf_size;
|
||||
__le32 *_data_buf_virt_addr;
|
||||
dma_addr_t _data_buf_phys_addr;
|
||||
|
||||
u32 upstream_riscbuf_size;
|
||||
u32 upstream_databuf_size;
|
||||
int is_60hz;
|
||||
int _frame_index;
|
||||
int cur_frame_index;
|
||||
int curpos;
|
||||
wait_queue_head_t waitq;
|
||||
};
|
||||
|
||||
struct cx25821_channel {
|
||||
struct v4l2_prio_state prio;
|
||||
unsigned id;
|
||||
struct cx25821_dev *dev;
|
||||
struct v4l2_fh *streaming_fh;
|
||||
|
||||
int ctl_bright;
|
||||
int ctl_contrast;
|
||||
int ctl_hue;
|
||||
int ctl_saturation;
|
||||
struct v4l2_ctrl_handler hdl;
|
||||
struct cx25821_data timeout_data;
|
||||
|
||||
struct video_device *video_dev;
|
||||
struct cx25821_dmaqueue vidq;
|
||||
struct video_device vdev;
|
||||
struct cx25821_dmaqueue dma_vidq;
|
||||
struct videobuf_queue vidq;
|
||||
|
||||
struct sram_channel *sram_channels;
|
||||
|
||||
struct mutex lock;
|
||||
int resources;
|
||||
const struct sram_channel *sram_channels;
|
||||
|
||||
const struct cx25821_fmt *fmt;
|
||||
unsigned int width, height;
|
||||
int pixel_formats;
|
||||
int use_cif_resolution;
|
||||
int cif_width;
|
||||
|
||||
/* video output data for the video output channel */
|
||||
struct cx25821_video_out_data *out;
|
||||
};
|
||||
|
||||
struct snd_card;
|
||||
|
||||
struct cx25821_dev {
|
||||
struct list_head devlist;
|
||||
atomic_t refcount;
|
||||
struct v4l2_device v4l2_dev;
|
||||
|
||||
/* pci stuff */
|
||||
@ -273,6 +242,8 @@ struct cx25821_dev {
|
||||
u8 __iomem *bmmio;
|
||||
int pci_irqmask;
|
||||
int hwrevision;
|
||||
/* used by cx25821-alsa */
|
||||
struct snd_card *card;
|
||||
|
||||
u32 clk_freq;
|
||||
|
||||
@ -289,17 +260,8 @@ struct cx25821_dev {
|
||||
char name[32];
|
||||
|
||||
/* Analog video */
|
||||
u32 resources;
|
||||
unsigned int input;
|
||||
u32 tvaudio;
|
||||
v4l2_std_id tvnorm;
|
||||
unsigned int tuner_type;
|
||||
unsigned char tuner_addr;
|
||||
unsigned int radio_type;
|
||||
unsigned char radio_addr;
|
||||
unsigned int has_radio;
|
||||
unsigned int videc_type;
|
||||
unsigned char videc_addr;
|
||||
unsigned short _max_num_decoders;
|
||||
|
||||
/* Analog Audio Upstream */
|
||||
@ -323,132 +285,26 @@ struct cx25821_dev {
|
||||
__le32 *_audiodata_buf_virt_addr;
|
||||
dma_addr_t _audiodata_buf_phys_addr;
|
||||
char *_audiofilename;
|
||||
u32 audio_upstream_riscbuf_size;
|
||||
u32 audio_upstream_databuf_size;
|
||||
int _audioframe_index;
|
||||
struct workqueue_struct *_irq_audio_queues;
|
||||
struct work_struct _audio_work_entry;
|
||||
char *input_audiofilename;
|
||||
|
||||
/* V4l */
|
||||
u32 freq;
|
||||
struct video_device *vbi_dev;
|
||||
struct video_device *radio_dev;
|
||||
struct video_device *ioctl_dev;
|
||||
|
||||
spinlock_t slock;
|
||||
|
||||
/* Video Upstream */
|
||||
int _line_size;
|
||||
int _prog_cnt;
|
||||
int _pixel_format;
|
||||
int _is_first_frame;
|
||||
int _is_running;
|
||||
int _file_status;
|
||||
int _lines_count;
|
||||
int _frame_count;
|
||||
int _channel_upstream_select;
|
||||
unsigned int _risc_size;
|
||||
|
||||
__le32 *_dma_virt_start_addr;
|
||||
__le32 *_dma_virt_addr;
|
||||
dma_addr_t _dma_phys_addr;
|
||||
dma_addr_t _dma_phys_start_addr;
|
||||
|
||||
unsigned int _data_buf_size;
|
||||
__le32 *_data_buf_virt_addr;
|
||||
dma_addr_t _data_buf_phys_addr;
|
||||
char *_filename;
|
||||
char *_defaultname;
|
||||
|
||||
int _line_size_ch2;
|
||||
int _prog_cnt_ch2;
|
||||
int _pixel_format_ch2;
|
||||
int _is_first_frame_ch2;
|
||||
int _is_running_ch2;
|
||||
int _file_status_ch2;
|
||||
int _lines_count_ch2;
|
||||
int _frame_count_ch2;
|
||||
int _channel2_upstream_select;
|
||||
unsigned int _risc_size_ch2;
|
||||
|
||||
__le32 *_dma_virt_start_addr_ch2;
|
||||
__le32 *_dma_virt_addr_ch2;
|
||||
dma_addr_t _dma_phys_addr_ch2;
|
||||
dma_addr_t _dma_phys_start_addr_ch2;
|
||||
|
||||
unsigned int _data_buf_size_ch2;
|
||||
__le32 *_data_buf_virt_addr_ch2;
|
||||
dma_addr_t _data_buf_phys_addr_ch2;
|
||||
char *_filename_ch2;
|
||||
char *_defaultname_ch2;
|
||||
|
||||
/* MPEG Encoder ONLY settings */
|
||||
u32 cx23417_mailbox;
|
||||
struct cx2341x_mpeg_params mpeg_params;
|
||||
struct video_device *v4l_device;
|
||||
atomic_t v4l_reader_count;
|
||||
struct cx25821_tvnorm encodernorm;
|
||||
|
||||
u32 upstream_riscbuf_size;
|
||||
u32 upstream_databuf_size;
|
||||
u32 upstream_riscbuf_size_ch2;
|
||||
u32 upstream_databuf_size_ch2;
|
||||
u32 audio_upstream_riscbuf_size;
|
||||
u32 audio_upstream_databuf_size;
|
||||
int _isNTSC;
|
||||
int _frame_index;
|
||||
int _audioframe_index;
|
||||
struct workqueue_struct *_irq_queues;
|
||||
struct work_struct _irq_work_entry;
|
||||
struct workqueue_struct *_irq_queues_ch2;
|
||||
struct work_struct _irq_work_entry_ch2;
|
||||
struct workqueue_struct *_irq_audio_queues;
|
||||
struct work_struct _audio_work_entry;
|
||||
char *input_filename;
|
||||
char *input_filename_ch2;
|
||||
int _frame_index_ch2;
|
||||
int _isNTSC_ch2;
|
||||
char *vid_stdname_ch2;
|
||||
int pixel_format_ch2;
|
||||
int channel_select_ch2;
|
||||
int command_ch2;
|
||||
char *input_audiofilename;
|
||||
char *vid_stdname;
|
||||
int pixel_format;
|
||||
int channel_select;
|
||||
int command;
|
||||
int channel_opened;
|
||||
struct cx25821_video_out_data vid_out_data[2];
|
||||
};
|
||||
|
||||
struct upstream_user_struct {
|
||||
char *input_filename;
|
||||
char *vid_stdname;
|
||||
int pixel_format;
|
||||
int channel_select;
|
||||
int command;
|
||||
};
|
||||
|
||||
struct downstream_user_struct {
|
||||
char *vid_stdname;
|
||||
int pixel_format;
|
||||
int cif_resolution_enable;
|
||||
int cif_width;
|
||||
int decoder_select;
|
||||
int command;
|
||||
int reg_address;
|
||||
int reg_data;
|
||||
};
|
||||
|
||||
extern struct upstream_user_struct *up_data;
|
||||
|
||||
static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
|
||||
{
|
||||
return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev);
|
||||
}
|
||||
|
||||
#define cx25821_call_all(dev, o, f, args...) \
|
||||
v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args)
|
||||
|
||||
extern struct list_head cx25821_devlist;
|
||||
extern struct mutex cx25821_devlist_mutex;
|
||||
|
||||
extern struct cx25821_board cx25821_boards[];
|
||||
extern struct cx25821_subid cx25821_subids[];
|
||||
|
||||
#define SRAM_CH00 0 /* Video A */
|
||||
#define SRAM_CH01 1 /* Video B */
|
||||
@ -467,7 +323,6 @@ extern struct cx25821_subid cx25821_subids[];
|
||||
#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09
|
||||
#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10
|
||||
#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11
|
||||
#define VIDEO_IOCTL_CH 11
|
||||
|
||||
struct sram_channel {
|
||||
char *name;
|
||||
@ -503,10 +358,8 @@ struct sram_channel {
|
||||
u32 jumponly;
|
||||
u32 irq_bit;
|
||||
};
|
||||
extern struct sram_channel cx25821_sram_channels[];
|
||||
|
||||
#define STATUS_SUCCESS 0
|
||||
#define STATUS_UNSUCCESSFUL -1
|
||||
extern const struct sram_channel cx25821_sram_channels[];
|
||||
|
||||
#define cx_read(reg) readl(dev->lmmio + ((reg)>>2))
|
||||
#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2))
|
||||
@ -529,8 +382,6 @@ extern struct sram_channel cx25821_sram_channels[];
|
||||
pr_info("(%d): " fmt, dev->board, ##args)
|
||||
|
||||
extern int cx25821_i2c_register(struct cx25821_i2c *bus);
|
||||
extern void cx25821_card_setup(struct cx25821_dev *dev);
|
||||
extern int cx25821_ir_init(struct cx25821_dev *dev);
|
||||
extern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value);
|
||||
extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
|
||||
extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
|
||||
@ -551,7 +402,7 @@ extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation,
|
||||
int decoder);
|
||||
|
||||
extern int cx25821_sram_channel_setup(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch, unsigned int bpl,
|
||||
const struct sram_channel *ch, unsigned int bpl,
|
||||
u32 risc);
|
||||
|
||||
extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
|
||||
@ -570,46 +421,31 @@ extern void cx25821_free_buffer(struct videobuf_queue *q,
|
||||
extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
|
||||
u32 reg, u32 mask, u32 value);
|
||||
extern void cx25821_sram_channel_dump(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch);
|
||||
const struct sram_channel *ch);
|
||||
extern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch);
|
||||
const struct sram_channel *ch);
|
||||
|
||||
extern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci);
|
||||
extern void cx25821_print_irqbits(char *name, char *tag, char **strings,
|
||||
int len, u32 bits, u32 mask);
|
||||
extern void cx25821_dev_unregister(struct cx25821_dev *dev);
|
||||
extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc);
|
||||
|
||||
extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev,
|
||||
int channel_select, int pixel_format);
|
||||
extern int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev,
|
||||
int channel_select, int pixel_format);
|
||||
extern int cx25821_vidupstream_init(struct cx25821_channel *chan, int pixel_format);
|
||||
extern int cx25821_audio_upstream_init(struct cx25821_dev *dev,
|
||||
int channel_select);
|
||||
extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev);
|
||||
extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev);
|
||||
extern int cx25821_write_frame(struct cx25821_channel *chan,
|
||||
const char __user *data, size_t count);
|
||||
extern void cx25821_free_mem_upstream(struct cx25821_channel *chan);
|
||||
extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev);
|
||||
extern void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct
|
||||
*up_data);
|
||||
extern void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct
|
||||
*up_data);
|
||||
extern void cx25821_start_upstream_audio(struct cx25821_dev *dev,
|
||||
struct upstream_user_struct *up_data);
|
||||
extern void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev);
|
||||
extern void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev);
|
||||
extern void cx25821_stop_upstream_video(struct cx25821_channel *chan);
|
||||
extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev);
|
||||
extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
|
||||
struct sram_channel *ch,
|
||||
const struct sram_channel *ch,
|
||||
unsigned int bpl, u32 risc);
|
||||
extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel,
|
||||
u32 format);
|
||||
extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev);
|
||||
extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
|
||||
struct pci_dev *pci,
|
||||
struct video_device *template,
|
||||
char *type);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user