V4L/DVB (12732): cx25821: fix bad whitespacing

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Mauro Carvalho Chehab 2009-09-13 11:25:45 -03:00
parent 466a1c15b5
commit bb4c9a74b8
29 changed files with 3806 additions and 3807 deletions

View File

@ -15,7 +15,7 @@ config VIDEO_CX25821
To compile this driver as a module, choose M here: the
module will be called cx25821
config VIDEO_CX25821_ALSA
tristate "Conexant 25821 DMA audio support"
depends on VIDEO_CX25821 && SND && EXPERIMENTAL
@ -30,5 +30,5 @@ config VIDEO_CX25821_ALSA
PCI device.
To compile this driver as a module, choose M here: the
module will be called cx25821-alsa.
module will be called cx25821-alsa.

View File

@ -72,7 +72,7 @@ struct cx25821_audio_dev {
unsigned long iobase;
spinlock_t reg_lock;
atomic_t count;
atomic_t count;
unsigned int dma_size;
unsigned int period_size;

View File

@ -45,8 +45,8 @@ static int _intr_msk = FLD_AUD_SRC_RISCI1 | FLD_AUD_SRC_OF | FLD_AUD_SRC_SYNC |
int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
struct sram_channel *ch,
unsigned int bpl, u32 risc)
struct sram_channel *ch,
unsigned int bpl, u32 risc)
{
unsigned int i, lines;
u32 cdt;
@ -66,7 +66,7 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
if (lines > 3)
{
lines = 3;
lines = 3;
}
BUG_ON(lines < 2);
@ -87,7 +87,7 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
cx_write(ch->cmds_start + 8, cdt);
cx_write(ch->cmds_start + 12, AUDIO_CDT_SIZE_QW);
cx_write(ch->cmds_start + 16, ch->ctrl_start);
//IQ size
cx_write(ch->cmds_start + 20, AUDIO_IQ_SIZE_DW);
@ -105,40 +105,40 @@ int cx25821_sram_channel_setup_upstream_audio(struct cx25821_dev *dev,
static __le32 *cx25821_risc_field_upstream_audio( struct cx25821_dev *dev, __le32 *rp,
dma_addr_t databuf_phys_addr,
unsigned int bpl, int fifo_enable)
dma_addr_t databuf_phys_addr,
unsigned int bpl, int fifo_enable)
{
unsigned int line;
struct sram_channel *sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select];
int offset = 0;
/* scan lines */
for (line = 0; line < LINES_PER_AUDIO_BUFFER; 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 */
*(rp++) = cpu_to_le32(databuf_phys_addr + offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
// Check if we need to enable the FIFO after the first 3 lines
// For the upstream audio channel, the risc engine will enable the FIFO.
if ( fifo_enable && line == 2 )
// Check if we need to enable the FIFO after the first 3 lines
// For the upstream audio channel, the risc engine will enable the FIFO.
if ( fifo_enable && line == 2 )
{
*(rp++) = RISC_WRITECR;
*(rp++) = sram_ch->dma_ctl;
*(rp++) = sram_ch->fld_aud_fifo_en;
*(rp++) = 0x00000020;
}
offset += AUDIO_LINE_SIZE;
}
offset += AUDIO_LINE_SIZE;
}
return rp;
}
int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev,
struct pci_dev *pci,
unsigned int bpl, unsigned int lines)
struct pci_dev *pci,
unsigned int bpl, unsigned int lines)
{
__le32 *rp;
int fifo_enable = 0;
@ -148,7 +148,7 @@ int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev,
int risc_flag = RISC_CNT_INC;
dma_addr_t risc_phys_jump_addr;
/* Virtual address of Risc buffer program */
rp = dev->_risc_virt_addr;
@ -158,48 +158,48 @@ int cx25821_risc_buffer_upstream_audio( struct cx25821_dev *dev,
for( frame = 0; frame < NUM_AUDIO_FRAMES; frame++ )
{
databuf_offset = frame_size * frame;
if( frame == 0 )
{
fifo_enable = 1;
risc_flag = RISC_CNT_RESET;
}
else
{
fifo_enable = 0;
risc_flag = RISC_CNT_INC;
}
//Calculate physical jump address
if( (frame+1) == NUM_AUDIO_FRAMES )
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE;
}
else
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1);
}
rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable);
if( USE_RISC_NOOP_AUDIO )
{
for( i = 0; i < NUM_NO_OPS; i++ )
{
*(rp++) = cpu_to_le32(RISC_NOOP);
}
}
databuf_offset = frame_size * frame;
if( frame == 0 )
{
fifo_enable = 1;
risc_flag = RISC_CNT_RESET;
}
else
{
fifo_enable = 0;
risc_flag = RISC_CNT_INC;
}
//Calculate physical jump address
if( (frame+1) == NUM_AUDIO_FRAMES )
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE;
}
else
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE*(frame+1);
}
rp = cx25821_risc_field_upstream_audio(dev, rp, dev->_audiodata_buf_phys_addr+databuf_offset, bpl, fifo_enable);
if( USE_RISC_NOOP_AUDIO )
{
for( i = 0; i < NUM_NO_OPS; i++ )
{
*(rp++) = cpu_to_le32(RISC_NOOP);
}
}
// Loop to (Nth)FrameRISC 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);
// Loop to (Nth)FrameRISC 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);
//Recalculate virtual address based on frame index
rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ;
//Recalculate virtual address based on frame index
rp = dev->_risc_virt_addr + RISC_SYNC_INSTRUCTION_SIZE/4 + (AUDIO_RISC_DMA_BUF_SIZE*(frame+1)/4 ) ;
}
return 0;
@ -228,10 +228,10 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
if( !dev->_audio_is_running )
{
printk("cx25821: No audio file is currently running so return!\n");
return;
printk("cx25821: No audio file is currently running so return!\n");
return;
}
//Disable RISC interrupts
cx_write( sram_ch->int_msk, 0 );
@ -241,8 +241,8 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
//Clear data buffer memory
if( dev->_audiodata_buf_virt_addr )
memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size );
memset( dev->_audiodata_buf_virt_addr, 0, dev->_audiodata_buf_size );
dev->_audio_is_running = 0;
dev->_is_first_audio_frame = 0;
dev->_audioframe_count = 0;
@ -250,12 +250,12 @@ void cx25821_stop_upstream_audio(struct cx25821_dev *dev)
if( dev->_irq_audio_queues )
{
kfree(dev->_irq_audio_queues);
dev->_irq_audio_queues = NULL;
kfree(dev->_irq_audio_queues);
dev->_irq_audio_queues = NULL;
}
if( dev->_audiofilename != NULL )
kfree(dev->_audiofilename);
kfree(dev->_audiofilename);
}
@ -263,7 +263,7 @@ void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev)
{
if( dev->_audio_is_running )
{
cx25821_stop_upstream_audio(dev);
cx25821_stop_upstream_audio(dev);
}
cx25821_free_memory_audio(dev);
@ -286,69 +286,69 @@ int cx25821_get_audio_data(struct cx25821_dev *dev, struct sram_channel *sram_ch
if( dev->_audiofile_status == END_OF_FILE )
return 0;
return 0;
myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 );
if (IS_ERR(myfile))
{
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!\n", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%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->_audio_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->_audiodata_buf_virt_addr != NULL )
{
memcpy( (void*)(dev->_audiodata_buf_virt_addr+frame_offset/4), mybuf, vfs_read_retval);
}
file_offset += vfs_read_retval;
frame_offset += vfs_read_retval;
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!\n", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%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->_audio_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->_audiodata_buf_virt_addr != NULL )
{
memcpy( (void*)(dev->_audiodata_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 )
{
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break;
}
}
if( i > 0 )
dev->_audioframe_count++;
if( vfs_read_retval < line_size )
{
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break;
}
}
if( i > 0 )
dev->_audioframe_count++;
dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs);
filp_close(myfile, NULL);
set_fs(old_fs);
filp_close(myfile, NULL);
}
return 0;
@ -360,8 +360,8 @@ static void cx25821_audioups_handler(struct work_struct *work)
if( !dev )
{
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
}
cx25821_get_audio_data( dev, &dev->sram_channels[dev->_audio_upstream_channel_select] );
@ -377,91 +377,91 @@ int cx25821_openfile_audio(struct cx25821_dev *dev, struct sram_channel *sram_ch
loff_t pos;
loff_t offset = (unsigned long)0;
mm_segment_t old_fs;
myfile = filp_open( dev->_audiofilename, O_RDONLY | O_LARGEFILE, 0 );
if (IS_ERR(myfile))
{
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_audiofilename, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered! \n", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%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( j = 0; j < NUM_AUDIO_FRAMES; j++ )
{
for( i = 0; i < dev->_audio_lines_count; i++ )
{
pos = offset;
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered! \n", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%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( j = 0; j < NUM_AUDIO_FRAMES; j++ )
{
for( i = 0; i < dev->_audio_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->_audiodata_buf_virt_addr != NULL )
{
memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval);
}
offset += vfs_read_retval;
vfs_read_retval = vfs_read(myfile, mybuf, line_size, &pos);
if( vfs_read_retval > 0 && vfs_read_retval == line_size && dev->_audiodata_buf_virt_addr != NULL )
{
memcpy( (void*)(dev->_audiodata_buf_virt_addr+offset/4), mybuf, vfs_read_retval);
}
offset += vfs_read_retval;
if( vfs_read_retval < line_size )
{
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break;
}
}
if( i > 0 )
{
dev->_audioframe_count++;
}
if( vfs_read_retval < line_size )
{
break;
}
}
dev->_audiofile_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs);
myfile->f_pos = 0;
filp_close(myfile, NULL);
if( vfs_read_retval < line_size )
{
printk(KERN_INFO "Done: exit %s() since no more bytes to read from Audio file.\n", __func__ );
break;
}
}
if( i > 0 )
{
dev->_audioframe_count++;
}
if( vfs_read_retval < line_size )
{
break;
}
}
dev->_audiofile_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_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
struct sram_channel *sram_ch,
int bpl)
struct sram_channel *sram_ch,
int bpl)
{
int ret = 0;
dma_addr_t dma_addr;
dma_addr_t data_dma_addr;
cx25821_free_memory_audio(dev);
@ -474,7 +474,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_risc_virt_addr)
{
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n");
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for RISC program! Returning.\n");
return -ENOMEM;
}
@ -489,7 +489,7 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_audiodata_buf_virt_addr)
{
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n");
printk("cx25821 ERROR: pci_alloc_consistent() FAILED to allocate memory for data buffer! Returning. \n");
return -ENOMEM;
}
@ -499,8 +499,8 @@ static int cx25821_audio_upstream_buffer_prepare(struct cx25821_dev *dev,
ret = cx25821_openfile_audio(dev, sram_ch);
if( ret < 0 )
return ret;
return ret;
//Creating RISC programs
ret = cx25821_risc_buffer_upstream_audio(dev, dev->pci, bpl, dev->_audio_lines_count );
@ -528,86 +528,86 @@ int cx25821_audio_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status
if (status & FLD_AUD_SRC_RISCI1)
{
//Get interrupt_index of the program that interrupted
u32 prog_cnt = cx_read( channel->gpcnt );
u32 prog_cnt = cx_read( channel->gpcnt );
//Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
cx_write(channel->int_msk, 0);
cx_write(channel->int_stat, cx_read(channel->int_stat) );
//Since we've identified our IRQ, clear our bits from the interrupt mask and interrupt status registers
cx_write(channel->int_msk, 0);
cx_write(channel->int_stat, cx_read(channel->int_stat) );
spin_lock(&dev->slock);
while(prog_cnt != dev->_last_index_irq)
{
//Update _last_index_irq
if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1))
{
dev->_last_index_irq++;
}
else
{
dev->_last_index_irq = 0;
}
while(prog_cnt != dev->_last_index_irq)
{
//Update _last_index_irq
if(dev->_last_index_irq < (NUMBER_OF_PROGRAMS-1))
{
dev->_last_index_irq++;
}
else
{
dev->_last_index_irq = 0;
}
dev->_audioframe_index = dev->_last_index_irq;
queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry);
}
dev->_audioframe_index = dev->_last_index_irq;
queue_work(dev->_irq_audio_queues, &dev->_audio_work_entry);
}
if ( dev->_is_first_audio_frame )
{
dev->_is_first_audio_frame = 0;
if( dev->_risc_virt_start_addr != NULL )
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE;
rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE);
if ( dev->_is_first_audio_frame )
{
dev->_is_first_audio_frame = 0;
if( dev->_risc_virt_start_addr != NULL )
{
risc_phys_jump_addr = dev->_risc_phys_start_addr + RISC_SYNC_INSTRUCTION_SIZE + AUDIO_RISC_DMA_BUF_SIZE;
rp = cx25821_risc_field_upstream_audio(dev, dev->_risc_virt_start_addr+1, dev->_audiodata_buf_phys_addr, AUDIO_LINE_SIZE, FIFO_DISABLE);
if( USE_RISC_NOOP_AUDIO )
{
for( i = 0; i < NUM_NO_OPS; i++ )
{
*(rp++) = cpu_to_le32(RISC_NOOP);
}
}
// Jump to 2nd Audio Frame
*(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET);
*(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0);
}
}
if( USE_RISC_NOOP_AUDIO )
{
for( i = 0; i < NUM_NO_OPS; i++ )
{
*(rp++) = cpu_to_le32(RISC_NOOP);
}
}
// Jump to 2nd Audio Frame
*(rp++) = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_RESET);
*(rp++) = cpu_to_le32(risc_phys_jump_addr);
*(rp++) = cpu_to_le32(0);
}
}
spin_unlock(&dev->slock);
}
else
{
if(status & FLD_AUD_SRC_OF)
printk("%s: Audio Received Overflow Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_OF)
printk("%s: Audio Received Overflow Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_SYNC)
printk("%s: Audio Received Sync Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_SYNC)
printk("%s: Audio Received Sync Error Interrupt!\n", __func__);
if(status & FLD_AUD_SRC_OPC_ERR)
printk("%s: Audio Received OpCode Error Interrupt!\n", __func__);
// Read and write back the interrupt status register to clear our bits
cx_write(channel->int_stat, cx_read(channel->int_stat) );
if(status & FLD_AUD_SRC_OPC_ERR)
printk("%s: Audio Received OpCode Error Interrupt!\n", __func__);
// Read and write back the interrupt status register to clear our bits
cx_write(channel->int_stat, cx_read(channel->int_stat) );
}
if( dev->_audiofile_status == END_OF_FILE )
{
printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count );
return -1;
printk("cx25821: EOF Channel Audio Framecount = %d\n", dev->_audioframe_count );
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;
}
@ -620,8 +620,8 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
if( !dev )
return -1;
return -1;
sram_ch = &dev->sram_channels[dev->_audio_upstream_channel_select];
@ -631,17 +631,17 @@ static irqreturn_t cx25821_upstream_irq_audio(int irq, void *dev_id)
// Only deal with our interrupt
if(audio_status)
{
handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status);
handled = cx25821_audio_upstream_irq(dev, dev->_audio_upstream_channel_select, audio_status);
}
if( handled < 0 )
{
cx25821_stop_upstream_audio(dev);
cx25821_stop_upstream_audio(dev);
}
else
{
handled += handled;
handled += handled;
}
return IRQ_RETVAL(handled);
@ -655,24 +655,24 @@ static void cx25821_wait_fifo_enable(struct cx25821_dev *dev, struct sram_channe
do
{
//Wait 10 microsecond before checking to see if the FIFO is turned ON.
udelay(10);
//Wait 10 microsecond before checking to see if the FIFO is turned ON.
udelay(10);
tmp = cx_read( sram_ch->dma_ctl );
if(count++ > 1000) //10 millisecond timeout
{
printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__);
return;
}
tmp = cx_read( sram_ch->dma_ctl );
if(count++ > 1000) //10 millisecond timeout
{
printk("cx25821 ERROR: %s() fifo is NOT turned on. Timeout!\n", __func__);
return;
}
} while( !(tmp & sram_ch->fld_aud_fifo_en) );
}
int cx25821_start_audio_dma_upstream(struct cx25821_dev *dev,
struct sram_channel *sram_ch)
struct sram_channel *sram_ch)
{
u32 tmp = 0;
int err = 0;
@ -744,10 +744,10 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
if( dev->_audio_is_running )
{
printk("Audio Channel is still running so return!\n");
return 0;
printk("Audio Channel is still running so return!\n");
return 0;
}
dev->_audio_upstream_channel_select = channel_select;
sram_ch = &dev->sram_channels[channel_select];
@ -757,10 +757,10 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
if(!dev->_irq_audio_queues)
{
printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n");
printk("cx25821 ERROR: create_singlethread_workqueue() for Audio FAILED!\n");
return -ENOMEM;
}
dev->_last_index_irq = 0;
dev->_audio_is_running = 0;
@ -769,32 +769,32 @@ int cx25821_audio_upstream_init(struct cx25821_dev *dev, int channel_select)
dev->_audio_lines_count = LINES_PER_AUDIO_BUFFER;
_line_size = AUDIO_LINE_SIZE;
if( dev->input_audiofilename )
{
str_length = strlen(dev->input_audiofilename);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename )
goto error;
memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1);
str_length = strlen(dev->input_audiofilename);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename )
goto error;
memcpy(dev->_audiofilename, dev->input_audiofilename, str_length + 1);
//Default if filename is empty string
if( strcmp(dev->input_audiofilename,"") == 0)
{
dev->_audiofilename = "/root/audioGOOD.wav";
}
//Default if filename is empty string
if( strcmp(dev->input_audiofilename,"") == 0)
{
dev->_audiofilename = "/root/audioGOOD.wav";
}
}
else
{
str_length = strlen(_defaultAudioName);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename )
goto error;
memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1);
str_length = strlen(_defaultAudioName);
dev->_audiofilename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_audiofilename )
goto error;
memcpy(dev->_audiofilename, _defaultAudioName, str_length + 1);
}
@ -822,4 +822,3 @@ error:
return err;
}

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH11]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -99,18 +99,18 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH11] && h->video_dev[SRAM_CH11]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -128,21 +128,21 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = 10;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO11))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO11))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO11)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return POLLIN|POLLRDNORM;
return 0;
}
@ -199,17 +199,17 @@ static int video_release(struct file *file)
struct cx25821_dev *dev = fh->dev;
//stop the risc engine and fifo
//cx_write(channel11->dma_ctl, 0);
//cx_write(channel11->dma_ctl, 0);
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO11)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO11);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO11);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO11))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO11);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -272,18 +272,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height;
@ -293,30 +293,30 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
return 0;
}
static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg)
{
static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned long arg)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
int command = 0;
struct upstream_user_struct *data_from_user;
data_from_user = (struct upstream_user_struct *)arg;
if( !data_from_user )
{
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
}
command = data_from_user->command;
if( command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO )
{
return 0;
return 0;
}
dev->input_filename = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname = data_from_user->vid_stdname;
@ -324,18 +324,18 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, unsigned
dev->channel_select = data_from_user->channel_select;
dev->command = data_from_user->command;
switch(command)
{
case UPSTREAM_START_AUDIO:
cx25821_start_upstream_audio(dev, data_from_user);
break;
case UPSTREAM_STOP_AUDIO:
cx25821_stop_upstream_audio(dev);
break;
switch(command)
{
case UPSTREAM_START_AUDIO:
cx25821_start_upstream_audio(dev, data_from_user);
break;
case UPSTREAM_STOP_AUDIO:
cx25821_stop_upstream_audio(dev);
break;
}
return 0;
}
@ -366,11 +366,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct cx25821_dev *dev = fh->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
return 0;
}
@ -382,7 +382,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
.ioctl = video_ioctl_upstream11,
.ioctl = video_ioctl_upstream11,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {

View File

@ -30,12 +30,12 @@
#include "cx25821.h"
#include "tuner-xc2028.h"
// board config info
// board config info
struct cx25821_board cx25821_boards[] = {
[UNKNOWN_BOARD] = {
.name = "UNKNOWN/GENERIC",
// Ensure safe default for unknown boards
// Ensure safe default for unknown boards
.clk_freq = 0,
},
@ -43,8 +43,8 @@ struct cx25821_board cx25821_boards[] = {
.name = "CX25821",
.portb = CX25821_RAW,
.portc = CX25821_264,
.input[0].type = CX25821_VMUX_COMPOSITE,
},
.input[0].type = CX25821_VMUX_COMPOSITE,
},
};
@ -63,7 +63,7 @@ void cx25821_card_setup(struct cx25821_dev *dev)
{
static u8 eeprom[256];
if (dev->i2c_bus[0].i2c_rc == 0)
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));

File diff suppressed because it is too large Load Diff

View File

@ -25,17 +25,17 @@
/********************* GPIO stuffs *********************/
void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
int pin_number,
int pin_logic_value)
int pin_number,
int pin_logic_value)
{
int bit = pin_number;
u32 gpio_oe_reg = GPIO_LO_OE;
u32 gpio_register = 0;
u32 value = 0;
// Check for valid pinNumber
if ( pin_number >= 47 )
return;
return;
if ( pin_number > 31 )
@ -46,32 +46,32 @@ void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
// Here we will make sure that the GPIOs 0 and 1 are output. keep the rest as is
gpio_register = cx_read( gpio_oe_reg );
if (pin_logic_value == 1)
{
value = gpio_register | Set_GPIO_Bit(bit) ;
value = gpio_register | Set_GPIO_Bit(bit) ;
}
else
{
value = gpio_register & Clear_GPIO_Bit(bit) ;
value = gpio_register & Clear_GPIO_Bit(bit) ;
}
cx_write( gpio_oe_reg, value );
}
static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev,
int pin_number,
int pin_logic_value)
{
int pin_number,
int pin_logic_value)
{
int bit = pin_number;
u32 gpio_reg = GPIO_LO;
u32 value = 0;
// Check for valid pinNumber
if (pin_number >= 47)
return;
return;
cx25821_set_gpiopin_direction(dev, pin_number, 0); // change to output direction
@ -82,15 +82,15 @@ static void cx25821_set_gpiopin_logicvalue( struct cx25821_dev *dev,
}
value = cx_read( gpio_reg );
if (pin_logic_value == 0)
{
value &= Clear_GPIO_Bit(bit);
value &= Clear_GPIO_Bit(bit);
}
else
{
value |= Set_GPIO_Bit(bit);
value |= Set_GPIO_Bit(bit);
}
cx_write( gpio_reg, value);
@ -102,15 +102,15 @@ void cx25821_gpio_init(struct cx25821_dev *dev)
{
return;
}
switch (dev->board)
switch (dev->board)
{
case CX25821_BOARD_CONEXANT_ATHENA10:
default:
//set GPIO 5 to select the path for Medusa/Athena
cx25821_set_gpiopin_logicvalue(dev, 5, 1);
case CX25821_BOARD_CONEXANT_ATHENA10:
default:
//set GPIO 5 to select the path for Medusa/Athena
cx25821_set_gpiopin_logicvalue(dev, 5, 1);
mdelay(20);
break;
}
}

View File

@ -88,9 +88,9 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg
dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len);
/* Deal with i2c probe functions with zero payload */
if (msg->len == 0)
if (msg->len == 0)
{
cx_write(bus->reg_addr, msg->addr << 25);
cx_write(bus->reg_addr, msg->addr << 25);
cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2));
if (!i2c_wait_done(i2c_adap))
@ -106,7 +106,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg
/* dev, reg + first byte */
addr = (msg->addr << 25) | msg->buf[0];
wdata = msg->buf[0];
ctrl = bus->i2c_period | (1 << 12) | (1 << 2);
if (msg->len > 1)
@ -125,7 +125,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg
if (retval == 0)
goto eio;
if (i2c_debug)
if (i2c_debug)
{
if (!(ctrl & I2C_NOSTOP))
printk(" >\n");
@ -152,14 +152,14 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, const struct i2c_msg *msg
if (retval == 0)
goto eio;
if (i2c_debug)
if (i2c_debug)
{
dprintk(1, " %02x", msg->buf[cnt]);
if (!(ctrl & I2C_NOSTOP))
dprintk(1, " >\n");
}
}
return msg->len;
eio:
@ -244,18 +244,18 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
dprintk(1, "%s(num = %d)\n", __func__, num);
for (i = 0 ; i < num; i++)
for (i = 0 ; i < num; i++)
{
dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n",
__func__, num, msgs[i].addr, msgs[i].len);
if (msgs[i].flags & I2C_M_RD)
if (msgs[i].flags & I2C_M_RD)
{
/* read */
retval = i2c_readbytes(i2c_adap, &msgs[i], 0);
}
}
else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) &&
msgs[i].addr == msgs[i + 1].addr)
msgs[i].addr == msgs[i + 1].addr)
{
/* write then read from same address */
retval = i2c_sendbytes(i2c_adap, &msgs[i], msgs[i + 1].len);
@ -264,13 +264,13 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
goto err;
i++;
retval = i2c_readbytes(i2c_adap, &msgs[i], 1);
}
else
}
else
{
/* write */
retval = i2c_sendbytes(i2c_adap, &msgs[i], 0);
}
if (retval < 0)
goto err;
}
@ -283,9 +283,9 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
static u32 cx25821_functionality(struct i2c_adapter *adap)
{
return I2C_FUNC_SMBUS_EMUL |
return I2C_FUNC_SMBUS_EMUL |
I2C_FUNC_I2C |
I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_READ_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_WORD_DATA;
}
@ -334,7 +334,7 @@ int cx25821_i2c_register(struct cx25821_i2c *bus)
//set up the I2c
bus->i2c_client.addr = (0x88>>1);
return bus->i2c_rc;
}
@ -375,19 +375,19 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value)
int v = 0;
u8 addr[2] = {0, 0};
u8 buf[4] = {0,0,0,0};
struct i2c_msg msgs[2]={
{
.addr = client->addr,
.flags = 0,
.len = 2,
.buf = addr,
}, {
.addr = client->addr,
.flags = I2C_M_RD,
.len = 4,
.buf = buf,
}
{
.addr = client->addr,
.flags = 0,
.len = 2,
.buf = addr,
}, {
.addr = client->addr,
.flags = I2C_M_RD,
.len = 4,
.buf = buf,
}
};
@ -401,23 +401,23 @@ int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value)
v = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0];
*value = v;
return v;
return v;
}
int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value)
{
struct i2c_client *client = &bus->i2c_client;
int retval = 0;
int retval = 0;
u8 buf[6] = {0, 0, 0, 0, 0, 0};
struct i2c_msg msgs[1]={
{
.addr = client->addr,
.flags = 0,
.len = 6,
.buf = buf,
}
{
.addr = client->addr,
.flags = 0,
.len = 6,
.buf = buf,
}
};

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
*
* This program is free software; you can redistribute it and/or modify
@ -38,52 +38,52 @@ static void medusa_enable_bluefield_output(struct cx25821_dev *dev, int channel,
int out_ctrl = OUT_CTRL1;
int out_ctrl_ns = OUT_CTRL_NS;
switch (channel)
{
default:
case VDEC_A:
break;
case VDEC_B:
out_ctrl = VDEC_B_OUT_CTRL1;
out_ctrl_ns = VDEC_B_OUT_CTRL_NS;
break;
case VDEC_C:
out_ctrl = VDEC_C_OUT_CTRL1;
out_ctrl_ns = VDEC_C_OUT_CTRL_NS;
break;
case VDEC_D:
out_ctrl = VDEC_D_OUT_CTRL1;
out_ctrl_ns = VDEC_D_OUT_CTRL_NS;
break;
case VDEC_E:
out_ctrl = VDEC_E_OUT_CTRL1;
out_ctrl_ns = VDEC_E_OUT_CTRL_NS;
return;
case VDEC_F:
out_ctrl = VDEC_F_OUT_CTRL1;
out_ctrl_ns = VDEC_F_OUT_CTRL_NS;
return;
case VDEC_G:
out_ctrl = VDEC_G_OUT_CTRL1;
out_ctrl_ns = VDEC_G_OUT_CTRL_NS;
return;
case VDEC_H:
out_ctrl = VDEC_H_OUT_CTRL1;
out_ctrl_ns = VDEC_H_OUT_CTRL_NS;
return;
default:
case VDEC_A:
break;
case VDEC_B:
out_ctrl = VDEC_B_OUT_CTRL1;
out_ctrl_ns = VDEC_B_OUT_CTRL_NS;
break;
case VDEC_C:
out_ctrl = VDEC_C_OUT_CTRL1;
out_ctrl_ns = VDEC_C_OUT_CTRL_NS;
break;
case VDEC_D:
out_ctrl = VDEC_D_OUT_CTRL1;
out_ctrl_ns = VDEC_D_OUT_CTRL_NS;
break;
case VDEC_E:
out_ctrl = VDEC_E_OUT_CTRL1;
out_ctrl_ns = VDEC_E_OUT_CTRL_NS;
return;
case VDEC_F:
out_ctrl = VDEC_F_OUT_CTRL1;
out_ctrl_ns = VDEC_F_OUT_CTRL_NS;
return;
case VDEC_G:
out_ctrl = VDEC_G_OUT_CTRL1;
out_ctrl_ns = VDEC_G_OUT_CTRL_NS;
return;
case VDEC_H:
out_ctrl = VDEC_H_OUT_CTRL1;
out_ctrl_ns = VDEC_H_OUT_CTRL_NS;
return;
}
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl, &tmp);
value &= 0xFFFFFF7F; // clear BLUE_FIELD_EN
if (enable)
value |= 0x00000080; // set BLUE_FIELD_EN
value |= 0x00000080; // set BLUE_FIELD_EN
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl, value);
value = cx25821_i2c_read(&dev->i2c_bus[0], out_ctrl_ns, &tmp);
value &= 0xFFFFFF7F;
if (enable)
value |= 0x00000080; // set BLUE_FIELD_EN
value |= 0x00000080; // set BLUE_FIELD_EN
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], out_ctrl_ns, value);
}
@ -97,93 +97,93 @@ static int medusa_initialize_ntsc(struct cx25821_dev *dev)
mutex_lock(&dev->lock);
for (i=0; i < MAX_DECODERS; i++)
{
// set video format NTSC-M
value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0;
value |= 0x10001; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// resolution NTSC 720x480
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x612D0074;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// set video format NTSC-M
value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0;
value |= 0x10001; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000);
// enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// resolution NTSC 720x480
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x612D0074;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x1C1E001A; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields
//
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x43E00000);
// set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
// Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1);
// enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields
//
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
// Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1);
}
for (i=0; i < MAX_ENCODERS; i++)
{
// NTSC hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00;
value |= 0x06B402D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// NTSC hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00;
value |= 0x06B402D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000;
value |= 0x007E9054;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
// burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000;
value |= 0x007E9054;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00;
value |= 0x00EC00F0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00;
value |= 0x00EC00F0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
// set NTSC vblank, no phase alternation, 7.5 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF;
value |= 0x13020000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
// set NTSC vblank, no phase alternation, 7.5 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF;
value |= 0x13020000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000;
value |= 0x0000E575;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000;
value |= 0x0000E575;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x009A89C1);
// Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F);
// Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x21F07C1F);
}
@ -206,23 +206,23 @@ static int medusa_PALCombInit(struct cx25821_dev *dev, int dec)
{
int ret_val = -1;
u32 value = 0, tmp = 0;
// Setup for 2D threshold
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFS_CFG+(0x200*dec), 0x20002861);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFD_CFG+(0x200*dec), 0x20002861);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_LF_CFG+(0x200*dec), 0x200A1023);
// Setup flat chroma and luma thresholds
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_HFD_CFG+(0x200*dec), 0x20002861);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_LF_CFG+(0x200*dec), 0x200A1023);
// Setup flat chroma and luma thresholds
value = cx25821_i2c_read(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), &tmp);
value &= 0x06230000;
value &= 0x06230000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_FLAT_THRESH_CTRL+(0x200*dec), value);
// set comb 2D blend
// set comb 2D blend
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_2D_BLEND+(0x200*dec), 0x210F0F0F);
// COMB MISC CONTROL
// COMB MISC CONTROL
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], COMB_MISC_CTRL+(0x200*dec), 0x41120A7F);
return ret_val;
}
@ -235,110 +235,110 @@ static int medusa_initialize_pal(struct cx25821_dev *dev)
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], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0;
value |= 0x10004; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// resolution PAL 720x576
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x632D007D;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
// vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x28240026; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0);
// set video format PAL-BDGHI
value = cx25821_i2c_read(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), &tmp);
value &= 0xFFFFFFF0;
value |= 0x10004; // enable the fast locking mode bit[16]
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MODE_CTRL+(0x200*i), value);
// enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
medusa_PALCombInit(dev, i);
// Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1);
// resolution PAL 720x576
value = cx25821_i2c_read(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x632D007D;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HORIZ_TIM_CTRL+(0x200*i), value);
// vblank656_cnt=x26, vactive_cnt=240h, vblank_cnt=x24
value = cx25821_i2c_read(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), &tmp);
value &= 0x00C00C00;
value |= 0x28240026; // vblank_cnt + 2 to get camera ID
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VERT_TIM_CTRL+(0x200*i), value);
// chroma subcarrier step size
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], SC_STEP_SIZE+(0x200*i), 0x5411E2D0);
// enable VIP optional active
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL_NS+(0x200*i), value);
// enable VIP optional active (VIP_OPT_AL) for direct output.
value = cx25821_i2c_read(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), &tmp);
value &= 0xFFFBFFFF;
value |= 0x00040000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], OUT_CTRL1+(0x200*i), value);
// clear VPRES_VERT_EN bit, fixes the chroma run away problem
// when the input switching rate < 16 fields
value = cx25821_i2c_read(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), &tmp);
value = setBitAtPos(value, 14); // disable special play detection
value = clearBitAtPos(value, 15);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MISC_TIM_CTRL+(0x200*i), value);
// set vbi_gate_en to 0
value = cx25821_i2c_read(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), &tmp);
value = clearBitAtPos(value, 29);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DFE_CTRL1+(0x200*i), value);
medusa_PALCombInit(dev, i);
// Enable the generation of blue field output if no video
medusa_enable_bluefield_output(dev, i, 1);
}
for (i=0; i < MAX_ENCODERS; i++)
for (i=0; i < MAX_ENCODERS; i++)
{
// PAL hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00;
value |= 0x06C002D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// PAL hclock
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), &tmp);
value &= 0xF000FC00;
value |= 0x06C002D0;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_1+(0x100*i), value);
// burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000;
value |= 0x007E9754;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
// burst begin and burst end
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), &tmp);
value &= 0xFF000000;
value |= 0x007E9754;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_2+(0x100*i), value);
// hblank and vactive
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00;
value |= 0x00FC0120;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
// hblank and vactive
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), &tmp);
value &= 0xFC00FE00;
value |= 0x00FC0120;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_3+(0x100*i), value);
// set PAL vblank, phase alternation, 0 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF;
value |= 0x14010000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000;
value |= 0x0000F078;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
// set PAL vblank, phase alternation, 0 IRE pedestal
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), &tmp);
value &= 0x00FCFFFF;
value |= 0x14010000;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4+(0x100*i), value);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF);
// Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB);
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), &tmp);
value &= 0xFFFF0000;
value |= 0x0000F078;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_5+(0x100*i), value);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_6+(0x100*i), 0x00A493CF);
// Subcarrier Increment
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_7+(0x100*i), 0x2A098ACB);
}
//set picture resolutions
//set picture resolutions
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL, 0x0); //0 - 720
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL, 0x0); //0 - 576
// set Bypass input format to PAL 625 lines
// set Bypass input format to PAL 625 lines
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
value &= 0xFFF7FDFF;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
mutex_unlock(&dev->lock);
return ret_val;
@ -350,26 +350,26 @@ int medusa_set_videostandard(struct cx25821_dev *dev)
int status = STATUS_SUCCESS;
u32 value = 0, tmp = 0;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
{
status = medusa_initialize_pal(dev);
status = medusa_initialize_pal(dev);
}
else
{
status = medusa_initialize_ntsc(dev);
status = medusa_initialize_ntsc(dev);
}
// Enable DENC_A output
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_A_REG_4, &tmp);
value = setBitAtPos(value, 4);
status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_A_REG_4, value);
// Enable DENC_B output
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_B_REG_4, &tmp);
value = setBitAtPos(value, 4);
status = cx25821_i2c_write(&dev->i2c_bus[0], DENC_B_REG_4, value);
return status;
}
@ -380,7 +380,7 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_selec
int decoder_count = 0;
int ret_val = 0;
u32 hscale = 0x0;
u32 vscale = 0x0;
u32 vscale = 0x0;
const int MAX_WIDTH = 720;
mutex_lock(&dev->lock);
@ -388,55 +388,55 @@ void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_selec
// validate the width - cannot be negative
if (width > MAX_WIDTH)
{
printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH);
width = MAX_WIDTH;
}
printk("cx25821 %s() : width %d > MAX_WIDTH %d ! resetting to MAX_WIDTH \n", __func__, width, MAX_WIDTH);
width = MAX_WIDTH;
}
if( decoder_select <= 7 && decoder_select >= 0 )
{
decoder = decoder_select;
decoder_count = decoder_select + 1;
decoder = decoder_select;
decoder_count = decoder_select + 1;
}
else
{
decoder = 0;
decoder_count = _num_decoders;
decoder = 0;
decoder_count = _num_decoders;
}
switch( width )
{
case 320:
hscale = 0x13E34B;
vscale = 0x0;
break;
case 320:
hscale = 0x13E34B;
vscale = 0x0;
break;
case 352:
hscale = 0x10A273;
vscale = 0x0;
break;
case 352:
hscale = 0x10A273;
vscale = 0x0;
break;
case 176:
hscale = 0x3115B2;
vscale = 0x1E00;
break;
case 176:
hscale = 0x3115B2;
vscale = 0x1E00;
break;
case 160:
hscale = 0x378D84;
vscale = 0x1E00;
break;
case 160:
hscale = 0x378D84;
vscale = 0x1E00;
break;
default: //720
hscale = 0x0;
vscale = 0x0;
break;
}
default: //720
hscale = 0x0;
vscale = 0x0;
break;
}
for( ; decoder < decoder_count; decoder++)
{
// write scaling values for each decoder
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale);
// write scaling values for each decoder
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], HSCALE_CTRL+(0x200*decoder), hscale);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], VSCALE_CTRL+(0x200*decoder), vscale);
}
mutex_unlock(&dev->lock);
@ -448,52 +448,52 @@ static void medusa_set_decoderduration(struct cx25821_dev *dev, int decoder, int
u32 fld_cnt = 0;
u32 tmp = 0;
u32 disp_cnt_reg = DISP_AB_CNT;
mutex_lock(&dev->lock);
// no support
// no support
if (decoder < VDEC_A && decoder > VDEC_H)
{
mutex_unlock(&dev->lock);
return;
mutex_unlock(&dev->lock);
return;
}
switch (decoder)
{
default:
break;
case VDEC_C:
case VDEC_D:
disp_cnt_reg = DISP_CD_CNT;
break;
case VDEC_E:
case VDEC_F:
disp_cnt_reg = DISP_EF_CNT;
break;
case VDEC_G:
case VDEC_H:
disp_cnt_reg = DISP_GH_CNT;
break;
default:
break;
case VDEC_C:
case VDEC_D:
disp_cnt_reg = DISP_CD_CNT;
break;
case VDEC_E:
case VDEC_F:
disp_cnt_reg = DISP_EF_CNT;
break;
case VDEC_G:
case VDEC_H:
disp_cnt_reg = DISP_GH_CNT;
break;
}
_display_field_cnt[decoder] = duration;
// update hardware
fld_cnt = cx25821_i2c_read(&dev->i2c_bus[0], disp_cnt_reg, &tmp);
if (!(decoder % 2)) // EVEN decoder
{
fld_cnt &= 0xFFFF0000;
fld_cnt |= duration;
fld_cnt &= 0xFFFF0000;
fld_cnt |= duration;
}
else
{
fld_cnt &= 0x0000FFFF;
fld_cnt |= ((u32)duration) << 16;
fld_cnt &= 0x0000FFFF;
fld_cnt |= ((u32)duration) << 16;
}
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], disp_cnt_reg, fld_cnt);
mutex_unlock(&dev->lock);
}
@ -514,7 +514,7 @@ static int mapM(
if((srcMin == srcMax) || (srcVal < srcMin) || (srcVal > srcMax))
{
return -1;
return -1;
}
// This is the overall expression used:
@ -527,7 +527,7 @@ static int mapM(
if(2 * ( numerator % denominator ) >= denominator)
{
quotient++;
quotient++;
}
*dstVal = quotient + dstMin;
@ -540,12 +540,12 @@ static unsigned long convert_to_twos(long numeric, unsigned long bits_len)
unsigned char temp;
if (numeric >= 0)
return numeric;
return numeric;
else
{
temp = ~(abs(numeric) & 0xFF);
temp += 1;
return temp;
temp = ~(abs(numeric) & 0xFF);
temp += 1;
return temp;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
@ -558,8 +558,8 @@ int medusa_set_brightness(struct cx25821_dev *dev, int brightness, int decoder)
mutex_lock(&dev->lock);
if((brightness > VIDEO_PROCAMP_MAX) || (brightness < VIDEO_PROCAMP_MIN))
{
mutex_unlock(&dev->lock);
return -1;
mutex_unlock(&dev->lock);
return -1;
}
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, brightness, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
value = convert_to_twos(value, 8);
@ -578,11 +578,11 @@ int medusa_set_contrast(struct cx25821_dev *dev, int contrast, int decoder)
u32 val = 0, tmp = 0;
mutex_lock(&dev->lock);
if((contrast > VIDEO_PROCAMP_MAX) || (contrast < VIDEO_PROCAMP_MIN))
{
mutex_unlock(&dev->lock);
return -1;
mutex_unlock(&dev->lock);
return -1;
}
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, contrast, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
@ -602,15 +602,15 @@ int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder)
u32 val = 0, tmp = 0;
mutex_lock(&dev->lock);
if((hue > VIDEO_PROCAMP_MAX) || (hue < VIDEO_PROCAMP_MIN))
{
mutex_unlock(&dev->lock);
return -1;
mutex_unlock(&dev->lock);
return -1;
}
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, hue, SIGNED_BYTE_MIN, SIGNED_BYTE_MAX, &value);
value = convert_to_twos(value, 8);
val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_HUE_CTRL+(0x200*decoder), &tmp);
val &= 0xFFFFFF00;
@ -628,25 +628,25 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
int ret_val = 0;
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;
mutex_unlock(&dev->lock);
return -1;
}
ret_val = mapM(VIDEO_PROCAMP_MIN, VIDEO_PROCAMP_MAX, saturation, UNSIGNED_BYTE_MIN, UNSIGNED_BYTE_MAX, &value);
val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), &tmp);
val &= 0xFFFFFF00;
val &= 0xFFFFFF00;
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_USAT_CTRL+(0x200*decoder), val | value);
val = cx25821_i2c_read(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), &tmp);
val &= 0xFFFFFF00;
val &= 0xFFFFFF00;
ret_val |= cx25821_i2c_write(&dev->i2c_bus[0], VDEC_A_VSAT_CTRL+(0x200*decoder), val | value);
mutex_unlock(&dev->lock);
return ret_val;
}
@ -660,75 +660,75 @@ int medusa_video_init(struct cx25821_dev *dev)
u32 value = 0, tmp = 0;
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
// disable Auto source selection on all video decoders
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
value &= 0xFFFFF0FF;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
// Turn off Master source switch enable
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
value &= 0xFFFFFFDF;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
mutex_unlock(&dev->lock);
for (i=0; i < _num_decoders; i++)
{
medusa_set_decoderduration(dev, i, _display_field_cnt[i]);
medusa_set_decoderduration(dev, i, _display_field_cnt[i]);
}
mutex_lock(&dev->lock);
// Select monitor as DENC A input, power up the DAC
// Select monitor as DENC A input, power up the DAC
value = cx25821_i2c_read(&dev->i2c_bus[0], DENC_AB_CTRL, &tmp);
value &= 0xFF70FF70;
value |= 0x00090008; // set en_active
value |= 0x00090008; // set en_active
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
// enable input is VIP/656
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
value |= 0x00040100; // enable VIP
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
// select AFE clock to output mode
// select AFE clock to output mode
value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
value &= 0x83FFFFFF;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, value | 0x10000000);
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, value | 0x10000000);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
// Turn on all of the data out and control output pins.
@ -736,34 +736,34 @@ int medusa_video_init(struct cx25821_dev *dev)
value &= 0xFEF0FE00;
if (_num_decoders == MAX_DECODERS)
{
// Note: The octal board does not support control pins(bit16-19).
// These bits are ignored in the octal board.
value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface
// Note: The octal board does not support control pins(bit16-19).
// These bits are ignored in the octal board.
value |= 0x010001F8; // disable VDEC A-C port, default to Mobilygen Interface
}
else
{
value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface
value |= 0x010F0108; // disable VDEC A-C port, default to Mobilygen Interface
}
value |= 7;
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
mutex_unlock(&dev->lock);
return -EINVAL;
}
mutex_unlock(&dev->lock);
ret_val = medusa_set_videostandard(dev);
if (ret_val < 0)
{
mutex_unlock(&dev->lock);
return -EINVAL;
}
mutex_unlock(&dev->lock);
return -EINVAL;
}
return 1;
}

View File

@ -26,7 +26,7 @@
#include "cx25821-medusa-defines.h"
// Color control constants
// Color control constants
#define VIDEO_PROCAMP_MIN 0
#define VIDEO_PROCAMP_MAX 10000
#define UNSIGNED_BYTE_MIN 0

View File

@ -1481,7 +1481,7 @@
//*****************************************************************************
#define I2C1_ADDR 0x180000 // I2C #1 address
#define FLD_I2C_DADDR 0xfe000000 // RW [31:25] I2C Device Address
// RO [24] reserved
// RO [24] reserved
//*****************************************************************************
#define FLD_I2C_SADDR 0x00FFFFFF // RW [23:0] I2C Sub-address
@ -1494,15 +1494,15 @@
#define FLD_I2C_PERIOD 0xFF000000 // RW [31:24]
#define FLD_I2C_SCL_IN 0x00200000 // RW [21]
#define FLD_I2C_SDA_IN 0x00100000 // RW [20]
// RO [19:18] reserved
// RO [19:18] reserved
#define FLD_I2C_SCL_OUT 0x00020000 // RW [17]
#define FLD_I2C_SDA_OUT 0x00010000 // RW [16]
// RO [15] reserved
// RO [15] reserved
#define FLD_I2C_DATA_LEN 0x00007000 // RW [14:12]
#define FLD_I2C_SADDR_INC 0x00000800 // RW [11]
// RO [10:9] reserved
// RO [10:9] reserved
#define FLD_I2C_SADDR_LEN 0x00000300 // RW [9:8]
// RO [7:6] reserved
// RO [7:6] reserved
#define FLD_I2C_SOFT 0x00000020 // RW [5]
#define FLD_I2C_NOSTOP 0x00000010 // RW [4]
#define FLD_I2C_EXTEND 0x00000008 // RW [3]
@ -1588,13 +1588,13 @@
//*****************************************************************************
// Motion Detection
#define MD_CH0_GRID_BLOCK_YCNT 0x170014
#define MD_CH1_GRID_BLOCK_YCNT 0x170094
#define MD_CH2_GRID_BLOCK_YCNT 0x170114
#define MD_CH3_GRID_BLOCK_YCNT 0x170194
#define MD_CH4_GRID_BLOCK_YCNT 0x170214
#define MD_CH5_GRID_BLOCK_YCNT 0x170294
#define MD_CH6_GRID_BLOCK_YCNT 0x170314
#define MD_CH0_GRID_BLOCK_YCNT 0x170014
#define MD_CH1_GRID_BLOCK_YCNT 0x170094
#define MD_CH2_GRID_BLOCK_YCNT 0x170114
#define MD_CH3_GRID_BLOCK_YCNT 0x170194
#define MD_CH4_GRID_BLOCK_YCNT 0x170214
#define MD_CH5_GRID_BLOCK_YCNT 0x170294
#define MD_CH6_GRID_BLOCK_YCNT 0x170314
#define MD_CH7_GRID_BLOCK_YCNT 0x170394
#define PIXEL_FRMT_422 4

View File

@ -44,97 +44,97 @@ static int _intr_msk = FLD_VID_SRC_RISC1 | FLD_VID_SRC_UF | FLD_VID_SRC_SYNC | F
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)
__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);
}
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;
}
*(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)
__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->sram_channels[dev->_channel2_upstream_select];
int dist_betwn_starts = bpl * 2;
/* sync instruction */
if (sync_line != NO_SYNC_LINE)
{
*(rp++) = cpu_to_le32(RISC_RESYNC | 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);
}
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;
}
*(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;
}
// 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;
}
int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *pci,
unsigned int top_offset,
unsigned int bpl, unsigned int lines)
unsigned int top_offset,
unsigned int bpl, unsigned int lines)
{
__le32 *rp;
int fifo_enable = 0;
@ -148,57 +148,57 @@ int cx25821_risc_buffer_upstream_ch2( struct cx25821_dev *dev, struct pci_dev *p
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;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
odd_num_lines = singlefield_lines + 1;
risc_program_size = FRAME1_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
}
else
{
risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : 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);
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;
}
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);
// 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;
@ -212,8 +212,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
if( !dev->_is_running_ch2 )
{
printk("cx25821: No video file is currently running so return!\n");
return;
printk("cx25821: No video file is currently running so return!\n");
return;
}
//Disable RISC interrupts
@ -226,8 +226,8 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
//Clear data buffer memory
if( dev->_data_buf_virt_addr_ch2 )
memset( dev->_data_buf_virt_addr_ch2, 0, dev->_data_buf_size_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;
@ -235,12 +235,12 @@ void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev)
if( dev->_irq_queues_ch2 )
{
kfree(dev->_irq_queues_ch2);
dev->_irq_queues_ch2 = NULL;
kfree(dev->_irq_queues_ch2);
dev->_irq_queues_ch2 = NULL;
}
if( dev->_filename_ch2 != NULL )
kfree(dev->_filename_ch2);
kfree(dev->_filename_ch2);
tmp = cx_read( VID_CH_MODE_SEL );
cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
@ -250,19 +250,19 @@ void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev)
{
if( dev->_is_running_ch2 )
{
cx25821_stop_upstream_video_ch2(dev);
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;
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;
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;
}
}
@ -280,84 +280,84 @@ int cx25821_get_frame_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch
loff_t file_offset;
loff_t pos;
mm_segment_t old_fs;
if( dev->_file_status_ch2 == END_OF_FILE )
return 0;
return 0;
if( dev->_isNTSC_ch2 )
{
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
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_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);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered!", __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( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered!", __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 )
{
printk(KERN_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 )
{
printk(KERN_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;
dev->_file_status_ch2 = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs);
filp_close(myfile, NULL);
set_fs(old_fs);
filp_close(myfile, NULL);
}
return 0;
@ -369,8 +369,8 @@ static void cx25821_vidups_handler_ch2(struct work_struct *work)
if( !dev )
{
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
}
cx25821_get_frame_ch2( dev, &dev->sram_channels[dev->_channel2_upstream_select] );
@ -387,76 +387,76 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch)
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);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename_ch2, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered! Returning.", __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;
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered! Returning.", __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;
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 )
{
printk(KERN_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;
}
}
if( vfs_read_retval < line_size )
{
printk(KERN_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);
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;
@ -464,17 +464,17 @@ int cx25821_openfile_ch2(struct cx25821_dev *dev, struct sram_channel *sram_ch)
static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
struct sram_channel *sram_ch,
int bpl)
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);
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);
@ -486,8 +486,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
if (!dev->_dma_virt_addr_ch2)
{
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM;
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM;
}
@ -497,7 +497,7 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
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);
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
@ -507,8 +507,8 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
if (!dev->_data_buf_virt_addr_ch2)
{
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM;
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM;
}
@ -518,15 +518,15 @@ static int cx25821_upstream_buffer_prepare_ch2(struct cx25821_dev *dev,
ret = cx25821_openfile_ch2(dev, sram_ch);
if( ret < 0 )
return ret;
return ret;
//Creating RISC programs
ret = cx25821_risc_buffer_upstream_ch2(dev, dev->pci, 0, bpl, dev->_lines_count_ch2 );
if (ret < 0)
{
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error;
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error;
}
return 0;
@ -549,59 +549,59 @@ int cx25821_video_upstream_irq_ch2(struct cx25821_dev *dev, int chan_num, u32 st
if (status & FLD_VID_SRC_RISC1)
{
// We should only process one program per call
u32 prog_cnt = cx_read( channel->gpcnt );
// 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;
//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;
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->_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 )
{
line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : 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);
if( dev->_dma_virt_start_addr_ch2 != NULL )
{
line_size_in_bytes = (dev->_pixel_format_ch2 == PIXEL_FRMT_411) ? Y411_LINE_SZ : 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);
// 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 )
{
printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 );
return -1;
printk("cx25821: EOF Channel 2 Framecount = %d\n", dev->_frame_count_ch2 );
return -1;
}
//ElSE, set the interrupt mask register, re-enable irq.
@ -621,10 +621,10 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id)
if( !dev )
return -1;
return -1;
channel_num = VID_UPSTREAM_SRAM_CHANNEL_J;
sram_ch = &dev->sram_channels[channel_num];
msk_stat = cx_read(sram_ch->int_mstat);
@ -633,17 +633,17 @@ static irqreturn_t cx25821_upstream_irq_ch2(int irq, void *dev_id)
// Only deal with our interrupt
if(vid_status)
{
handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status);
handled = cx25821_video_upstream_irq_ch2(dev, channel_num, vid_status);
}
if( handled < 0 )
{
cx25821_stop_upstream_video_ch2(dev);
cx25821_stop_upstream_video_ch2(dev);
}
else
{
handled += handled;
handled += handled;
}
return IRQ_RETVAL(handled);
@ -658,7 +658,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha
u32 value;
int vip_mode = PIXEL_ENGINE_VIP1;
value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 );
value &= 0xFFFFFFEF;
value |= dev->_isNTSC_ch2 ? 0 : 0x10;
@ -672,7 +672,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha
if(dev->_isNTSC_ch2)
{
odd_num_lines += 1;
odd_num_lines += 1;
}
value = (num_lines << 16) | odd_num_lines;
@ -685,7 +685,7 @@ static void cx25821_set_pixelengine_ch2(struct cx25821_dev *dev, struct sram_cha
int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
struct sram_channel *sram_ch)
struct sram_channel *sram_ch)
{
u32 tmp = 0;
int err = 0;
@ -716,8 +716,8 @@ int cx25821_start_video_dma_upstream_ch2(struct cx25821_dev *dev,
err = request_irq(dev->pci->irq, cx25821_upstream_irq_ch2, IRQF_SHARED | IRQF_DISABLED, dev->name, dev);
if (err < 0)
{
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq;
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq;
}
// Start the DMA engine
@ -748,8 +748,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
if( dev->_is_running_ch2 )
{
printk("Video Channel is still running so return!\n");
return 0;
printk("Video Channel is still running so return!\n");
return 0;
}
dev->_channel2_upstream_select = channel_select;
@ -761,15 +761,15 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
if(!dev->_irq_queues_ch2)
{
printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n");
return -ENOMEM;
printk("cx25821: 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;
@ -779,43 +779,43 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
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 )
{
str_length = strlen(dev->input_filename_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 )
goto error;
memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1);
str_length = strlen(dev->input_filename_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 )
goto error;
memcpy(dev->_filename_ch2, dev->input_filename_ch2, str_length + 1);
}
else
{
str_length = strlen(dev->_defaultname_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 )
goto error;
memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1);
str_length = strlen(dev->_defaultname_ch2);
dev->_filename_ch2 = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename_ch2 )
goto error;
memcpy(dev->_filename_ch2, dev->_defaultname_ch2, str_length + 1);
}
//Default if filename is empty string
if( strcmp(dev->input_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";
}
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";
}
}
retval = cx25821_sram_channel_setup_upstream(dev, sram_ch, dev->_line_size_ch2, 0);
@ -830,8 +830,8 @@ int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev, int channel_select, in
retval = cx25821_upstream_buffer_prepare_ch2(dev, sram_ch, dev->_line_size_ch2);
if (retval < 0)
{
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error;
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error;
}

View File

@ -71,25 +71,25 @@
#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)
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)
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)
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)
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)
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)
RISC_WRITECR_INSTRUCTION_SIZE + NUM_NO_OPS*DWORD_SIZE)
#endif
@ -97,11 +97,11 @@
#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 )
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 )
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE )
#endif

View File

@ -43,19 +43,19 @@ MODULE_LICENSE("GPL");
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,
unsigned int bpl, u32 risc)
struct sram_channel *ch,
unsigned int bpl, u32 risc)
{
unsigned int i, lines;
u32 cdt;
if (ch->cmds_start == 0) {
cx_write(ch->ptr1_reg, 0);
cx_write(ch->ptr2_reg, 0);
cx_write(ch->cnt2_reg, 0);
cx_write(ch->cnt1_reg, 0);
return 0;
cx_write(ch->ptr1_reg, 0);
cx_write(ch->ptr2_reg, 0);
cx_write(ch->cnt2_reg, 0);
cx_write(ch->cnt1_reg, 0);
return 0;
}
bpl = (bpl + 7) & ~7; /* alignment */
@ -64,7 +64,7 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
if (lines > 4)
{
lines = 4;
lines = 4;
}
BUG_ON(lines < 2);
@ -72,10 +72,10 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
/* write CDT */
for (i = 0; i < lines; i++) {
cx_write(cdt + 16*i, ch->fifo_start + bpl*i);
cx_write(cdt + 16*i + 4, 0);
cx_write(cdt + 16*i + 8, 0);
cx_write(cdt + 16*i + 12, 0);
cx_write(cdt + 16*i, ch->fifo_start + bpl*i);
cx_write(cdt + 16*i + 4, 0);
cx_write(cdt + 16*i + 8, 0);
cx_write(cdt + 16*i + 12, 0);
}
/* write CMDS */
@ -85,12 +85,12 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
cx_write(ch->cmds_start + 8, cdt);
cx_write(ch->cmds_start + 12, (lines*16) >> 3);
cx_write(ch->cmds_start + 16, ch->ctrl_start);
cx_write(ch->cmds_start + 20, VID_IQ_SIZE_DW);
for (i = 24; i < 80; i += 4)
cx_write(ch->cmds_start + i, 0);
cx_write(ch->cmds_start + i, 0);
/* fill registers */
cx_write(ch->ptr1_reg, ch->fifo_start);
@ -102,8 +102,8 @@ int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
}
static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev,
__le32 *rp, unsigned int offset, unsigned int bpl,
u32 sync_line, unsigned int lines, int fifo_enable, int field_type)
__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;
@ -114,85 +114,85 @@ static __le32 *cx25821_update_riscprogram( struct cx25821_dev *dev,
if( USE_RISC_NOOP_VIDEO )
{
for( i = 0; i < NUM_NO_OPS; i++ )
{
*(rp++) = cpu_to_le32(RISC_NOOP);
}
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+offset);
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) )
{
offset += dist_betwn_starts;
}
*(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(0); /* bits 63-32 */
if ( (lines <= NTSC_FIELD_HEIGHT) || (line < (NTSC_FIELD_HEIGHT-1)) || !(dev->_isNTSC) )
{
offset += dist_betwn_starts;
}
}
return rp;
}
static __le32 *cx25821_risc_field_upstream( 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)
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->sram_channels[dev->_channel_upstream_select];
int dist_betwn_starts = bpl * 2;
/* sync instruction */
if (sync_line != NO_SYNC_LINE)
{
*(rp++) = cpu_to_le32(RISC_RESYNC | 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);
}
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) )
{
offset += dist_betwn_starts; //to skip the other field 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) )
{
offset += dist_betwn_starts; //to skip the other field line
}
// 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;
}
// 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;
}
int cx25821_risc_buffer_upstream( struct cx25821_dev *dev,
struct pci_dev *pci,
unsigned int top_offset,
unsigned int bpl, unsigned int lines)
struct pci_dev *pci,
unsigned int top_offset,
unsigned int bpl, unsigned int lines)
{
__le32 *rp;
int fifo_enable = 0;
@ -205,57 +205,57 @@ int cx25821_risc_buffer_upstream( struct cx25821_dev *dev,
int risc_flag = RISC_CNT_RESET;
unsigned int bottom_offset = bpl;
dma_addr_t risc_phys_jump_addr;
if( dev->_isNTSC )
{
odd_num_lines = singlefield_lines + 1;
risc_program_size = FRAME1_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
odd_num_lines = singlefield_lines + 1;
risc_program_size = FRAME1_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
}
else
{
risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
risc_program_size = PAL_VID_PROG_SIZE;
frame_size = (bpl == Y411_LINE_SZ) ? FRAME_SIZE_PAL_Y411 : FRAME_SIZE_PAL_Y422;
}
/* Virtual address of Risc buffer program */
rp = dev->_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+databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD);
}
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+databuf_offset, top_offset, 0, bpl, odd_num_lines, fifo_enable, ODD_FIELD);
}
fifo_enable = FIFO_DISABLE;
//Even Field
rp = cx25821_risc_field_upstream(dev, rp, dev->_data_buf_phys_addr+databuf_offset, bottom_offset, 0x200, bpl, singlefield_lines, fifo_enable, EVEN_FIELD);
fifo_enable = FIFO_DISABLE;
//Even Field
rp = cx25821_risc_field_upstream(dev, rp, dev->_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_program_size;
}
else
{
risc_phys_jump_addr = dev->_dma_phys_start_addr;
risc_flag = RISC_CNT_INC;
}
if( frame == 0 )
{
risc_flag = RISC_CNT_RESET;
risc_phys_jump_addr = dev->_dma_phys_start_addr + risc_program_size;
}
else
{
risc_phys_jump_addr = dev->_dma_phys_start_addr;
risc_flag = RISC_CNT_INC;
}
// 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);
// 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;
@ -269,10 +269,10 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
if( !dev->_is_running )
{
printk("cx25821: No video file is currently running so return!\n");
return;
printk("cx25821: 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);
@ -283,8 +283,8 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
//Clear data buffer memory
if( dev->_data_buf_virt_addr )
memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size );
memset( dev->_data_buf_virt_addr, 0, dev->_data_buf_size );
dev->_is_running = 0;
dev->_is_first_frame = 0;
dev->_frame_count = 0;
@ -292,12 +292,12 @@ void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
if( dev->_irq_queues )
{
kfree(dev->_irq_queues);
dev->_irq_queues = NULL;
kfree(dev->_irq_queues);
dev->_irq_queues = NULL;
}
if( dev->_filename != NULL )
kfree(dev->_filename);
kfree(dev->_filename);
tmp = cx_read( VID_CH_MODE_SEL );
cx_write( VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
@ -307,19 +307,19 @@ void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev)
{
if( dev->_is_running )
{
cx25821_stop_upstream_video_ch1(dev);
cx25821_stop_upstream_video_ch1(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;
pci_free_consistent(dev->pci, dev->_risc_size, dev->_dma_virt_addr, dev->_dma_phys_addr);
dev->_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;
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;
}
}
@ -337,84 +337,84 @@ int cx25821_get_frame(struct cx25821_dev *dev, struct sram_channel *sram_ch )
loff_t file_offset;
loff_t pos;
mm_segment_t old_fs;
if( dev->_file_status == END_OF_FILE )
return 0;
return 0;
if( dev->_isNTSC )
{
frame_size = (line_size == Y411_LINE_SZ) ? FRAME_SIZE_NTSC_Y411 : FRAME_SIZE_NTSC_Y422;
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_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);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered!", __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( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered!", __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 )
{
printk(KERN_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 )
{
printk(KERN_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;
dev->_file_status = (vfs_read_retval == line_size) ? IN_PROGRESS : END_OF_FILE;
set_fs(old_fs);
filp_close(myfile, NULL);
set_fs(old_fs);
filp_close(myfile, NULL);
}
return 0;
@ -426,8 +426,8 @@ static void cx25821_vidups_handler(struct work_struct *work)
if( !dev )
{
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
printk("ERROR %s(): since container_of(work_struct) FAILED! \n", __func__ );
return;
}
cx25821_get_frame( dev, &dev->sram_channels[dev->_channel_upstream_select] );
@ -444,77 +444,77 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch)
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);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile);
const int open_errno = -PTR_ERR(myfile);
printk("%s(): ERROR opening file(%s) with errno = %d! \n", __func__, dev->_filename, open_errno);
return PTR_ERR(myfile);
}
else
{
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered! Returning.", __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;
if( !(myfile->f_op) )
{
printk("%s: File has no file operations registered!", __func__);
filp_close(myfile, NULL);
return -EIO;
}
if( !myfile->f_op->read )
{
printk("%s: File has no READ operations registered! Returning.", __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;
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 )
{
printk(KERN_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;
}
}
if( vfs_read_retval < line_size )
{
printk(KERN_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);
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;
@ -522,8 +522,8 @@ int cx25821_openfile(struct cx25821_dev *dev, struct sram_channel *sram_ch)
int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
struct sram_channel *sram_ch,
int bpl)
struct sram_channel *sram_ch,
int bpl)
{
int ret = 0;
dma_addr_t dma_addr;
@ -531,7 +531,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if( dev->_dma_virt_addr != NULL )
{
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr);
pci_free_consistent(dev->pci, dev->upstream_riscbuf_size, dev->_dma_virt_addr, dev->_dma_phys_addr);
}
@ -544,8 +544,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_dma_virt_addr)
{
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM;
printk("cx25821: FAILED to allocate memory for Risc buffer! Returning.\n");
return -ENOMEM;
}
@ -555,7 +555,7 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
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);
pci_free_consistent(dev->pci, dev->upstream_databuf_size, dev->_data_buf_virt_addr, dev->_data_buf_phys_addr);
}
//For Video Data buffer allocation
@ -565,8 +565,8 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
if (!dev->_data_buf_virt_addr)
{
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM;
printk("cx25821: FAILED to allocate memory for data buffer! Returning.\n");
return -ENOMEM;
}
@ -576,15 +576,15 @@ int cx25821_upstream_buffer_prepare(struct cx25821_dev *dev,
ret = cx25821_openfile(dev, sram_ch);
if( ret < 0 )
return ret;
return ret;
//Create RISC programs
ret = cx25821_risc_buffer_upstream(dev, dev->pci, 0, bpl, dev->_lines_count );
if (ret < 0)
{
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error;
printk(KERN_INFO "cx25821: Failed creating Video Upstream Risc programs! \n");
goto error;
}
return 0;
@ -607,70 +607,70 @@ int cx25821_video_upstream_irq(struct cx25821_dev *dev, int chan_num, u32 status
if (status & FLD_VID_SRC_RISC1)
{
// We should only process one program per call
u32 prog_cnt = cx_read( channel->gpcnt );
// 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 = prog_cnt;
//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 = prog_cnt;
queue_work(dev->_irq_queues, &dev->_irq_work_entry);
if ( dev->_is_first_frame )
{
dev->_is_first_frame = 0;
queue_work(dev->_irq_queues, &dev->_irq_work_entry);
if ( dev->_is_first_frame )
{
dev->_is_first_frame = 0;
if( dev->_isNTSC )
{
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->_isNTSC )
{
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 != NULL )
{
line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ;
risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size;
rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, 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->_dma_virt_start_addr != NULL )
{
line_size_in_bytes = (dev->_pixel_format == PIXEL_FRMT_411) ? Y411_LINE_SZ : Y422_LINE_SZ;
risc_phys_jump_addr = dev->_dma_phys_start_addr + odd_risc_prog_size;
rp = cx25821_update_riscprogram(dev, dev->_dma_virt_start_addr, 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);
}
else
{
if(status & FLD_VID_SRC_UF)
printk("%s: Video Received Underflow Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_UF)
printk("%s: Video Received Underflow Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_SYNC)
printk("%s: Video Received Sync Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_SYNC)
printk("%s: Video Received Sync Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_OPC_ERR)
printk("%s: Video Received OpCode Error Interrupt!\n", __func__);
if(status & FLD_VID_SRC_OPC_ERR)
printk("%s: Video Received OpCode Error Interrupt!\n", __func__);
}
if( dev->_file_status == END_OF_FILE )
{
printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count );
return -1;
printk("cx25821: EOF Channel 1 Framecount = %d\n", dev->_frame_count );
return -1;
}
//ElSE, set the interrupt mask register, re-enable irq.
@ -690,8 +690,8 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
if( !dev )
return -1;
return -1;
channel_num = VID_UPSTREAM_SRAM_CHANNEL_I;
sram_ch = &dev->sram_channels[channel_num];
@ -702,16 +702,16 @@ static irqreturn_t cx25821_upstream_irq(int irq, void *dev_id)
// Only deal with our interrupt
if(vid_status)
{
handled = cx25821_video_upstream_irq(dev, channel_num, vid_status);
handled = cx25821_video_upstream_irq(dev, channel_num, vid_status);
}
if( handled < 0 )
{
cx25821_stop_upstream_video_ch1(dev);
cx25821_stop_upstream_video_ch1(dev);
}
else
{
handled += handled;
handled += handled;
}
return IRQ_RETVAL(handled);
@ -725,7 +725,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i
int num_lines, odd_num_lines;
u32 value;
int vip_mode = OUTPUT_FRMT_656;
value = ( (pix_format & 0x3) << 12 ) | ( vip_mode & 0x7 );
value &= 0xFFFFFFEF;
@ -741,7 +741,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i
if(dev->_isNTSC)
{
odd_num_lines += 1;
odd_num_lines += 1;
}
value = (num_lines << 16) | odd_num_lines;
@ -754,7 +754,7 @@ void cx25821_set_pixelengine(struct cx25821_dev *dev, struct sram_channel *ch, i
int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
struct sram_channel *sram_ch)
struct sram_channel *sram_ch)
{
u32 tmp = 0;
int err = 0;
@ -785,8 +785,8 @@ int cx25821_start_video_dma_upstream(struct cx25821_dev *dev,
err = request_irq(dev->pci->irq, cx25821_upstream_irq, IRQF_SHARED | IRQF_DISABLED, dev->name, dev);
if (err < 0)
{
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq;
printk(KERN_ERR "%s: can't get upstream IRQ %d\n", dev->name, dev->pci->irq);
goto fail_irq;
}
@ -818,8 +818,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
if( dev->_is_running )
{
printk("Video Channel is still running so return!\n");
return 0;
printk("Video Channel is still running so return!\n");
return 0;
}
@ -832,15 +832,15 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
if(!dev->_irq_queues)
{
printk("cx25821: create_singlethread_workqueue() for Video FAILED!\n");
return -ENOMEM;
printk("cx25821: 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;
@ -850,40 +850,40 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
data_frame_size = dev->_isNTSC ? NTSC_DATA_BUF_SZ : PAL_DATA_BUF_SZ;
risc_buffer_size = dev->_isNTSC ? NTSC_RISC_BUF_SIZE : PAL_RISC_BUF_SIZE;
if( dev->input_filename )
{
str_length = strlen(dev->input_filename);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename )
goto error;
memcpy(dev->_filename, dev->input_filename, str_length + 1);
str_length = strlen(dev->input_filename);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename )
goto error;
memcpy(dev->_filename, dev->input_filename, str_length + 1);
}
else
{
str_length = strlen(dev->_defaultname);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename )
goto error;
memcpy(dev->_filename, dev->_defaultname, str_length + 1);
str_length = strlen(dev->_defaultname);
dev->_filename = (char *) kmalloc(str_length + 1, GFP_KERNEL);
if( !dev->_filename )
goto error;
memcpy(dev->_filename, dev->_defaultname, str_length + 1);
}
//Default if filename is empty string
if( strcmp(dev->input_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";
}
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;
@ -906,8 +906,8 @@ int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, int channel_select, in
retval = cx25821_upstream_buffer_prepare(dev, sram_ch, dev->_line_size);
if (retval < 0)
{
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error;
printk(KERN_ERR "%s: Failed to set up Video upstream buffers!\n", dev->name);
goto error;
}

View File

@ -70,38 +70,38 @@
#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)
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)
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)
RISC_WRITECR_INSTRUCTION_SIZE + 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)
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)
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)
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE + 2*NUM_NO_OPS*DWORD_SIZE)
#endif
#ifndef USE_RISC_NOOP_VIDEO
#define PAL_US_VID_PROG_SIZE ((PAL_FIELD_HEIGHT) * 3 * DWORD_SIZE + RISC_WRITECR_INSTRUCTION_SIZE + \
RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE)
RISC_SYNC_INSTRUCTION_SIZE + JUMP_INSTRUCTION_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 )
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 )
@ -109,5 +109,5 @@
#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 )
RISC_WRITECR_INSTRUCTION_SIZE + JUMP_INSTRUCTION_SIZE )
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -52,7 +52,7 @@
#define dprintk(level, fmt, arg...)\
do { if (VIDEO_DEBUG >= level)\
printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
} while (0)
@ -117,9 +117,9 @@ extern int res_locked(struct cx25821_dev *dev, unsigned int bit);
extern void 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);
struct cx25821_dmaqueue *q,
struct cx25821_buffer *buf,
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);

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH00]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,18 +100,18 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH00] && h->video_dev[SRAM_CH00]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -129,22 +129,22 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH00;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
fh->fmt = format_by_fourcc(pix_format);
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO0))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO0))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -176,36 +176,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO0)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH00] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH00] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -220,13 +220,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO0)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO0);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO0);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -246,17 +246,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO0))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -269,14 +269,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO0);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = PIXEL_FRMT_422;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH00, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH00, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH00] = 1;
dev->use_cif_resolution[SRAM_CH00] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH00] = 0;
dev->use_cif_resolution[SRAM_CH00] = 0;
}
dev->cif_width[SRAM_CH00] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH00 );
medusa_set_resolution( dev, fh->width, SRAM_CH00 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH00].count;
@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH00];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH00];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
@ -398,7 +398,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
.ioctl = video_ioctl2,
.ioctl = video_ioctl2,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH01]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH01] && h->video_dev[SRAM_CH01]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -129,9 +129,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH01;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -140,11 +140,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO1))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO1))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -176,36 +176,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO1)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH01] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH01] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO1)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO1);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO1);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO1))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO1);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH01, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH01, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH01] = 1;
dev->use_cif_resolution[SRAM_CH01] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH01] = 0;
}
dev->cif_width[SRAM_CH01] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH01 );
medusa_set_resolution( dev, fh->width, SRAM_CH01 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH01].count;
@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH01];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH01];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
@ -378,10 +378,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
@ -397,7 +397,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
.ioctl = video_ioctl2,
.ioctl = video_ioctl2,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH02]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH02] && h->video_dev[SRAM_CH02]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH02;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -139,11 +139,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO2))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO2))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -175,36 +175,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO2)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH02] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH02] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO2)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO2);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO2);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO2))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO2);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH02, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH02, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH02] = 1;
dev->use_cif_resolution[SRAM_CH02] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH02] = 0;
}
dev->cif_width[SRAM_CH02] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH02 );
medusa_set_resolution( dev, fh->width, SRAM_CH02 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
@ -349,7 +349,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH02].count;
@ -361,15 +361,15 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH02];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH02];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n",
dev->name);
cx25821_call_all(dev, core, log_status);
tmp = cx_read(sram_ch->dma_ctl);
printk(KERN_INFO "Video input 2 is %s\n", (tmp & 0x11)?"streaming" : "stopped");
printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n",
@ -381,10 +381,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH03]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -101,17 +101,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH03] && h->video_dev[SRAM_CH03]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH03;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -139,11 +139,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO3))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO3))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -175,36 +175,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO3)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH03] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH03] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -219,13 +219,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO3)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO3);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO3);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -245,17 +245,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO3))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -268,14 +268,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO3);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -286,21 +286,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -308,33 +308,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH03, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH03, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH03] = 1;
dev->use_cif_resolution[SRAM_CH03] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH03] = 0;
dev->use_cif_resolution[SRAM_CH03] = 0;
}
dev->cif_width[SRAM_CH03] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH03 );
medusa_set_resolution( dev, fh->width, SRAM_CH03 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -348,7 +348,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH03].count;
@ -360,7 +360,7 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH03];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH03];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
@ -379,10 +379,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH04]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH04] && h->video_dev[SRAM_CH04]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH04;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -137,11 +137,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO4))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO4))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -173,36 +173,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO4)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH04] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH04] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -217,13 +217,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO4)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO4);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO4);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO4))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO4);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -284,21 +284,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
// check priority
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -306,33 +306,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH04, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH04, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH04] = 1;
dev->use_cif_resolution[SRAM_CH04] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH04] = 0;
}
dev->cif_width[SRAM_CH04] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH04);
medusa_set_resolution( dev, fh->width, SRAM_CH04);
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -346,7 +346,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH04].count;
@ -358,7 +358,7 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH04];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH04];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
@ -377,10 +377,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH05]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH05] && h->video_dev[SRAM_CH05]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH05;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -138,11 +138,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO5))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO5))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -174,34 +174,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO5)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH05] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH05] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
@ -218,13 +218,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO5)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO5);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO5);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -244,17 +244,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO5))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -267,14 +267,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO5);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -284,21 +284,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -306,33 +306,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH05, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH05, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH05] = 1;
dev->use_cif_resolution[SRAM_CH05] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH05] = 0;
}
dev->cif_width[SRAM_CH05] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH05 );
medusa_set_resolution( dev, fh->width, SRAM_CH05 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -346,7 +346,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH05].count;
@ -357,14 +357,14 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH05];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH05];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n",
dev->name);
cx25821_call_all(dev, core, log_status);
tmp = cx_read(sram_ch->dma_ctl);
printk(KERN_INFO "Video input 5 is %s\n", (tmp & 0x11)?"streaming" : "stopped");
printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n",
@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH06]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH06] && h->video_dev[SRAM_CH06]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -127,9 +127,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH06;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
@ -138,11 +138,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO6))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO6))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -174,36 +174,36 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO6)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH06] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH06] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
}
@ -218,12 +218,12 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO6)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO6);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO6);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO6))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO6);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -283,21 +283,21 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -305,33 +305,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH06, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH06, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH06] = 1;
dev->use_cif_resolution[SRAM_CH06] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH06] = 0;
}
dev->cif_width[SRAM_CH06] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH06 );
medusa_set_resolution( dev, fh->width, SRAM_CH06 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -345,7 +345,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH06].count;
@ -357,14 +357,14 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH06];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH06];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n",
dev->name);
cx25821_call_all(dev, core, log_status);
tmp = cx_read(sram_ch->dma_ctl);
printk(KERN_INFO "Video input 6 is %s\n", (tmp & 0x11)?"streaming" : "stopped");
printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n",
@ -376,10 +376,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -37,39 +37,39 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH07]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -99,17 +99,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH07] && h->video_dev[SRAM_CH07]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -117,8 +117,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
fh->dev = dev;
@ -126,22 +126,22 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = SRAM_CH07;
dev->channel_opened = SRAM_CH07;
pix_format = (dev->pixel_formats[dev->channel_opened] == PIXEL_FRMT_411) ? V4L2_PIX_FMT_Y41P : V4L2_PIX_FMT_YUYV;
fh->fmt = format_by_fourcc(pix_format);
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -155,15 +155,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO7))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO7))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -173,34 +173,34 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO7)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
{
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH07] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
if( buf->vb.state == VIDEOBUF_DONE )
{
struct cx25821_dev *dev = fh->dev;
if( dev && dev->use_cif_resolution[SRAM_CH07] )
{
u8 cam_id = *((char*)buf->vb.baddr+3);
memcpy((char*)buf->vb.baddr, (char*)buf->vb.baddr + (fh->width * 2), (fh->width * 2));
*((char*)buf->vb.baddr+3) = cam_id;
}
}
return POLLIN|POLLRDNORM;
}
return 0;
@ -217,13 +217,13 @@ static int video_release(struct file *file)
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO7)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO7);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO7);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -243,17 +243,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO7))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -266,14 +266,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO7);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -283,13 +283,13 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
int err;
int pix_format = 0;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
@ -297,7 +297,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->vidq.field = f->fmt.pix.field;
@ -305,33 +305,33 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
// check if width and height is valid based on set standard
if (is_valid_width(f->fmt.pix.width, dev->tvnorm))
{
fh->width = f->fmt.pix.width;
fh->width = f->fmt.pix.width;
}
if (is_valid_height(f->fmt.pix.height, dev->tvnorm))
{
fh->height = f->fmt.pix.height;
fh->height = f->fmt.pix.height;
}
if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_Y41P)
pix_format = PIXEL_FRMT_411;
pix_format = PIXEL_FRMT_411;
else if (f->fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
pix_format = PIXEL_FRMT_422;
pix_format = PIXEL_FRMT_422;
else
return -EINVAL;
return -EINVAL;
cx25821_set_pixel_format( dev, SRAM_CH07, pix_format );
cx25821_set_pixel_format( dev, SRAM_CH07, pix_format );
// check if cif resolution
if (fh->width == 320 || fh->width == 352)
{
dev->use_cif_resolution[SRAM_CH07] = 1;
dev->use_cif_resolution[SRAM_CH07] = 1;
}else
{
dev->use_cif_resolution[SRAM_CH07] = 0;
}
dev->cif_width[SRAM_CH07] = fh->width;
medusa_set_resolution( dev, fh->width, SRAM_CH07 );
medusa_set_resolution( dev, fh->width, SRAM_CH07 );
dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, fh->width, fh->height, fh->vidq.field);
cx25821_call_all(dev, video, s_fmt, f);
@ -345,7 +345,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
ret_val = videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
p->sequence = dev->vidq[SRAM_CH07].count;
@ -356,14 +356,14 @@ static int vidioc_log_status (struct file *file, void *priv)
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
char name[32 + 2];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH07];
struct sram_channel *sram_ch = &dev->sram_channels[SRAM_CH07];
u32 tmp = 0;
snprintf(name, sizeof(name), "%s/2", dev->name);
printk(KERN_INFO "%s/2: ============ START LOG STATUS ============\n",
dev->name);
cx25821_call_all(dev, core, log_status);
tmp = cx_read(sram_ch->dma_ctl);
printk(KERN_INFO "Video input 7 is %s\n", (tmp & 0x11)?"streaming" : "stopped");
printk(KERN_INFO "%s/2: ============= END LOG STATUS =============\n",
@ -375,10 +375,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctl)
{
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh) {
if (fh) {
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[VIDEO_IOCTL_CH]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,18 +100,18 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->ioctl_dev && h->ioctl_dev->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->ioctl_dev && h->ioctl_dev->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -119,8 +119,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -129,22 +129,22 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = VIDEO_IOCTL_CH;
pix_format = V4L2_PIX_FMT_YUYV;
fh->fmt = format_by_fourcc(pix_format);
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -158,15 +158,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO_IOCTL))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -176,22 +176,22 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO_IOCTL)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return 0;
}
@ -199,17 +199,17 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
static int video_release(struct file *file)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
struct cx25821_dev *dev = fh->dev;
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO_IOCTL)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO_IOCTL);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO_IOCTL);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO_IOCTL))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -253,14 +253,14 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO_IOCTL);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
@ -272,18 +272,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height;
@ -299,8 +299,8 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p)
return videobuf_dqbuf(get_queue(fh), p, file->f_flags & O_NONBLOCK);
}
static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long arg)
{
static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long arg)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
struct downstream_user_struct *data_from_user;
@ -310,96 +310,96 @@ static long video_ioctl_set(struct file *file, unsigned int cmd, unsigned long a
int cif_enable = 0, cif_width = 0;
u32 value = 0;
data_from_user = (struct downstream_user_struct *)arg;
if( !data_from_user )
{
printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__);
return 0;
printk("cx25821 in %s(): User data is INVALID. Returning.\n", __func__);
return 0;
}
command = data_from_user->command;
if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION &&
command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE)
if( command != SET_VIDEO_STD && command != SET_PIXEL_FORMAT && command != ENABLE_CIF_RESOLUTION &&
command != REG_READ && command != REG_WRITE && command != MEDUSA_READ && command != MEDUSA_WRITE)
{
return 0;
return 0;
}
switch(command)
{
case SET_VIDEO_STD:
dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M;
medusa_set_videostandard(dev);
break;
case SET_PIXEL_FORMAT:
selected_channel = data_from_user->decoder_select;
pix_format = data_from_user->pixel_format;
{
case SET_VIDEO_STD:
dev->tvnorm = !strcmp(data_from_user->vid_stdname,"PAL") ? V4L2_STD_PAL_BG : V4L2_STD_NTSC_M;
medusa_set_videostandard(dev);
break;
if( !(selected_channel <= 7 && selected_channel >= 0) )
{
selected_channel -= 4;
selected_channel = selected_channel % 8;
}
if( selected_channel >= 0 )
cx25821_set_pixel_format( dev, selected_channel, pix_format );
break;
case ENABLE_CIF_RESOLUTION:
selected_channel = data_from_user->decoder_select;
cif_enable = data_from_user->cif_resolution_enable;
cif_width = data_from_user->cif_width;
if( cif_enable )
{
if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK )
width = 352;
else
width = (cif_width == 320 || cif_width == 352) ? cif_width : 320;
}
if( !(selected_channel <= 7 && selected_channel >= 0) )
{
selected_channel -= 4;
selected_channel = selected_channel % 8;
}
if( selected_channel <= 7 && selected_channel >= 0 )
{
dev->use_cif_resolution[selected_channel] = cif_enable;
dev->cif_width[selected_channel] = width;
}
else
{
for( i=0; i < VID_CHANNEL_NUM; i++ )
{
dev->use_cif_resolution[i] = cif_enable;
dev->cif_width[i] = width;
}
}
case SET_PIXEL_FORMAT:
selected_channel = data_from_user->decoder_select;
pix_format = data_from_user->pixel_format;
medusa_set_resolution( dev, width, selected_channel );
break;
case REG_READ:
data_from_user->reg_data = cx_read(data_from_user->reg_address);
break;
case REG_WRITE:
cx_write(data_from_user->reg_address, data_from_user->reg_data);
break;
case MEDUSA_READ:
value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data);
break;
case MEDUSA_WRITE:
cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data);
break;
if( !(selected_channel <= 7 && selected_channel >= 0) )
{
selected_channel -= 4;
selected_channel = selected_channel % 8;
}
if( selected_channel >= 0 )
cx25821_set_pixel_format( dev, selected_channel, pix_format );
break;
case ENABLE_CIF_RESOLUTION:
selected_channel = data_from_user->decoder_select;
cif_enable = data_from_user->cif_resolution_enable;
cif_width = data_from_user->cif_width;
if( cif_enable )
{
if( dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK )
width = 352;
else
width = (cif_width == 320 || cif_width == 352) ? cif_width : 320;
}
if( !(selected_channel <= 7 && selected_channel >= 0) )
{
selected_channel -= 4;
selected_channel = selected_channel % 8;
}
if( selected_channel <= 7 && selected_channel >= 0 )
{
dev->use_cif_resolution[selected_channel] = cif_enable;
dev->cif_width[selected_channel] = width;
}
else
{
for( i=0; i < VID_CHANNEL_NUM; i++ )
{
dev->use_cif_resolution[i] = cif_enable;
dev->cif_width[i] = width;
}
}
medusa_set_resolution( dev, width, selected_channel );
break;
case REG_READ:
data_from_user->reg_data = cx_read(data_from_user->reg_address);
break;
case REG_WRITE:
cx_write(data_from_user->reg_address, data_from_user->reg_data);
break;
case MEDUSA_READ:
value = cx25821_i2c_read(&dev->i2c_bus[0], (u16)data_from_user->reg_address, &data_from_user->reg_data);
break;
case MEDUSA_WRITE:
cx25821_i2c_write(&dev->i2c_bus[0], (u16)data_from_user->reg_address, data_from_user->reg_data);
break;
}
return 0;
}
@ -423,12 +423,12 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct cx25821_fh *fh = priv;
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
return 0;

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -41,37 +41,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH10]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -100,17 +100,17 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH10] && h->video_dev[SRAM_CH10]->minor == minor) {
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -128,22 +128,22 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = 9;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -157,15 +157,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO10))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO10))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -175,21 +175,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO10)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return POLLIN|POLLRDNORM;
return 0;
}
@ -199,17 +199,17 @@ static int video_release(struct file *file)
struct cx25821_dev *dev = fh->dev;
//stop the risc engine and fifo
//cx_write(channel10->dma_ctl, 0);
//cx_write(channel10->dma_ctl, 0);
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO10)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO10);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO10);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO10))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -253,61 +253,61 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO10);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned long arg)
{
static long video_ioctl_upstream10(struct file *file, unsigned int cmd, unsigned long arg)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
int command = 0;
struct upstream_user_struct *data_from_user;
data_from_user = (struct upstream_user_struct *)arg;
data_from_user = (struct upstream_user_struct *)arg;
if( !data_from_user )
{
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
}
command = data_from_user->command;
if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO )
{
return 0;
return 0;
}
dev->input_filename_ch2 = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname_ch2 = data_from_user->vid_stdname;
dev->pixel_format_ch2 = data_from_user->pixel_format;
dev->channel_select_ch2 = data_from_user->channel_select;
dev->command_ch2 = data_from_user->command;
switch(command)
{
case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch2(dev, data_from_user);
break;
case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch2(dev);
break;
switch(command)
{
case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch2(dev, data_from_user);
break;
case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch2(dev);
break;
}
return 0;
}
@ -318,18 +318,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height;
@ -366,11 +366,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
return 0;
@ -384,7 +384,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
.ioctl = video_ioctl_upstream10,
.ioctl = video_ioctl_upstream10,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -40,37 +40,37 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
dprintk(2, "jmp to stopper (0x%x)\n", buf->risc.jmp[1]);
if (!list_empty(&q->queued)) {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - append to queued\n", buf, buf->vb.i);
} else if (list_empty(&q->active)) {
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
list_add_tail(&buf->vb.queue, &q->active);
cx25821_start_video_dma(dev, q, buf, &dev->sram_channels[SRAM_CH09]);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(2, "[%p/%d] buffer_queue - first active, buf cnt = %d, q->count = %d\n",
buf, buf->vb. i, buf->count, q->count);
} else {
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
prev = list_entry(q->active.prev, struct cx25821_buffer, vb.queue);
if (prev->vb.width == buf->vb.width &&
prev->vb.height == buf->vb.height &&
prev->fmt == buf->fmt) {
list_add_tail(&buf->vb.queue, &q->active);
buf->vb.state = VIDEOBUF_ACTIVE;
buf->count = q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
/* 64 bit bits 63-32 */
prev->risc.jmp[2] = cpu_to_le32(0);
dprintk(2, "[%p/%d] buffer_queue - append to active, buf->count=%d\n", buf, buf->vb.i, buf->count);
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
} else {
list_add_tail(&buf->vb.queue, &q->queued);
buf->vb.state = VIDEOBUF_QUEUED;
dprintk(2, "[%p/%d] buffer_queue - first queued\n", buf, buf->vb.i);
}
}
if (list_empty(&q->active))
@ -99,18 +99,18 @@ static int video_open(struct file *file)
lock_kernel();
list_for_each(list, &cx25821_devlist)
{
h = list_entry(list, struct cx25821_dev, devlist);
h = list_entry(list, struct cx25821_dev, devlist);
if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
if (h->video_dev[SRAM_CH09] && h->video_dev[SRAM_CH09]->minor == minor)
{
dev = h;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
}
if (NULL == dev) {
unlock_kernel();
return -ENODEV;
unlock_kernel();
return -ENODEV;
}
printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
@ -118,8 +118,8 @@ static int video_open(struct file *file)
/* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
if (NULL == fh) {
unlock_kernel();
return -ENOMEM;
unlock_kernel();
return -ENOMEM;
}
file->private_data = fh;
@ -128,9 +128,9 @@ static int video_open(struct file *file)
fh->width = 720;
if(dev->tvnorm & V4L2_STD_PAL_BG || dev->tvnorm & V4L2_STD_PAL_DK)
fh->height = 576;
fh->height = 576;
else
fh->height = 480;
fh->height = 480;
dev->channel_opened = 8;
fh->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV);
@ -138,11 +138,11 @@ static int video_open(struct file *file)
v4l2_prio_open(&dev->prio,&fh->prio);
videobuf_queue_sg_init(&fh->vidq, &cx25821_video_qops,
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
&dev->pci->dev, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE,
V4L2_FIELD_INTERLACED,
sizeof(struct cx25821_buffer),
fh);
dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel();
@ -156,15 +156,15 @@ static ssize_t video_read(struct file *file, char __user *data, size_t count, lo
switch (fh->type)
{
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO9))
return -EBUSY;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if (res_locked(fh->dev, RESOURCE_VIDEO9))
return -EBUSY;
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
return videobuf_read_one(&fh->vidq, data, count, ppos, file->f_flags & O_NONBLOCK);
default:
BUG();
return 0;
default:
BUG();
return 0;
}
}
@ -174,21 +174,21 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait
struct cx25821_buffer *buf;
if (res_check(fh, RESOURCE_VIDEO9)) {
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
/* streaming capture */
if (list_empty(&fh->vidq.stream))
return POLLERR;
buf = list_entry(fh->vidq.stream.next,
struct cx25821_buffer, vb.stream);
} else {
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
/* read() capture */
buf = (struct cx25821_buffer *)fh->vidq.read_buf;
if (NULL == buf)
return POLLERR;
}
poll_wait(file, &buf->vb.done, wait);
if (buf->vb.state == VIDEOBUF_DONE || buf->vb.state == VIDEOBUF_ERROR)
return POLLIN|POLLRDNORM;
return POLLIN|POLLRDNORM;
return 0;
}
@ -199,17 +199,17 @@ static int video_release(struct file *file)
struct cx25821_dev *dev = fh->dev;
//stop the risc engine and fifo
//cx_write(channel9->dma_ctl, 0);
//cx_write(channel9->dma_ctl, 0);
/* stop video capture */
if (res_check(fh, RESOURCE_VIDEO9)) {
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO9);
videobuf_queue_cancel(&fh->vidq);
res_free(dev, fh, RESOURCE_VIDEO9);
}
if (fh->vidq.read_buf) {
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
buffer_release(&fh->vidq, fh->vidq.read_buf);
kfree(fh->vidq.read_buf);
}
videobuf_mmap_free(&fh->vidq);
@ -230,17 +230,17 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(i != fh->type))
{
return -EINVAL;
return -EINVAL;
}
if (unlikely(!res_get(dev, fh, get_resource(fh, RESOURCE_VIDEO9))))
{
return -EBUSY;
return -EBUSY;
}
return videobuf_streamon(get_queue(fh));
@ -253,62 +253,62 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
int err, res;
if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
return -EINVAL;
if (i != fh->type)
return -EINVAL;
return -EINVAL;
res = get_resource(fh, RESOURCE_VIDEO9);
err = videobuf_streamoff(get_queue(fh));
if (err < 0)
return err;
return err;
res_free(dev, fh, res);
return 0;
}
static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned long arg)
{
static long video_ioctl_upstream9(struct file *file, unsigned int cmd, unsigned long arg)
{
struct cx25821_fh *fh = file->private_data;
struct cx25821_dev *dev = fh->dev;
int command = 0;
struct upstream_user_struct *data_from_user;
data_from_user = (struct upstream_user_struct *)arg;
if( !data_from_user )
{
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
printk("cx25821 in %s(): Upstream data is INVALID. Returning.\n", __func__);
return 0;
}
command = data_from_user->command;
command = data_from_user->command;
if( command != UPSTREAM_START_VIDEO && command != UPSTREAM_STOP_VIDEO )
{
return 0;
return 0;
}
dev->input_filename = data_from_user->input_filename;
dev->input_audiofilename = data_from_user->input_filename;
dev->vid_stdname = data_from_user->vid_stdname;
dev->pixel_format = data_from_user->pixel_format;
dev->channel_select = data_from_user->channel_select;
dev->command = data_from_user->command;
switch(command)
{
case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch1(dev, data_from_user);
break;
case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch1(dev);
break;
{
case UPSTREAM_START_VIDEO:
cx25821_start_upstream_video_ch1(dev, data_from_user);
break;
case UPSTREAM_STOP_VIDEO:
cx25821_stop_upstream_video_ch1(dev);
break;
}
return 0;
}
@ -319,18 +319,18 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_forma
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
dprintk(2, "%s()\n", __func__);
err = vidioc_try_fmt_vid_cap(file, priv, f);
if (0 != err)
return err;
return err;
fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
fh->width = f->fmt.pix.width;
fh->height = f->fmt.pix.height;
@ -365,11 +365,11 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
struct cx25821_fh *fh = priv;
int err;
if (fh)
if (fh)
{
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
err = v4l2_prio_check(&dev->prio, &fh->prio);
if (0 != err)
return err;
}
return 0;
@ -382,7 +382,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read,
.poll = video_poll,
.mmap = video_mmap,
.ioctl = video_ioctl_upstream9,
.ioctl = video_ioctl_upstream9,
};
static const struct v4l2_ioctl_ops video_ioctl_ops = {

View File

@ -1,7 +1,7 @@
/*
* Driver for the Conexant CX25821 PCIe bridge
*
* Copyright (C) 2009 Conexant Systems Inc.
* Copyright (C) 2009 Conexant Systems Inc.
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
*
@ -35,7 +35,7 @@
#include <linux/smp_lock.h>
#include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <media/v4l2-device.h>
#include <media/tuner.h>
#include <media/tveeprom.h>
#include <media/videobuf-dma-sg.h>
@ -62,7 +62,7 @@
#define FALSE 0
#define LINE_SIZE_D1 1440
// Number of decoders and encoders
// Number of decoders and encoders
#define MAX_DECODERS 8
#define MAX_ENCODERS 2
#define QUAD_DECODERS 4
@ -91,7 +91,7 @@
#define UNKNOWN_BOARD 0
#define CX25821_BOARD 1
/* Currently supported by the driver */
/* Currently supported by the driver */
#define CX25821_NORMS (\
V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \
V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \
@ -292,7 +292,7 @@ struct cx25821_dev {
struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
/* Analog Audio Upstream */
int _audio_is_running;
int _audio_is_running;
int _audiopixel_format;
int _is_first_audio_frame;
int _audiofile_status;
@ -311,7 +311,7 @@ struct cx25821_dev {
unsigned int _audiodata_buf_size;
__le32 * _audiodata_buf_virt_addr;
dma_addr_t _audiodata_buf_phys_addr;
char *_audiofilename;
char *_audiofilename;
/* V4l */
u32 freq;
@ -322,7 +322,7 @@ struct cx25821_dev {
struct cx25821_dmaqueue vidq[MAX_VID_CHANNEL_NUM];
spinlock_t slock;
/* Video Upstream */
int _line_size;
int _prog_cnt;
@ -343,8 +343,8 @@ struct cx25821_dev {
unsigned int _data_buf_size;
__le32 * _data_buf_virt_addr;
dma_addr_t _data_buf_phys_addr;
char * _filename;
char * _defaultname;
char * _filename;
char * _defaultname;
int _line_size_ch2;
@ -366,8 +366,8 @@ struct cx25821_dev {
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;
char * _filename_ch2;
char * _defaultname_ch2;
/* MPEG Encoder ONLY settings */
u32 cx23417_mailbox;
@ -375,26 +375,26 @@ struct cx25821_dev {
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;
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;
int _frame_index_ch2;
int _isNTSC_ch2;
char *vid_stdname_ch2;
int pixel_format_ch2;
int channel_select_ch2;
@ -439,7 +439,7 @@ static inline struct cx25821_dev *get_cx25821(struct v4l2_device *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 cx25821_board cx25821_boards[];
extern struct cx25821_subid cx25821_subids[];
@ -487,16 +487,16 @@ struct sram_channel {
u32 aud_cfg;
u32 fld_aud_fifo_en;
u32 fld_aud_risc_en;
//For Upstream Video
u32 vid_fmt_ctl;
u32 vid_active_ctl1;
u32 vid_active_ctl2;
u32 vid_cdt_size;
u32 vip_ctl;
u32 pix_frmt;
u32 jumponly;
u32 jumponly;
u32 irq_bit;
};
extern struct sram_channel cx25821_sram_channels[];
@ -529,9 +529,9 @@ extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
extern void cx25821_gpio_init(struct cx25821_dev *dev);
extern void cx25821_set_gpiopin_direction( struct cx25821_dev *dev,
int pin_number,
int pin_logic_value);
int pin_number,
int pin_logic_value);
extern int medusa_video_init(struct cx25821_dev *dev);
extern int medusa_set_videostandard(struct cx25821_dev *dev);
extern void medusa_set_resolution(struct cx25821_dev *dev, int width, int decoder_select);
@ -543,18 +543,18 @@ extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int d
extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, struct sram_channel *ch, unsigned int bpl, u32 risc);
extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
struct scatterlist *sglist,
unsigned int top_offset,
unsigned int bottom_offset,
unsigned int bpl,
unsigned int padding,
unsigned int lines);
struct scatterlist *sglist,
unsigned int top_offset,
unsigned int bottom_offset,
unsigned int bpl,
unsigned int padding,
unsigned int lines);
extern int cx25821_risc_databuffer_audio(struct pci_dev *pci,
struct btcx_riscmem *risc,
struct scatterlist *sglist,
unsigned int bpl,
unsigned int lines,
unsigned int lpi);
struct btcx_riscmem *risc,
struct scatterlist *sglist,
unsigned int bpl,
unsigned int lines,
unsigned int lpi);
extern void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf);
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);
@ -565,26 +565,26 @@ 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,
unsigned int bpl, u32 risc);
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_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 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_audio(struct cx25821_dev *dev);
extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev);
extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev);
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_audio(struct cx25821_dev *dev);
extern int cx25821_sram_channel_setup_upstream( struct cx25821_dev *dev, 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);
struct pci_dev *pci,
struct video_device *template,
char *type);
#endif